(String) del método SPDiagnosticsService.GetItem
NOTA: esta API está ahora obsoleta.
Devuelve un objeto IDiagnosticsLevel que representa una categoría de informes con un nombre especificado.
Espacio de nombres: Microsoft.SharePoint.Administration
Ensamblado: Microsoft.SharePoint (en Microsoft.SharePoint.dll)
Sintaxis
'Declaración
<ObsoleteAttribute("Use SPDiagnosticsServiceBase.Categories")> _
Public Function GetItem ( _
name As String _
) As IDiagnosticsLevel
'Uso
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
)
Parámetros
name
Tipo: System.StringUn objeto String que contiene el nombre de una categoría de informes.
Valor devuelto
Tipo: Microsoft.SharePoint.Administration.IDiagnosticsLevel
Un objeto IDiagnosticsLevel que representa una categoría informes. Si una categoría con el nombre proporcionado no está registrada en la granja de servidores, el método devuelve una referencia null (Nothing en Visual Basic).
Implementaciones
IDiagnosticsManager.GetItem(String)
Comentarios
La cadena que se pasa como un argumento puede ser un nombre de categoría adaptada (el valor de la propiedad IDiagnosticsLevel.Name ) o un nombre de categoría no traducida (el valor de la propiedad IDiagnosticsLevel.Id ). Con el nombre sin adaptar hace que el código portable en configuraciones regionales.
Ejemplos
El ejemplo siguiente muestra una aplicación de consola que imprime información acerca de la categoría de tiempo de ejecución en la consola.
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();
}
}
}