One option would be to use Windows Management Instrumentation (WMI). I added a little extra to this script: a link to
eventid.net with parameters for the event ID and the source of the event (in order to provide more information about the error), as well as a search of Microsoft's Knowledge Base for articles that mention the error.
<% on error resume next set loc = CreateObject("WbemScripting.SWbemLocator") set nms = loc.ConnectServer() WQL = "SELECT " & _ "TimeGenerated," & _ "EventCode," & _ "SourceName," & _ "Message " & _ "FROM Win32_NTLogEvent " & _ "WHERE Logfile='Application'" Set eventLog = nms.ExecQuery(WQL,"WQL",48) if err.number <> 0 then Response.Write("Error reading log files.") else response.write "<table border=1>" For Each logEvent In EventLog eID = logevent.EventCode msg = logEvent.message src = logevent.sourcename cdt = customDateTime(LogEvent.TimeGenerated) response.write "<tr valign=top><td>" & cdt & _ "</td><td>ID: " & eID & "<br>Source: " & _ src & "<br><a target=_blank " & _ "href=http://www.eventid.net/display.asp?" & _ "eventid=" & eID & "&source=" & src & _ ">3rd party info</a> | <a target=_blank " & _ "href=" & buildKBSearch(eID) & "</td>" & _ "<td>" & msg & "</td></tr>" next response.write "</table>" end if function customDateTime(str) ' deal with ugly date/time format of WMI str = left(str,instr(str,".")-1): dt = left(str,8) dt = left(dt,4) & "-" & _ left(right(dt,4),2) & "-" & right(dt,2) tm = left(right(str,len(str)-8),4) tm = left(tm,2) & ":" & right(tm,2) customDateTime = dt & " " & formatdatetime(tm,3) end function function buildKBSearch(id) buildKBSearch = "http://support.microsoft.com/" & _ "search/default.aspx?Catalog=LCID%3D1033" & _ "%26CDID%3DEN-US-KB%26PRODLISTSRC%3DON&" & _ "withinResults=&QuerySource=gASr_Query&" & _ "Product=msall&Queryc=event+id+" & id & _ "&Query=event+id+" & id & "&KeywordType" & _ "=PHRASE&maxResults=150&Titles=false" end function %> |
Note that you need to run this in a folder where IUSR or an authenticated user (using windows auth) has sufficient rights to read the event log. For more details about this object, see the
Win32_NTLogEvent topic from the WMI SDK.
Another option would be to use a 3rd party component, such as
ASPEventViewer.
If you know of other tools or methods for extracting Event Log information into an ASP page,
don't be shy.