Share via


SPDiagnosticsService.SetItem Method (IDiagnosticsLevel, TraceSeverity, EventSeverity)

NOTE: This API is now obsolete.

Sets the reporting thresholds for a category that is specified by an IDiagnosticsLevel object.

Namespace:  Microsoft.SharePoint.Administration
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No

Syntax

'Declaration
<ObsoleteAttribute("directly modify severities on SPDiagnosticsCategory")> _
Public Sub SetItem ( _
    item As IDiagnosticsLevel, _
    traceSeverity As TraceSeverity, _
    eventSeverity As EventSeverity _
)
'Usage
Dim instance As SPDiagnosticsService
Dim item As IDiagnosticsLevel
Dim traceSeverity As TraceSeverity
Dim eventSeverity As EventSeverity

instance.SetItem(item, traceSeverity, _
    eventSeverity)
[ObsoleteAttribute("directly modify severities on SPDiagnosticsCategory")]
public void SetItem(
    IDiagnosticsLevel item,
    TraceSeverity traceSeverity,
    EventSeverity eventSeverity
)

Parameters

Remarks

Use this method to control the threshold for capturing a single category of events in trace logs and in the Windows event log. As the severity level decreases, the number of events logged will increase.

Note

This method provides a programmatic means of accomplishing what you can do manually in the Event Throttling section on the Central Administration Diagnostics Logging page. In the user interface, select the category and then select severity levels.

Examples

The following example shows a console application that changes the reporting thresholds for the Unified Logging Service category.

Imports System
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.Administration

Module ConsoleApp

   Sub Main()

      Dim diagnostics As SPDiagnosticsService = SPDiagnosticsService.Local
      If Not diagnostics Is Nothing Then
         Dim category As IDiagnosticsLevel = diagnostics.GetItem("Unified Logging Service")
         If Not category Is Nothing Then
            diagnostics.SetItem(category, TraceSeverity.Verbose, EventSeverity.Error)
            diagnostics.Update()
         End If
      End If
   End Sub

End Module
using System;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;

namespace Test
{
   class ConsoleApp
   {
      static void Main(string[] args)
      {
         SPDiagnosticsService diagnostics = SPDiagnosticsService.Local;
         if (diagnostics != null)
         {
            IDiagnosticsLevel category = diagnostics.GetItem("Unified Logging Service");
            if (category != null)
            {
               diagnostics.SetItem(category, TraceSeverity.Verbose, EventSeverity.Error);
               diagnostics.Update();
            }
         }
      }
   }
}

See Also

Reference

SPDiagnosticsService Class

SPDiagnosticsService Members

SetItem Overload

Microsoft.SharePoint.Administration Namespace

GetItem(String)

ResetItem(IDiagnosticsLevel)