ReadFilter

This method allows you to read log records between a date and time range.

Syntax

OIISLog.ReadFilter( [startDateTime], [endDateTime] )

 

Parameters
startDateTime
Optional parameter indicating date and time after which log records are to be read.
endDateTime
Optional parameter indicating date and time before which log records are to be read.

Important

Although the parameters are optional, at least one must be specified.

Example

The following example opens a log file in the W3C Extended Log File Format, and displays selective properties of the records in the specified date range.

--- Log_ReadFilter.asp ---

<HTML>
<HEAD><TITLE></TITLE></HEAD>
<BODY>

<%
LogFile = Request.Form("logfile")
StartDate = Request.Form("startdt")
EndDate = Request.Form("enddt")
%>

<H3>Display a Range of Log Records by Date</H3>

<FORM NAME="getlogfilename" METHOD="POST" ACTION="Log_ReadFilter.asp">
Please enter the full path name of a log file to read in %SystemRoot%\system32\LogFiles\*SVC*\*.log:<BR>
<input type="TEXT" NAME="logfile"  size=70 value=<%=LogFile%>><BR><BR>
Start DateTime:
<input type="TEXT" NAME="startdt" value=<%=StartDate%>> (Optional)<BR>
End DateTime: 
<input type="TEXT" NAME="enddt" value=<%=EndDate%>> (Optional)<BR>
(Use the format 'MM/DD/YYYY HH:MM:SS AM/PM')<BR><BR>
<INPUT TYPE="SUBMIT" VALUE="Submit">
</FORM>

<%
''''''''''''''''''''
'  Log file formats:
'  "NCSA Common Log File Format"
'  "Microsoft IIS Log File Format"
'  "W3C Extended Log File Format"
'''''''''''''''''''''

Set fsoObject = Server.CreateObject("Scripting.FileSystemObject")

If (fsoObject.FileExists(LogFile)) Then

  Set oRead = CreateObject ("MSWC.IISLog")
  oRead.OpenLogFile LogFile, 1, "W3SVC", 1, "W3C Extended Log File Format"

  If Not (StartDate = "" Or EndDate = "") Then
    oRead.ReadFilter StartDate,EndDate
  End If 

  oRead.ReadLogRecord
%>
<TABLE Border=1>
<TR><TD>
<B>Date/Time</TD><TD><B>Client IP</TD><TD><B>User Name</TD><TD><B>URL Requested
</B></TD></TR>
<%
  Do While Not oRead.AtEndOfLog
    Response.Write "<TR><TD>&nbsp;" & oRead.DateTime & "</TD>"
    Response.Write "<TD>&nbsp;" & oRead.ClientIP & "</TD>"
    Response.Write "<TD>&nbsp;" & oRead.UserName & "</TD>"
    Response.Write "<TD>&nbsp;" & oRead.URIStem & "</TD></TR>"
    oRead.ReadLogRecord
  Loop
%>
</TABLE>
<%
  oRead.CloseLogFiles 1

ElseIf Not (LogFile = "") Then

  Response.Write "ERROR: " & LogFile & " does not exist."

End If

%>

</BODY>
</HTML>

© 1997-2001 Microsoft Corporation. All rights reserved.