O'Reilly logo

Design – Build – Run: Applied Practices and Principles for Production-Ready Software Development by Dave Ingram

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

20.2. Events and Event Logs

Events are probably the most important part of monitoring the application. They provide valuable information to the operations and support teams regarding the application's internal state, especially under abnormal conditions. Although performance counters offer processing performance and other internal state-related information, events can contain far more information than simple values that can be sampled.

Windows-based applications can raise events using the EventLog class. An event can be of type Information, Warning, Error, Success Audit, or Failure Audit. The events raised by the application are stored in a specific "event log." An event log is a special type of log file and is not to be confused with debug or trace logs. Applications use the Debug and Trace classes to output information that helps to trace program execution and assist in debugging activities. The events raised by the application should indicate information that is useful from an operational point of view, not "spam" the event log with unnecessary information. The following simplified pseudo code shows a hypothetical example of a program flow using both event logging and tracing:

Trace.WriteLine "Process Started" // trace execution Trace.WriteLine "Checking AccountState 'AccountState' for Account 'thisAccount'" if( thisAccount.AccountState == AccountStates.New ) { try { // process account . . . Trace.WriteLine "Account 'AccountId' Processed Successfully" } catch( Exception e ) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required