AspEventlog 2.0 Component - free
Last updated: 06/21/99, v2.0 (01/20/99 Initial Release)
You can log additional information to the site logs using Response.AppendToLog, however, sometimes it is important to see events reported to a more central log of Windows NT itself - the Application eventlog (like the Application_OnStart event in global.asa). You can use Event Viewer immediately to filter for events, without having to go to the log files and processing them.
The AspEventlog component can be used from any OLE Automation enviroment, including but not limited to ASP (though the name would imply that). It registers itself with the eventlog during the standard OLE registration process.
The component's interface is intended to be simple, but powerful if you want to have events reported to the Application eventlog of the local server (works with a standard installation, aka server runs under IUSR_machinename account). All four different event types (success, error, warning and information) can be logged, together with a single string of information (you are free to include anything in this string, like IP, user agent, etc). See the sample for how to do that.
The component ships with an Excel workbook that demonstrates many of the useful usage scenarios of the component (including remote logging and the creation of custom event sources). The reason why it is implemented as Excel example is that you can interactively test the code (much easier than in ASP). However, you can take the code and port it to ASP (ok, you can use it in any Automation environment).
Below is an example of such a port to ASP.
<% Option Explicit %> <!-- Christoph Wille, 20.1.99 --> <% Const EVENTLOG_SUCCESS = 0 Const EVENTLOG_ERROR_TYPE = 1 Const EVENTLOG_WARNING_TYPE = 2 Const EVENTLOG_INFORMATION_TYPE = 4 %> <% ' Create the AspEventlog object Dim xObj, bResult Set xObj = Server.CreateObject("SOFTWING.ASPEventlog") ' open the log and report the status bResult = xObj.Open() Response.Write "Open called with return value of: " & bResult _ & "<BR>" & vbCRLF ' write a information type event and give feedback bResult = xObj.ReportEvent(EVENTLOG_INFORMATION_TYPE, _ "This is a demo event from SOFTWING") Response.Write "Event was reported successfully: " & bResult _ & "<BR>" & vbCRLF ' close the log (would be done automatically on object destruction) bResult = xObj.Close() Response.Write "Log closed successfully: " & bResult & _ "<BR>" & vbCRLF ' delete the object and free up memory Set xObj = Nothing %>
Installation and Download
Before using the component you have to register it using the regsvr32 utility: regsvr32 AspEventlog.dll.
Download (size is approx. 77KB)
If you do have any questions, please feel free to send mail to Christoph Wille.
All content and images on this site are copyright. Reuse (even parts) needs our written consent.