%@ 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("logSelect"), Request.Form("txtDate"), Request.Form("txtLogFile"), Request.Form("txtType"), Request.Form("intRecs"), Request.Form("showParams"), Request.Form("txtMth"), Request.Form("txtIP")
end if
%>
<%
sub ShowLogEntries(logSel, txtDate, LogDir, logType, intRecs, showParams, txtMth, txtIP)
on error resume next
dim objLog
dim clientIP
dim dateTime
dim url
dim serverPort
dim method
dim uri
dim counter
dim lognumrecs
dim xlog
dim logfile
logfile = LogDir & "\" & logSel & "\ex" & txtDate & ".log"
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 |
<%
if showParams="ON" then
%>
Params |
<%
End If
%>
<%
Dim MyPos, MyPos1
Do While (counter < logNumRecs) AND (not objLog.AtEndOfLog)
clientIP = objLog.ClientIP
dateTime = objLog.DateTime
url = objLog.URIStem
serverPort = objLog.ServerPort
method = objLog.Method
uri = objLog.URIQuery
MyPos = InStr (1, method, txtMth)
MyPos1 = InStr (1, clientIP, txtIP)
'Exit Do
if (txtMth = "ALL" OR MyPos <> Null OR MyPos >= 1) AND (txtIP = "" OR MyPos1 <> NULL OR MyPos1 >= 1) then
%>
<%=clientIP%> |
<%=dateTime%> |
<%=url%> |
<%=serverPort%> |
<%=method%> |
<%
if showParams="ON" then
%>
<%=uri%> |
<%
End If
%>
<%
counter = counter + 1
End If
objLog.ReadLogRecord
Loop
response.write "
"
objLog.CloseLogFiles(32)
set objlog = nothing
end sub
%>