SPDiagnosticsServiceBase.Areas property

Gets a collection of all areas in this SPDiagnosticsService object.

Namespace:  Microsoft.SharePoint.Administration
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

public SPDiagnosticsCollection<SPDiagnosticsArea> Areas { get; }

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();
        }
    }
}
Show: