SPDiagnosticsService.Local 属性

获取一个对象,表示当前服务器场中运行的诊断程序服务的实例。

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

语法

声明
Public Shared ReadOnly Property Local As SPDiagnosticsService
    Get
用法
Dim value As SPDiagnosticsService

value = SPDiagnosticsService.Local
public static SPDiagnosticsService Local { get; }

属性值

类型:Microsoft.SharePoint.Administration.SPDiagnosticsService
SPDiagnosticsService 对象,该对象表示的服务实例。

备注

如果您的应用程序运行在一个服务器场中的前端 Web 服务器上,则此属性将返回SPDiagnosticsService类的一个实例。如果不存在该服务的实例,访问此属性时,在本地服务器上创建的实例,并更改传播到服务器场中的所有服务器。

如果您未连接到服务器场的前端 Web 服务器,则该属性会返回空引用(无 在 Visual Basic 中)。

示例

下面的示例演示一个控制台应用程序报告信息,您还可以在管理中心启用诊断日志记录页上的跟踪日志部分中找到。

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

Module ConsoleApp
   Sub Main()
      Dim diagSvc As SPDiagnosticsService = SPDiagnosticsService.Local
      If diagSvc Is Nothing Then
         Console.WriteLine("You are not connected to a front-end server.")
      Else
         Console.WriteLine("Trace log path: {0}", diagSvc.LogLocation)
         Console.WriteLine("Days to keep log files: {0}", diagSvc.DaysToKeepLogs)
         If diagSvc.LogMaxDiskSpaceUsageEnabled Then
            Console.WriteLine("Maximum amount of storage to use: {0}", diagSvc.LogDiskSpaceUsageGB)
         Else
            Console.WriteLine("Storage space is not restricted.")
      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 diagSvc = SPDiagnosticsService.Local;
            if (diagSvc == null)
            {
                Console.WriteLine("You are not connected to a front-end server.");
            }
            else
            {
                Console.WriteLine("Trace log path: {0}", diagSvc.LogLocation);
                Console.WriteLine("Days to keep log files: {0}", diagSvc.DaysToKeepLogs);
                if (diagSvc.LogMaxDiskSpaceUsageEnabled)
                    Console.WriteLine("Maximum amount of storage to use: {0}", diagSvc.LogDiskSpaceUsageGB);
                else
                    Console.WriteLine("Storage space is not restricted.");
            }
            Console.Write("\nPress ENTER to continue...");
            Console.ReadLine();
        }
    }
}

另请参阅

引用

SPDiagnosticsService 类

SPDiagnosticsService 成员

Microsoft.SharePoint.Administration 命名空间