領域 <areas>

概要

<areas> コレクションは、プロバイダーがトレースする機能領域の一覧を指定します。

互換性

バージョン メモ
IIS 10.0 <areas> 要素は、IIS 10.0 では変更されませんでした。
IIS 8.5 <areas> 要素は、IIS 8.5 では変更されませんでした。
IIS 8.0 <areas> 要素は IIS 8.0 では変更されませんでした。
IIS 7.5 <areas> 要素は、IIS 7.5 では変更されませんでした。
IIS 7.0 <traceProviderDefinitions> コレクションの <areas> 要素は IIS 7.0 で導入されました。
IIS 6.0 該当なし

段取り

IIS 7 以降の既定のインストールが完了したら、失敗した要求トレースを使用するためにトレース役割サービスをインストールする必要があります。 役割サービスをインストールした後も、サイト レベル、アプリケーション レベル、またはディレクトリ レベルで失敗した要求トレースを有効にする必要があります。

Windows Server 2012 または Windows Server 2012 R2

  1. タスク バーで [サーバー マネージャー]をクリックします。
  2. [サーバー マネージャー] で、[管理] メニューを選択し、[役割と機能の追加] を選択します。
  3. [役割と機能の追加] ウィザードで、[次へ] をクリックします。 インストールの種類を選択し、[次へ] をクリックします。 対象サーバーを選び、[次へ] をクリックします。
  4. [サーバーの役割] ページで、[Web サーバー (IIS)][Web サーバー] の順に展開し、[正常性と診断] を展開して、[トレース] を選びます。 次へ をクリックします。
    [トレース] が強調表示された [Web サーバーと正常性と診断] ウィンドウの画像。 .
  5. [機能の選択] ページで、[次へ] をクリックします。
  6. [インストール オプションの確認] ページで、[インストール] をクリックします。
  7. [結果] ページで、 [閉じる]をクリックします。

Windows 8 または Windows 8.1

  1. [スタート] 画面で、ポインターを左下隅まで移動し、[スタート] ボタンを右クリックし、[コントロール パネル] をクリックします。
  2. [コントロール パネル][プログラムと機能] をクリックし、次に [Windows の機能の有効化または無効化] をクリックします。
  3. [インターネット インフォメーション サービス] を展開し、[World Wide Web サービス] を展開し、[正常性と診断] を展開して、[トレース] を選びます。
    [トレース] が選択された状態で展開された [World Wide Web サービスと正常性と診断] ウィンドウの画像。 -- [OK] をクリックします。
  4. [閉じる] をクリックします。

Windows Server 2008 または Windows Server 2008 R2

  1. タスク バーで [スタート] をクリックし、[管理ツール] をポイントして、[サーバー マネージャ] をクリックします。
  2. [サーバー マネージャ] 階層ウィンドウで [役割] を展開し、[Web サーバー (IIS)] をクリックします。
  3. [Web サーバー (IIS)] ペインで、[役割サービス] セクションまでスクロールし、[役割サービスの追加] をクリックします。
  4. 役割サービスの追加ウィザード[役割サービスの選択] ページで、[トレース] を選び、[次へ] をクリックします。
    [正常性と診断] ウィンドウが展開され、[トレース] が選択されている役割サービスの追加ウィザードの [役割サービスの選択] ページのスクリーンショット。
  5. [インストール オプションの確認] ページで、[インストール] をクリックします。
  6. [結果] ページで、 [閉じる]をクリックします。

Windows Vista または Windows 7

  1. タスク バーで、[スタート][コントロール パネル] の順にクリックします。
  2. [コントロール パネル][プログラムと機能] をクリックし、次に [Windows の機能の有効化または無効化] をクリックします。
  3. [インターネット インフォメーション サービス][World Wide Web サービス][正常性と診断] の順に展開します。
  4. [トレース] を選んで [OK] をクリックします。
    [トレース] が強調表示された [World Wide Web Services] ウィンドウの画像。

操作方法

IIS 7 のトレース プロバイダーを追加するためのユーザー インターフェイスはありません。 トレース プロバイダーをプログラムで追加する方法の例については、このドキュメントの「コード サンプル」セクションを参照してください。

構成

属性

なし

子要素

要素 説明
add 省略可能な要素です。

トレースする機能領域のコレクションに機能領域を追加します。
clear 省略可能な要素です。

機能領域へのすべての参照を、トレース コレクションの機能領域から削除します。
remove 省略可能な要素です。

トレース コレクションの機能領域から機能領域への参照を削除します。

構成サンプル

次の既定の <traceProviderDefinitions> 要素は、IIS 7.0 のルート ApplicationHost.config ファイルで構成されます。

<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>

サンプル コード

次の例では、グローバル <traceProviderDefinitions> コレクションで定義されている一覧に、2 つのトレース領域を持つカスタム トレース プロバイダーを追加します。

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

AppCmd.exe を使用してこれらの設定を構成するときは、commit パラメーターを必ず apphost に設定する必要があります。 これで、ApplicationHost.config ファイルの適切な場所セクションに構成設定がコミットされます。

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()