ASP
  Home arrow ASP arrow Page 3 - View Your Web Servers Log Files With ASP
IBM developerWorks
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
Moblin 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP

View Your Web Servers Log Files With ASP
By:
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 15
    2001-12-28

    Table of Contents:
  • View Your Web Servers Log Files With ASP
  • Windows 2000 and log files
  • The MSWC logging utility
  • The ShowLogEntries sub-routine
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
    Iron Speed
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    View Your Web Servers Log Files With ASP - The MSWC logging utility


    (Page 3 of 5 )

    When Windows 2000 server is installed for the first time, a DLL named “logscrpt.dll” is also installed and registered. This DLL contains the MSWC.IISLog class, which allows us to load, read, write and close IIS log files on our server. To create an instance of the MSWC.IISLog class in ASP, we use the “MSWC.IISLog” ProgId, like this:

    set objLog = Server.CreateObject("MSWC.IISLog")

    The MSWC.IISLog class contains several methods and properties that can be used to either retrieve log entries, or write log entries to a log file. These methods and properties are described below:

    Methods
    • AtEndOfLog: Indicates whether all records have been read from the log file.
    • CloseLogFiles: Closes all open log files.
    • OpenLogFile: Opens a log file for reading or writing.
    • ReadFilter: Filters records from the log file by date and time.
    • ReadLogRecord: Reads the next available log record from the current log file.
    • WriteLogRecord: Writes a log record to the current log file.
    Properties
    • BytesReceived: Indicates the number of bytes received.
    • BytesSent: Indicates the number of bytes sent.
    • ClientIP: Indicates the client’s host name.
    • Cookie: Indicates the client’s cookie.
    • CustomFields: Indicates an array of custom headers.
    • DateTime: Indicates the date and time, in GMT.
    • Method: Indicates the operation type.
    • ProtocolStatus: Indicates the protocol status.
    • ProtocolVersion: Indicates the version string.
    • Referer: Indicates the referrer page.
    • ServerIP: Indicates the server’s IP address.
    • ServerName: Indicates the server name.
    • ServerPort: Indicates the port number.
    • ServiceName: Indicates the service name.
    • TimeTaken: Indicates the total processing time.
    • URIQuery: Indicates any parameters passed with the request.
    • URIStem: Indicates the target URL.
    • UserAgent: Indicates the user agent string.
    • UserName: Indicates the user’s name.
    • Win32Status: Indicates the Win32 status code.
    We will use some of these methods and properties now, to create our log viewer script, viewlog.asp. This file is available for download as part of the support material for this article. It will contain two sub-routines: GetDetails and ShowLogEntries.

    The GetDetails sub-routine will be called automatically whenever the viewlog.asp file is loaded for the first time. Its declaration looks like this:

    Sub GetDetails()

    It will display a HTML form with one text box, two drop-down lists, and a submit button. The text box will be where the user enters the file name for the log file they wish to view. This file name should contain a physical path, such as “c:\winnt\system32\logfiles\w3svc1\ex012808.log”. The first drop-down list will allow the user to select which type of log file they are viewing. The second drop-down list will allow the user to choose how many records to view.

    The code for the GetDetails sub-routine is shown below:

    sub GetDetails()



    'This sub-routine will display a simple HTML form

    'into which the user will enter the location of

    'the log file that we will be viewing.

    %>

    <form name="frmGetFile" action="<%=Request.ServerVariables("SCRIPT_NAME")%>" method="post">

    <h1>Log File Details</h1>

    Please enter the name and full path to the log file

    that you would like to view:<br>

    <input type="text" name="txtLogFile">

    <br><br>

    What type of log file will you be viewing?<br>

    <select name="txtType">

    <option SELECTED>W3C Extended Log File Format</option>

    <option>NCSA Common Log File Format</option>

    <option>Microsoft IIS Log File Format</option>

    </select>

    <br><br>

    How many records do you want returned?<br>

    <select name="intRecs">

    <option>10</option>

    <option>20</option>

    <option>30</option>

    <option>40</option>

    <option>50</option>

    <option>100</option>

    <option>150</option>

    <option>200</option>

    <option>500</option>

    <option>1000</option>

    <option value="10000" SELECTED>ALL</option>

    </select>

    <br><br>

    <input type="submit" name="submitted" value="View Log">

    </form>

    <%



    end sub



    The HTML output from the GetDetails sub-routine looks like this:

    The output from the GetDetails sub-routine

    Once the user completes the details form and clicks on the “View Log” button, the ShowLogEntries sub-routine is called. I will describe this sub-routine on the next page.

    More ASP Articles
    More By


     

    ASP ARTICLES

    - Central Scoreboard with Flash and ASP
    - Calorie Counter Using WAP and ASP
    - Creating PGP-Encrypted E-Mails Using ASP
    - Be My Guest in ASP
    - Session Replacement in ASP
    - Securing ASP Data Access Credentials Using t...
    - The Not So Ordinary Address Book
    - Adding and Displaying Data Easily via ASP an...
    - Sending Email From a Form in ASP
    - Adding Member Services in ASP
    - Removing Unconfirmed Members
    - Trapping HTTP 500.100 - Internal Server Error
    - So Many Rows, So Little Time! - Case Study
    - XDO: An XML Engine Class for Classic ASP
    - Credit Card Fraud Prevention Using ASP and C...







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway