SPDiagnosticsService.GetItem 方法 (String)

请注意:此 API 现在已过时。

返回一个IDiagnosticsLevel对象,该对象表示具有指定名称的报告类别。

命名空间:  Microsoft.SharePoint.Administration
程序集:  Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)

语法

声明
<ObsoleteAttribute("Use SPDiagnosticsServiceBase.Categories")> _
Public Function GetItem ( _
    name As String _
) As IDiagnosticsLevel
用法
Dim instance As SPDiagnosticsService
Dim name As String
Dim returnValue As IDiagnosticsLevel

returnValue = instance.GetItem(name)
[ObsoleteAttribute("Use SPDiagnosticsServiceBase.Categories")]
public IDiagnosticsLevel GetItem(
    string name
)

参数

返回值

类型:Microsoft.SharePoint.Administration.IDiagnosticsLevel
IDiagnosticsLevel 对象,该对象表示一个报告类别。如果在服务器场中未注册使用提供的名称的类别,则该方法会返回空引用(无 在 Visual Basic 中)。

实现

IDiagnosticsManager.GetItem(String)

备注

作为参数传递的字符串可以本地化的类别名称 ( IDiagnosticsLevel.Name属性的值) 或非本地化的类别名称 ( IDiagnosticsLevel.Id属性的值)。使用的非本地化名称使您的代码可移植跨区域设置。

示例

下面的示例显示的控制台应用程序打印到控制台运行时类别的信息。

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

Module ConsoleApp

   Sub Main()

      Dim diagnostics As SPDiagnosticsService = SPDiagnosticsService.Local
      If diagnostics Is Nothing Then
         Console.WriteLine("You are not connected to a front-end server.")
      Else
         Dim level As IDiagnosticsLevel = diagnostics.GetItem("Runtime")
         If Not level Is Nothing Then
            Console.WriteLine("Category name (localized): {0}", level.Name)
            Console.WriteLine("Category name (not localized): {0}", level.Id)
            Console.WriteLine("Least critical event to report to the event log: {0}", _
                              level.EventSeverity.ToString())
            Console.WriteLine("Least critical event to report to the trace log: {0}", _
                               level.TraceSeverity.ToString())
         End If
      End If

      Console.Write(vbCrLf + "Press ENTER to continue...")
      Console.ReadLine()
   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)
         {
            Console.WriteLine("You are not connected to a front-end server.");
         }
         else
         {
            IDiagnosticsLevel level = diagnostics.GetItem("Runtime");
            if (level != null)
            {
               Console.WriteLine("Category name (localized): {0}", level.Name);
               Console.WriteLine("Category name (not localized): {0}", level.Id);
               Console.WriteLine("Least critical event to report to the event log: {0}", 
                                 level.EventSeverity.ToString());
               Console.WriteLine("Least critical event to report to the trace log: {0}", 
                                 level.TraceSeverity.ToString());
            }
         }
         Console.Write("\nPress ENTER to continue...");
         Console.ReadLine();
      }
   }
}

另请参阅

引用

SPDiagnosticsService 类

SPDiagnosticsService 成员

GetItem 重载

Microsoft.SharePoint.Administration 命名空间