<%@ 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. %>

Log File Details

Which set of logs do you want to use?

Enter the date you would like to view ("yymmdd"):

Please enter the path to the log files that you would like to view:


What type of log file will you be viewing?


How many records do you want returned?


Which methods would you like to see?


Only include IP's with


Show Parameters

<%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 %>

<% if showParams="ON" then %> <% 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 %> <% if showParams="ON" then %> <% End If %> <% counter = counter + 1 End If objLog.ReadLogRecord Loop response.write "
Client IP Date URL Port Method Params
<%=clientIP%> <%=dateTime%> <%=url%> <%=serverPort%> <%=method%><%=uri%>
" objLog.CloseLogFiles(32) set objlog = nothing end sub %>