共用方式為


SPDiagnosticsServiceBase.Areas Property

Gets a collection of all areas in this SPDiagnosticsService object.

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

Syntax

'Declaration
Public ReadOnly Property Areas As SPDiagnosticsCollection(Of SPDiagnosticsArea)
    Get
'Usage
Dim instance As SPDiagnosticsServiceBase
Dim value As SPDiagnosticsCollection(Of SPDiagnosticsArea)

value = instance.Areas
public SPDiagnosticsCollection<SPDiagnosticsArea> Areas { get; }

Property Value

Type: Microsoft.SharePoint.Administration.SPDiagnosticsCollection<SPDiagnosticsArea>
A collection of areas.

Examples

The following example is a simple console application that enumerates the diagnostics areas that are registered with the diagnostics service on the local farm, and also enumerates the diagnostics categories for each area.

using System;
using Microsoft.SharePoint.Administration;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            SPDiagnosticsService diagnosticsService = SPDiagnosticsService.Local;
            foreach (SPDiagnosticsArea area in diagnosticsService.Areas)
            {
                Console.WriteLine("\nArea: {0}", area.Name);

                foreach (SPDiagnosticsCategory category in area.Categories)
                {
                    Console.WriteLine("Category: {0}", category.Name);
                }
            }
            Console.Write("\nPress ENTER to continue...");
            Console.ReadLine();
        }
    }
}

See Also

Reference

SPDiagnosticsServiceBase Class

SPDiagnosticsServiceBase Members

Microsoft.SharePoint.Administration Namespace