The SharePoint Logger
When you develop business-critical solutions, it is essential to ensure that you make diagnostic information about your application available to administrators and other developers.
Providing and consuming diagnostic information involves two distinct activities: logging and tracing. Logging is primarily directed toward system administrators, who typically rely on the Windows event logs to monitor deployed applications. They often use automated tools such as the System Center Operations Manager (SCOM) to monitor the event logs. Tracing, on the other hand, is primarily directed toward developers and field engineers. Trace logs record more detailed information about action taken and problems encountered during the execution of an application, and are typically used by people who are familiar with the implementation details of the application to monitor behavior and diagnose problems.
Like previous versions of SharePoint Products and Technologies, SharePoint 2010 uses both the Windows event logs and the SharePoint Unified Logging Service (ULS) trace log to record information and exceptions. Using the same approach in your own SharePoint applications offers many benefits. For example, logging your custom application traces to the ULS trace log allows you to view them in the larger context of Windows SharePoint Services operations without having to correlate multiple trace logs. However, implementing logging and tracing functionality can be complex and unwieldy.
To simplify these issues, the SharePoint Guidance Library includes a reusable component named the SharePoint Logger. You can use the SharePoint Logger in your own SharePoint applications to write to both the event log and the ULS trace log in a simple, consistent manner.
This section includes the following topics that will help you to understand and use the SharePoint Logger:
- What Does the SharePoint Logger Do? This topic provides a brief overview of the SharePoint Logger, the concepts behind it, and the features that it incorporates. It also provides a simple example of how you can programmatically interact with the SharePoint Logger.
- When Should I Use the SharePoint Logger? This topic can help you to decide whether the SharePoint Logger is suitable for your requirements. It identifies key scenarios in which the SharePoint Logger may be useful to you, and it explains the benefits and limitations of using the SharePoint Logger.
- Developing Applications Using the SharePoint Logger. This section describes how to approach the key development tasks that you will encounter when you use the SharePoint Logger, such as adding the right references to your solution, getting a logger instance, and writing to the event log or the trace log.
- Key Scenarios. This section provides some examples of the SharePoint Logger at work in the context of broader SharePoint operations.
- Design of the SharePoint Logger. This topic explains how the SharePoint Logger works in more detail, including the background and rationale behind the component.
- Developer How-to Topics. This section provides step-by-step, end-to-end procedural guidance on how to perform the most common developer tasks with the SharePoint Logger.