Chapter 43. Monitoring Your Applications
Very often developers need to review what actions are performed at runtime in some part of source code (this need is especially important in the case of complex applications). The simplest way to retrieve this information is by debugging an application step by step and using various features of the Visual Studio.NET IDE, such as watching, quick watching, command windows, local windows, and so on. But this approach provides developers only some information while debugging. Debugging enables you to track down finite pieces of information, single lines of trouble code, and so on.
Another important task is monitoring an application as it runs, and one approach is to write information in some storage (database, file, console, and so forth). In that case, the developer has a full overview of all actions (exceptions, warnings, critical situations, debugging information, and so on) that occurred during the application process execution. The common way of writing and storing auxiliary information during an application process execution is logging.
A logging facility lets an application write out information as it runs, and captures that information for later analysis. The information in the log can be very detailed or very sparse. Examining the log is a useful post-mortem tool, helping you pinpoint when and where a problem occurs for more detailed analysis. Logging facilities are especially handy when debuggers are not available or are too intrusive.
The simplest way to log information is by using Console.WriteLine() and Console.Write() statements. But this method is very crude and inflexible. The .NET Framework proposes its own mechanism of logging information: tracing, debugging statements and trace listeners.
WHAT YOU NEED
MONITORING YOUR APPLICATIONS AT A GLANCE