%@ LANGUAGE="VBScript" %>
<%
Option Explicit
Response.Buffer = True
%>
IIS Log Viewer
<% 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.
%>
<%end sub
if Request.Form("submitted") = "" then
GetDetails
else
ShowLogEntries Request.Form("txtLogFile"), Request.Form("txtType"), Request.Form("intRecs")
end if
%>
<%
sub ShowLogEntries(LogFile, logType, intRecs)
on error resume next
dim objLog
dim clientIP
dim dateTime
dim url
dim serverPort
dim method
dim counter
dim lognumrecs
dim xlog
xlog = logfile
const ForReading = 1
const ForWriting = 2
counter = 0
logNumRecs = CInt(intRecs)
set objLog = Server.CreateObject("MSWC.IISLog")
objLog.OpenLogFile logFile, 1, "W3SVC", 1, logType
if hex(err.number) = 80070002 OR logFile = "" OR Right(logFile, 4) <> ".log" then
Response.Write "File doesn't exist
"
else
objLog.ReadLogRecord
End If
%>
<%
response.write xlog
%>
Client IP |
Date |
URL |
Port |
Method |
<%
While (counter < logNumRecs) AND (not objLog.AtEndOfLog)
%>
<%
clientIP = objLog.ClientIP
dateTime = objLog.DateTime
url = objLog.URIStem
serverPort = objLog.ServerPort
method = objLog.Method
%>
<%=clientIP%> |
<%=dateTime%> |
<%=url%> |
<%=serverPort%> |
<%=method%> |
<%
objLog.ReadLogRecord
counter = counter + 1
wend
response.write "
"
objLog.CloseLogFiles(32)
set objlog = nothing
end sub
%>