SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In CA, Diagnostic Logging, a lot of areas with their categories are listed. When I enumerate these area's in code only three are returned:

  • Business Connectivity Services
  • SharePoint Foundation SharePoint
  • Foundation Search

This is the code I use:

SPDiagnosticsCollection<SPDiagnosticsArea> allAreas = SPDiagnosticsService.Local.Areas;
foreach (SPDiagnosticsArea item in allAreas)
    message.Text += "- Area: " + item.Name + "<br />";

Where are the other areas like Access Service, SharePoint Server, Web Content Management and many others?

share|improve this question
up vote 4 down vote accepted

The problem is you are retrieving only SPDiagnosticsService which is provided by SharePoint Foundation out of the box. Keep in mind that these Sharepoint server provides its own Diagnostic service and being extensible other third part components can register their own diagnostic services in Sharepoint farm.

The right way to get all areas is to loop through all services which are derived from SPDiagnosticsServiceBase and then loop through areas as shown below as an example:

SPServiceCollection services = SPFarm.Local.Services;
            var diagServices = from service in services
                               where service is SPDiagnosticsServiceBase
                                   select service;

            foreach (SPDiagnosticsServiceBase service in diagServices)
                Console.WriteLine("Areas of Diagnostic Service: " + service.TypeName);
                SPDiagnosticsCollection<SPDiagnosticsArea> allAreas = service.Areas;
                foreach (SPDiagnosticsArea item in allAreas)
                    Console.WriteLine("Area: " + item.Name);
share|improve this answer
Thanks! This is exactly what I'm looking for! – Anita Boerboom Jun 27 '11 at 7:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.