Areas <areas>

Overview

The <areas> collection specifies a list of functional areas for a provider to trace.

Compatibility

Version Notes
IIS 8.5 The <areas> element was not modified in IIS 8.5.
IIS 8.0 The <areas> element was not modified in IIS 8.0.
IIS 7.5 The <areas> element was not modified in IIS 7.5.
IIS 7.0 The <areas> element of the <traceProviderDefinitions> collection was introduced in IIS 7.0.
IIS 6.0 N/A

Setup

After you finish the default installation of IIS 7 and later, you must install the tracing role service to use failed request tracing. After you install the role service, you still must enable failed request tracing at the site level, application level, or directory level.

Windows Server 2012 or Windows Server 2012 R2

  1. On the taskbar, click Server Manager.
  2. In Server Manager, click the Manage menu, and then click Add Roles and Features.
  3. In the Add Roles and Features wizard, click Next. Select the installation type and click Next. Select the destination server and click Next.
  4. On the Server Roles page, expand Web Server (IIS), expand Web Server, expand Health and Diagnostics, and then select Tracing. Click Next.
    .
  5. On the Select features page, click Next.
  6. On the Confirm installation selections page, click Install.
  7. On the Results page, click Close.

Windows 8 or Windows 8.1

  1. On the Start screen, move the pointer all the way to the lower left corner, right-click the Start button, and then click Control Panel.
  2. In Control Panel, click Programs and Features, and then click Turn Windows features on or off.
  3. Expand Internet Information Services, expand World Wide Web Services, expand Health and Diagnostics, and then select Tracing.
  4. Click OK.
  5. Click Close.

Windows Server 2008 or Windows Server 2008 R2

  1. On the taskbar, click Start, point to Administrative Tools, and then click Server Manager.
  2. In the Server Manager hierarchy pane, expand Roles, and then click Web Server (IIS).
  3. In the Web Server (IIS) pane, scroll to the Role Services section, and then click Add Role Services.
  4. On the Select Role Services page of the Add Role Services Wizard, select Tracing, and then click Next.

  5. On the Confirm Installation Selections page, click Install.
  6. On the Results page, click Close.

Windows Vista or Windows 7

  1. On the taskbar, click Start, and then click Control Panel.
  2. In Control Panel, click Programs and Features, and then click Turn Windows Features on or off.
  3. Expand Internet Information Services, then World Wide Web Services, then Health and Diagnostics.
  4. Select Tracing, and then click OK.

How To

There is no user interface for adding trace providers for IIS 7. For examples of how to add trace providers programmatically, see the Code Samples section of this document.

Configuration

Attributes

None

Child Elements

Element Description
add Optional element.

Adds a functional area to the collection of functional areas to trace.
clear Optional element.

Removes all references to functional areas from the functional areas to trace collection.
remove Optional element.

Removes a reference to a functional area from the functional areas to trace collection.

Configuration Sample

The following default <traceProviderDefinitions> element is configured in the root ApplicationHost.config file in IIS 7.0.

<traceProviderDefinitions>
   <add name="WWW Server" guid="{3a2a4e84-4c21-4981-ae10-3fda0d9b0f83}">
      <areas>
         <clear />
         <add name="Authentication" value="2" />
         <add name="Security" value="4" />
         <add name="Filter" value="8" />
         <add name="StaticFile" value="16" />
         <add name="CGI" value="32" />
         <add name="Compression" value="64" />
         <add name="Cache" value="128" />
         <add name="RequestNotifications" value="256" />
         <add name="Module" value="512" />
      </areas>
   </add>
   <add name="ASP" guid="{06b94d9a-b15e-456e-a4ef-37c984a2cb4b}">
      <areas>
         <clear />
      </areas>
   </add>
   <add name="ISAPI Extension" guid="{a1c2040e-8840-4c31-ba11-9871031a19ea}">
      <areas>
         <clear />
      </areas>
   </add>
   <add name="ASPNET" guid="{AFF081FE-0247-4275-9C4E-021F3DC1DA35}">
      <areas>
         <add name="Infrastructure" value="1" />
         <add name="Module" value="2" />
         <add name="Page" value="4" />
         <add name="AppServices" value="8" />
      </areas>
   </add>
</traceProviderDefinitions>

Sample Code

The following examples add a custom trace provider with two trace areas to the list that is defined in the global <traceProviderDefinitions> collection.

AppCmd.exe

appcmd.exe set config -section:system.webServer/tracing/traceProviderDefinitions /+"[name='MyTraceProvider',guid='{00000000-0000-0000-0000-00000000000}']" /commit:apphost

appcmd.exe set config -section:system.webServer/tracing/traceProviderDefinitions /+"[guid='{00000000-0000-0000-0000-00000000000}'].areas.[name='ProviderAreaOne',value='0']" /commit:apphost

appcmd.exe set config -section:system.webServer/tracing/traceProviderDefinitions /+"[guid='{00000000-0000-0000-0000-00000000000}'].areas.[name='ProviderAreaTwo',value='1']" /commit:apphost

Note: You must be sure to set the commit parameter to apphost when you use AppCmd.exe to configure these settings. This commits the configuration settings to the appropriate location section in the ApplicationHost.config file.

