Chapter 18
Tracing and Events
Chapter 14 covered errors and exception handling. Besides handling exceptional code, it might be really interesting to get some live information about your running application to find the reason for some issues that application might have during production, or to monitor resources needed to early adapt to higher user loads. This is where the namespace System.Diagnostics comes into play.
The application doesn’t throw exceptions, but sometimes it doesn’t behave as expected. The application might be running well on most systems but might have a problem on a few. On the live system, you change the log behavior by changing a configuration value and get detailed live information about what’s going on in the application. This can be done with tracing.
If there are problems with applications, the system administrator needs to be informed. With the Event Viewer, the system administrator both interactively monitors problems with applications and gets informed about specific events that happen by adding subscriptions. The event-logging mechanism allows you to write information about the application.
To analyze resources needed from applications, monitor applications with specified time intervals, and plan for a different application distribution or extending of system resources, the system administrator uses the performance monitor. You can write live data of your application using performance counts.
This chapter explains these three facilities and demonstrates ...