Trace Log Categories
Published: May 2010
Microsoft SharePoint Foundation 2010 provides two ways of creating custom categories for ULS log entries.
The first is by using the SPDiagnosticsServiceBase to create a Diagnostics Service which will make the customized categories viewable in the administrative UI. Using the Diagnostic Services model will allow a developer to reference an external assembly containing localized message strings.
SharePoint Foundation also provides an interface through which developers can expose SharePoint Foundation to the categories to assign to trace log messages. SharePoint Foundation looks for services on the server farm that implement this interface. If a service implements the interface, SharePoint Foundation queries the service for the categories defined for the service, and displays those categories in the Central Administration user interface. Administrators can then use the Central Administration user interface to manage and update those categories.
This new API for SharePoint Foundation 2010 enables a developer to create their own log categories. It also allows localization of message strings by using custom resource files (.resx).
For more information on creating custom diagnostics services, see Creating a Custom Diagnostics Service
To expose an application's trace log categories to SharePoint Foundation, that service must implement the IDiagnosticsManager interface. This interface represents the trace log category collection, and includes methods for retrieving, updating, and resetting individual trace log categories.
Each trace log category is represented by an IDiagnosticsLevel class. This class includes methods that return the ID and name of the category, as well as whether the category is hidden. It also includes methods that enable you to set the event and trace severity of the trace log category.