Providing Application Diagnostics

Developers and architects should have a strategy for monitoring their applications, recording any problems, and providing enough information to help diagnose those problems. Including logic in an application that exposes its state, both while it is under development and after it is released, is referred to as instrumentation. Microsoft Windows provides several mechanisms for instrumentation, including event logs, trace files, Windows Management Instrumentation (WMI), and performance counters.

Logging and tracing provide many advantages. For example, you can anticipate potential system failures by detecting approaching boundary limits such as a database that is becoming full. If an application does fail, well-planned, informative error messages can reduce the time needed to restore operations.

This guidance provides several examples of instrumentation, including exception management, event logging, and tracing. Logging and tracing are packaged into a reusable component that is part of the SharePoint Guidance Library. This means that you can incorporate these capabilities into your own application. For more information, see The SharePoint Logger.

Performance counters and WMI are more advanced techniques for representing run-time state. They were omitted from this guidance to reduce the complexity of the reference implementation. After you understand how the Partner Portal application uses exception handling, tracing, and logging, you can consider adding these other forms of instrumentation. The basics of instrumenting a SharePoint application are similar to the techniques that are used with other Microsoft .NET Framework applications. For an overview of instrumentation, see Tracing and Instrumenting Applications on MSDN.

The code that implements logging and the code that implements tracing often use the same infrastructure. However, event logs have a different audience and intent than trace logs. Tracing helps developers detect and analyze problems when they cannot easily access some aspect of an application and debug it directly. Logging helps information technology (IT) professionals detect, troubleshoot, and resolve problems in deployed applications.

Home page on MSDN | Community site