バイナリ集中ログ ファイル <centralBinaryLogFile>
概要
<centralBinaryLogFile>
要素は、サーバー上のすべてのサイトに対してバイナリ集中ログ設定を指定します。
Note
<centralW3CLogFile>
要素の属性を有効にするには、親の <log>
要素の centralLogFileMode 属性を CentralBinary に設定する必要があります。 <log>
要素の centralLogFileMode 属性が CentralW3C または Site に設定されている場合、<centralW3CLogFile>
要素の属性は無視されます。
Note
W3C 形式のログ ファイルは、ほとんどのログ解析ユーティリティが処理できるテキスト ベースのファイルです。 Binary ログ ファイルは、Microsoft の Log Parser ユーティリティなどの、その形式でログ ファイルを処理できるアプリケーションの使用を必要とする独自のストレージ形式を使用します。
互換性
バージョン | メモ |
---|---|
IIS 10.0 | <centralBinaryLogFile> 要素は、IIS 10.0 では変更されませんでした。 |
IIS 8.5 | <centralBinaryLogFile> 要素は、IIS 8.5 では変更されませんでした。 |
IIS 8.0 | <centralBinaryLogFile> 要素は IIS 8.0 では変更されませんでした。 |
IIS 7.5 | <centralBinaryLogFile> 要素は、IIS 7.5 では変更されませんでした。 |
IIS 7.0 | <log> 要素の <centralBinaryLogFile> 要素が IIS 7.0 で導入されました。 |
IIS 6.0 | <log> 要素は、IIS 6.0 CentralBinaryLoggingEnabled フラグを置き換えます。 |
段取り
<log>
要素の <centralBinaryLogFile>
要素は、IIS 7 の既定のインストールに含まれています。
操作方法
サーバーに対して中央の Binary ログを有効にする方法
次のようにインターネット インフォメーション サービス (IIS) マネージャーを開きます。
Windows Server 2012 または Windows Server 2012 R2 を使用している場合:
- タスク バーで、[サーバー マネージャー] をクリックし、[ツール]、[インターネット インフォメーション サービス (IIS) マネージャー] の順にクリックします。
Windows 8 または Windows 8.1 を使用している場合:
- Windows キーを押しながら文字 X を押し、[コントロール パネル] をクリックします。
- [管理ツール] をクリックし、[インターネット インフォメーション サービス (IIS) マネージャー] をダブルクリックします。
Windows Server 2008 または Windows Server 2008 R2 を使用している場合:
- タスク バーで、[スタート] ボタンをクリックし、[管理ツール]、[インターネット インフォメーション サービス (IIS) マネージャー] の順にクリックします。
Windows Vista または Windows 7 を使用している場合:
- タスク バーで、[スタート]、[コントロール パネル] の順にクリックします。
- [管理ツール] をダブルクリックし、[インターネット インフォメーション サービス (IIS) マネージャー] をダブルクリックします。
[接続] ウィンドウでサーバー名をクリックします。
サーバーの [ホーム] ウィンドウで、[ログ記録] をダブルクリックします。
[ログ記録] ページの [ログ ファイル作成単位] で、ドロップダウン リストから [サーバー] を選択して、[形式] ドロップダウン リストから [Binary] を選びます。
[操作] ペインで [適用] をクリックします。
構成
属性
属性 | 説明 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
directory |
省略可能な文字列属性。 ログ エントリの書き込み先となるディレクトリを指定します。 |
||||||||||||
enabled |
省略可能な Boolean 属性です。 バイナリ集中ログを有効にするかどうかを指定します。 また、バイナリ集中ログを完全に有効にするには、centralLogFileMode を CentralBinary に設定する必要があります。 既定値は false です。 |
||||||||||||
localTimeRollover |
省略可能な Boolean 属性です。 新しいログ ファイルがローカル時刻または協定世界時 (UTC) のどちらに基づいて作成されるかを指定します。 true の値は、新しいログ ファイルがローカル時刻に基づくことを意味し、false は UTC に基づくことを意味します。 既定値は false です。 |
||||||||||||
period |
省略可能な列挙型属性。 ログ ファイルの内容をクリアする頻度を指定します。 period 属性には、次のいずれかの値を指定できます。 既定値は Daily です。
|
||||||||||||
truncateSize |
省略可能な int64 属性。 ログ ファイルの内容を切り捨てるサイズをバイト単位で指定します。 この属性は、period 属性の値が maxSize の場合に設定する必要があります。 サイズは、1048576 (1 メガバイト) から 4294967295 (4 ギガバイト) の間である必要があります。 既定値は 20971520 (20 メガバイト) です。 |
子要素
なし。
構成サンプル
次の構成サンプルは、IIS がバイナリ集中ログを使用し、Binary ログ ファイル ロールオーバーを毎日に構成することを指定します。
<log centralLogFileMode="CentralBinary">
<centralBinaryLogFile enabled="true" directory="%SystemDrive%\inetpub\logs\LogFiles" period="Daily" />
<centralW3CLogFile enabled="true" directory="%SystemDrive%\inetpub\logs\LogFiles" />
</log>
サンプル コード
次のコード サンプルは、IIS が中央の Binary ログを使用し、Binary ログ ファイル ロールオーバーを毎日に構成することを指定します。
AppCmd.exe
appcmd.exe set config -section:system.applicationHost/log /centralLogFileMode:"CentralBinary" /commit:apphost
appcmd.exe set config -section:system.applicationHost/log /centralBinaryLogFile.period:"Daily" /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 logSection = config.GetSection("system.applicationHost/log");
logSection["centralLogFileMode"] = @"CentralBinary";
ConfigurationElement centralBinaryLogFileElement = logSection.GetChildElement("centralBinaryLogFile");
centralBinaryLogFileElement["period"] = @"Daily";
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 logSection As ConfigurationSection = config.GetSection("system.applicationHost/log")
logSection("centralLogFileMode") = "CentralBinary"
Dim centralBinaryLogFileElement As ConfigurationElement = logSection.GetChildElement("centralBinaryLogFile")
centralBinaryLogFileElement("period") = "Daily"
serverManager.CommitChanges()
End Sub
End Module
JavaScript
var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";
var logSection = adminManager.GetAdminSection("system.applicationHost/log", "MACHINE/WEBROOT/APPHOST");
logSection.Properties.Item("centralLogFileMode").Value = "CentralBinary";
var centralBinaryLogFileElement = logSection.ChildElements.Item("centralBinaryLogFile");
centralBinaryLogFileElement.Properties.Item("period").Value = "Daily";
adminManager.CommitChanges();
VBScript
Set adminManager = WScript.CreateObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set logSection = adminManager.GetAdminSection("system.applicationHost/log", "MACHINE/WEBROOT/APPHOST")
logSection.Properties.Item("centralLogFileMode").Value = "CentralBinary"
Set centralBinaryLogFileElement = logSection.ChildElements.Item("centralBinaryLogFile")
centralBinaryLogFileElement.Properties.Item("period").Value = "Daily"
adminManager.CommitChanges()