C#

using System;
using System.Text;
using Microsoft.Web.Administration;

internal static class Sample
{
   private static void Main()
   {
      using (ServerManager serverManager = new ServerManager())
      {
         Configuration config = serverManager.GetApplicationHostConfiguration();
         ConfigurationSection traceProviderDefinitionsSection = config.GetSection("system.webServer/tracing/traceProviderDefinitions");
         ConfigurationElementCollection traceProviderDefinitionsCollection = traceProviderDefinitionsSection.GetCollection();

         ConfigurationElement addElement = traceProviderDefinitionsCollection.CreateElement("add");
         addElement["name"] = @"MyTraceProvider";
         addElement["guid"] = @"{00000000-0000-0000-0000-00000000000}";
         ConfigurationElementCollection areasCollection = addElement.GetCollection("areas");

         ConfigurationElement addElement1 = areasCollection.CreateElement("add");
         addElement1["name"] = @"ProviderAreaOne";
         addElement1["value"] = 0;
         areasCollection.Add(addElement1);

         ConfigurationElement addElement2 = areasCollection.CreateElement("add");
         addElement2["name"] = @"ProviderAreaTwo";
         addElement2["value"] = 1;
         areasCollection.Add(addElement2);

         traceProviderDefinitionsCollection.Add(addElement);
         serverManager.CommitChanges();
      }
   }
}

VB.NET

Imports System
Imports System.Text
Imports Microsoft.Web.Administration

Module Sample
   Sub Main()
      Dim serverManager As ServerManager = New ServerManager
      Dim config As Configuration = serverManager.GetApplicationHostConfiguration
      Dim traceProviderDefinitionsSection As ConfigurationSection = config.GetSection("system.webServer/tracing/traceProviderDefinitions")
      Dim traceProviderDefinitionsCollection As ConfigurationElementCollection = traceProviderDefinitionsSection.GetCollection

      Dim addElement As ConfigurationElement = traceProviderDefinitionsCollection.CreateElement("add")
      addElement("name") = "MyTraceProvider"
      addElement("guid") = "{00000000-0000-0000-0000-00000000000}"
      Dim areasCollection As ConfigurationElementCollection = addElement.GetCollection("areas")

      Dim addElement1 As ConfigurationElement = areasCollection.CreateElement("add")
      addElement1("name") = "ProviderAreaOne"
      addElement1("value") = 0
      areasCollection.Add(addElement1)

      Dim addElement2 As ConfigurationElement = areasCollection.CreateElement("add")
      addElement2("name") = "ProviderAreaTwo"
      addElement2("value") = 1
      areasCollection.Add(addElement2)

      traceProviderDefinitionsCollection.Add(addElement)
      serverManager.CommitChanges()
   End Sub
End Module

JavaScript

var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";
var traceProviderDefinitionsSection = adminManager.GetAdminSection("system.webServer/tracing/traceProviderDefinitions", "MACHINE/WEBROOT/APPHOST");
var traceProviderDefinitionsCollection = traceProviderDefinitionsSection.Collection;

var addElement = traceProviderDefinitionsCollection.CreateNewElement("add");
addElement.Properties.Item("name").Value = "MyTraceProvider";
addElement.Properties.Item("guid").Value = "{00000000-0000-0000-0000-00000000000}";
var areasCollection = addElement.ChildElements.Item("areas").Collection;

var addElement1 = areasCollection.CreateNewElement("add");
addElement1.Properties.Item("name").Value = "ProviderAreaOne";
addElement1.Properties.Item("value").Value = 0;
areasCollection.AddElement(addElement1);

var addElement2 = areasCollection.CreateNewElement("add");
addElement2.Properties.Item("name").Value = "ProviderAreaTwo";
addElement2.Properties.Item("value").Value = 1;
areasCollection.AddElement(addElement2);

traceProviderDefinitionsCollection.AddElement(addElement);
adminManager.CommitChanges();

VBScript

Set adminManager = createObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set traceProviderDefinitionsSection = adminManager.GetAdminSection("system.webServer/tracing/traceProviderDefinitions", "MACHINE/WEBROOT/APPHOST")
Set traceProviderDefinitionsCollection = traceProviderDefinitionsSection.Collection

Set addElement = traceProviderDefinitionsCollection.CreateNewElement("add")
addElement.Properties.Item("name").Value = "MyTraceProvider"
addElement.Properties.Item("guid").Value = "{00000000-0000-0000-0000-00000000000}"
Set areasCollection = addElement.ChildElements.Item("areas").Collection

Set addElement1 = areasCollection.CreateNewElement("add")
addElement1.Properties.Item("name").Value = "ProviderAreaOne"
addElement1.Properties.Item("value").Value = 0
areasCollection.AddElement addElement1

Set addElement2 = areasCollection.CreateNewElement("add")
addElement2.Properties.Item("name").Value = "ProviderAreaTwo"
addElement2.Properties.Item("value").Value = 1
areasCollection.AddElement addElement2

traceProviderDefinitionsCollection.AddElement addElement
adminManager.CommitChanges()
Deprecated Elements