This class enables you to do programmatically what you can do manually through the user interface in the Trace Log and Event Throttling sections on the Central Administration Diagnostics Logging page.
Trace logs receive informative messages about the execution of an application that has been instrumented for tracing. Application tracing is often used to measure product performance and to diagnose errors. However, logs do grow over time, and they must be managed carefully to keep them from consuming too much disk space. To manage the location, size, and number of trace logs programmatically throughout the server farm, start by getting an instance of the SPDiagnosticsService class from the static Local property. Then set the object's LogLocation, LogCutInterval, and LogsToKeep properties. Finally, propagate the new configuration throughout the server farm by calling the Update method.
Event throttling is a term that refers to controlling the rate at which events are captured in the Windows event log and in trace logs. Events are managed by categories, and separate reporting thresholds are maintained for each type of log. To set thresholds for a particular category, you must first get an instance of the SPDiagnosticsService class by accessing the static Local property. Then call the SetItem method, passing an instance of a class that implements the IDiagnosticsLevel interface to identify the category, a TraceSeverity value for the trace log threshold, and an EventSeverity value for the event log threshold. Alternatively, you can set thresholds for all categories at the same time by calling the SetAll method.