領域 <areas>
- 概要
- 互換性
- セットアップ
- 方法
- 構成
- サンプル コード
※本ページに挿入されている画像をクリックすると、画像全体が別ウィンドウで表示されます。
概要
<areas>
コレクションでは、プロバイダーがトレースする機能領域の一覧が指定されます。
互換性
IIS 7.0 | IIS 6.0 | |
---|---|---|
注意 | <traceProviderDefinitions> コレクションの <areas> は IIS 7.0 で新たに導入された要素です。 |
なし |
セットアップ
IIS 7.0 の既定のインストールが終了したら、失敗した要求トレースを使用するために、追跡の役割サービスをインストールする必要があります。また、当該役割サービスをインストールした後には、失敗した要求トレースをサイト レベル、アプリケーション レベル、またはディレクトリ レベルで有効にする必要があります。
Windows Server 2008
タスク バーで [スタート] ボタンをクリックし、[管理ツール] をポイントして [サーバー マネージャー] をクリックします。
[サーバー マネージャー] ウィンドウのツリー表示で、[役割] を展開して [Web サーバー (IIS)] をクリックします。
[Web サーバー (IIS)] ウィンドウで、[役割サービス] セクションまでスクロールして [役割サービスの追加] をクリックします。
役割サービスの追加ウィザードの [役割サービスの選択] ページで、[追跡] を選択して、[次へ] をクリックします。
[インストール オプションの確認] ページで [インストール] をクリックします。
[結果] ページで [閉じる] をクリックします。
Windows Vista
タスク バーで [スタート] ボタンをクリックし、[コントロール パネル] をクリックします。
コントロール パネルで、[プログラムと機能]、[Windows の機能の有効化または無効化] の順にクリックします。
[Internet Information Services]、[World Wide Web サービス]、[健常性と診断] の順に展開します。
[追跡] を選択して、[OK] をクリックします。
方法
IIS 7.0 でトレース プロバイダーを追加するためのユーザー インターフェイスはありません。トレース プロバイダーをプログラムによって追加する方法の例については、このドキュメントの「サンプル コード」セクションを参照してください。
構成
属性
なし
子要素
要素 | 説明 |
---|---|
add |
オプションの要素。 トレースする機能領域のコレクションに機能領域を追加します。 |
clear |
オプションの要素。 トレースする機能領域のコレクションから機能領域に対するすべての参照を削除します。 |
remove |
オプションの要素。 トレースする機能領域のコレクションから、ある機能領域に対する参照を削除します。 |
構成サンプル
IIS 7.0 のルート ApplicationHost.config ファイルでは、次の既定の <traceProviderDefinitions>
要素が構成されています。
<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
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()