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

Please enter the name and full path to the log file that you would like to view:


What type of log file will you be viewing?


How many records do you want returned?


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

<% While (counter < logNumRecs) AND (not objLog.AtEndOfLog) %> <% clientIP = objLog.ClientIP dateTime = objLog.DateTime url = objLog.URIStem serverPort = objLog.ServerPort method = objLog.Method %> <% objLog.ReadLogRecord counter = counter + 1 wend response.write "
Client IP Date URL Port Method
<%=clientIP%> <%=dateTime%> <%=url%> <%=serverPort%> <%=method%>
" objLog.CloseLogFiles(32) set objlog = nothing end sub %>