Logging to Event Log

Arkance Systems Benelux

This logging method enables logging unhandled application exceptions to a system event log. Applications and operating system components commonly make use of this centralized log service to report events that have taken place, such as a failure to start a component or complete an action. The system tool for inspecting and managing the event log is called Event Viewer.


Event Viewer dialog on Windows XP


When double-clicking on each event log record, the Event Properties dialog will show up. Event Properties dialog contains low-level description of the recorded event, including complete unhandled exception stack trace printout. You can click on a Copy button to copy event contents to clipboard:


Event Properties dialog on Windows XP


Logging to event log under Application section depends on EventLog variable setting:


[Debug]

EventLog=1


If EventLog variable is set to 1, unhandled errors will get logged to event log. If EventLog variable is set to 0, unhandled errors will not get logged to event log.


Depending on your system security settings, you may need elevated (i.e. Administrator) privileges to be able to either read or write event logs. It is mostly intended for console-based  server applications running on elevated application threads. In case application thread doesn't have enough privileges to access event log, it will simply skip logging to it.