トレース URL <traceUrls>
- 概要
- 互換性
- セットアップ
- 方法
- 構成
- サンプル コード
概要
<traceUrls>
要素には <add>
要素のコレクションが含まれます。<add>
の各要素では、トレースを有効にする URL が定義されます。
注 : Windows イベント トレーシング (ETW) は、オペレーティング システムによって提供される汎用の高速トレース機能です。ETW は、カーネルに実装されたバッファー処理とログ記録のメカニズムを使用して、ユーザーモードのアプリケーションとカーネルモードのデバイス ドライバーの両方によって起動されたイベントにトレース メカニズムを提供します。さらに、ログ記録を動的に有効化および無効化する機能を提供して、コンピューターやアプリケーションの再起動なしに、運用環境で詳細なトレースを簡単に行えるようにします。ログ記録メカニズムでは、非同期ライター スレッドによってディスクに書き込まれるプロセッサ単位のバッファーが使用されます。これにより、大規模なサーバー アプリケーションであっても、処理がほとんど妨げられることなくイベントを書き込むことができます。
互換性
IIS 7.0 | IIS 6.0 | |
---|---|---|
説明 | <httpTracing> コレクションの <traceUrls> は IIS 7.0 で新たに導入された要素です。 |
なし |
セットアップ
<httpTracing>
コレクションの <traceUrls>
要素は、IIS 7.0 の既定のインストールに含まれています。
方法
IIS 7.0 には、<httpTracing>
要素を構成するためのユーザー インターフェイスはありません。<httpTracing>
要素にプログラムを使用してアクセスする方法の例については、このドキュメントの「サンプル コード」セクションを参照してください。
構成
属性
なし。
子要素
要素 | 説明 |
---|---|
add |
オプションの要素。 トレース URL のコレクションにトレース URL を追加します。 |
clear |
オプションの要素。 トレース URL のコレクションから、トレース URL の参照をすべて削除します。 |
remove |
オプションの要素。 トレース URL のコレクションから、トレース URL の参照を 1 つ削除します。 |
構成サンプル
次の例を Default Web Site のルートにある Web.config ファイルに配置すると、IIS 7.0 に付属するサンプル ホーム ページのトレースが有効になります。
<configuration>
<system.webServer>
<httpTracing>
<traceUrls>
<add value="/iisstart.htm" />
</traceUrls>
</httpTracing>
</system.webServer>
</configuration>
サンプル コード
次の例では、Contoso という Web サイトの <traceUrls>
コレクションにエントリを追加することにより、この Web サイト上で、 IIS 7.0 に付属するサンプル ホーム ページのトレースを有効にします。
AppCmd.exe
appcmd.exe set config "Contoso" -section:system.webServer/httpTracing /+"traceUrls.[value='/iisstart.htm']" /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 httpTracingSection = config.GetSection("system.webServer/httpTracing", "Contoso");
ConfigurationElementCollection traceUrlsCollection = httpTracingSection.GetCollection("traceUrls");
ConfigurationElement addElement = traceUrlsCollection.CreateElement("add");
addElement["value"] = @"/iisstart.htm";
traceUrlsCollection.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 httpTracingSection As ConfigurationSection = config.GetSection("system.webServer/httpTracing", "Contoso")
Dim traceUrlsCollection As ConfigurationElementCollection = httpTracingSection.GetCollection("traceUrls")
Dim addElement As ConfigurationElement = traceUrlsCollection.CreateElement("add")
addElement("value") = "/iisstart.htm"
traceUrlsCollection.Add(addElement)
serverManager.CommitChanges()
End Sub
End Module
JavaScript
var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";
var httpTracingSection = adminManager.GetAdminSection("system.webServer/httpTracing", "MACHINE/WEBROOT/APPHOST/Contoso");
var traceUrlsCollection = httpTracingSection.ChildElements.Item("traceUrls").Collection;
var addElement = traceUrlsCollection.CreateNewElement("add");
addElement.Properties.Item("value").Value = "/iisstart.htm";
traceUrlsCollection.AddElement(addElement);
adminManager.CommitChanges();
VBScript
Set adminManager = createObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set httpTracingSection = adminManager.GetAdminSection("system.webServer/httpTracing", "MACHINE/WEBROOT/APPHOST/Contoso")
Set traceUrlsCollection = httpTracingSection.ChildElements.Item("traceUrls").Collection
Set addElement = traceUrlsCollection.CreateNewElement("add")
addElement.Properties.Item("value").Value = "/iisstart.htm"
traceUrlsCollection.AddElement addElement
adminManager.CommitChanges()