로그 <로그>

개요

요소는 <log> IIS(인터넷 정보 서비스) 7에 대한 몇 가지 전역 로깅 옵션을 지정합니다. 예를 들어 centralLogFileMode 특성은 사이트 수준 로깅, 중앙 W3C 로깅 또는 중앙 이진 로깅을 사용할 수 있는지 여부를 지정합니다.

사이트 수준 로깅은 서버의 각 사이트에 대한 개별 로그 파일 디렉터리를 만듭니다. 여기서 각 폴더에는 해당 사이트의 로그 파일만 포함됩니다. 중앙 로깅을 사용하면 또는 <centralW3CLogFile> 요소에 대한 period 특성으로 지정된 기간 동안 모든 사이트에 단일 <centralBinaryLogFile> 로그 파일을 사용할 수 있습니다. 기간은 매일, 매주, 매월, 매시간 또는 최대 파일 크기일 수 있습니다.

참고

W3C 형식의 로그 파일은 대부분의 로그 구문 분석 유틸리티에서 처리할 수 있는 텍스트 기반 파일입니다. 이진 로그 파일은 Microsoft의 LogParser 유틸리티와 같이 해당 형식으로 로그 파일을 처리할 수 있는 애플리케이션을 사용해야 하는 전용 스토리지 형식을 사용합니다.

호환성

버전 참고
IIS 10.0 <log> 요소가 IIS 10.0에서 수정되지 않았습니다.
IIS 8.5 <log> 요소가 IIS 8.5에서 수정되지 않았습니다.
IIS 8.0 <log> 요소가 IIS 8.0에서 수정되지 않았습니다.
IIS 7.5 <log> 요소가 IIS 7.5에서 수정되지 않았습니다.
IIS 7.0 요소는 <log> IIS 7.0에서 도입되었습니다.
IIS 6.0 요소는 <log> 다음 IIS 6.0 특성을 대체합니다.
  • CentralBinaryLoggingEnabled
  • CentralW3CLoggingEnabled
  • LogInUTF8

설치 프로그램

요소는 <log> IIS 7의 기본 설치에 포함됩니다.

방법

서버에 중앙 이진 로깅을 사용하도록 설정하는 방법

  1. 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(인터넷 정보 서비스) 관리자를 두 번 클릭합니다.
  2. 연결 창에서 서버 이름을 클릭합니다.

  3. 서버의 창에서 로깅을 두 번 클릭합니다.
    서버 홈 창에서 선택한 로깅의 스크린샷

  4. 로깅 페이지의 한 로그 파일당에서 드롭다운 목록에서 서버를 선택한 다음 형식 드롭다운 목록에서 이진을 선택합니다.
    로깅 창에서 서버당 하나의 로그 파일 및 로그 파일 형식을 이진 파일로 설정하는 스크린샷

  5. 작업 창에서 적용을 클릭합니다.

서버에 대해 중앙 W3C 로깅을 사용하도록 설정하는 방법

  1. 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(인터넷 정보 서비스) 관리자를 두 번 클릭합니다.
  2. 연결 창에서 서버 이름을 클릭합니다.

  3. 서버의 창에서 로깅을 두 번 클릭합니다.
    서버 홈 창에서 선택한 로깅 아이콘의 스크린샷.

  4. 로깅 페이지의 한 로그 파일당 드롭다운 목록에서 서버를 선택한 다음 형식 드롭다운 목록에서 W3C를 선택합니다.
    로깅 창에서 서버당 하나의 로그 파일 및 로그 파일 형식을 W 3 C로 설정하는 스크린샷

  5. 작업 창에서 적용을 클릭합니다.

구성

특성

attribute Description
centralLogFileMode 선택적 열거형 특성입니다.

서버에 대한 중앙 로깅 모드를 지정합니다.

centralLogFileMode 특성에는 다음과 같은 가능한 값 중 하나가 있을 수 있습니다. 기본값은 Site입니다.
Description
Site 중앙 로깅 대신 사이트 로깅을 사용하도록 모든 사이트를 구성합니다. 이 값은 기본 설정입니다.

숫자 값은 0입니다.
CentralBinary 웹 서버의 모든 웹 사이트에 대해 하나의 로그 파일을 만듭니다. 로그 파일의 데이터는 사용자 지정할 수 없는 이진 기반의 형식이 지정되지 않은 데이터입니다.

숫자 값은 1입니다.
CentralW3C 웹 서버의 모든 사이트에 대한 요청을 텍스트 기반의 사용자 지정 가능한 ASCII 형식으로 단일 중앙 로그 파일에 기록합니다.

숫자 값은 2입니다.
logInUTF8 선택적 부울 특성입니다.

IIS가 UCS 변환 형식 8(UTF-8)에서 모든 문자열을 기록해야 하는지 여부를 지정합니다. 이 설정은 모든 텍스트 모드 로깅에 서버 전체에 적용됩니다.

기본값은 true입니다.

자식 요소

요소 Description
centralBinaryLogFile 선택적 요소입니다.

서버의 모든 사이트에 대한 중앙 이진 로그 설정을 지정합니다.
centralW3CLogFile 선택적 요소입니다.

서버의 모든 사이트에 대한 중앙 W3C 로그 설정을 지정합니다.

구성 샘플

다음 구성 샘플에서는 IIS가 사이트 수준 로깅을 사용하도록 지정합니다.

<log centralLogFileMode="Site">
   <centralBinaryLogFile enabled="true" directory="%SystemDrive%\inetpub\logs\LogFiles" />
   <centralW3CLogFile enabled="true" directory="%SystemDrive%\inetpub\logs\LogFiles" />
</log>

다음 구성 샘플은 IIS가 중앙 이진 로깅을 사용하도록 지정하고 매일 이진 로그 파일 회전을 구성합니다.

<log centralLogFileMode="CentralBinary">
   <centralBinaryLogFile enabled="true" directory="%SystemDrive%\inetpub\logs\LogFiles" period="Daily" />
   <centralW3CLogFile enabled="true" directory="%SystemDrive%\inetpub\logs\LogFiles" />
</log>

다음 구성 샘플은 IIS가 중앙 W3C 로깅을 사용하도록 지정하고 W3C 로그 파일 회전을 매일 구성합니다.

<log centralLogFileMode="CentralW3C">
   <centralBinaryLogFile enabled="true" directory="%SystemDrive%\inetpub\logs\LogFiles" />
   <centralW3CLogFile enabled="true" directory="%SystemDrive%\inetpub\logs\LogFiles" period="Daily" />
</log>

샘플 코드

다음 코드 샘플은 IIS가 중앙 이진 로깅을 사용하도록 지정하고 매일 이진 로그 파일 회전을 구성합니다.

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

참고

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

다음 코드 샘플에서는 IIS가 중앙 W3C 로깅을 사용하도록 지정하고 W3C 로그 파일 회전을 매일 구성합니다.

AppCmd.exe

appcmd.exe set config -section:system.applicationHost/log /centralLogFileMode:"CentralW3C" /commit:apphost

appcmd.exe set config -section:system.applicationHost/log /centralW3CLogFile.period:"Daily" /commit:apphost

참고

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"] = @"CentralW3C";
         ConfigurationElement centralW3CLogFileElement = logSection.GetChildElement("centralW3CLogFile");
         centralW3CLogFileElement["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") = "CentralW3C"
      Dim centralW3CLogFileElement As ConfigurationElement = logSection.GetChildElement("centralW3CLogFile")
      centralW3CLogFileElement("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 = "CentralW3C";
var centralW3CLogFileElement = logSection.ChildElements.Item("centralW3CLogFile");
centralW3CLogFileElement.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 = "CentralW3C"
Set centralW3CLogFileElement = logSection.ChildElements.Item("centralW3CLogFile")
centralW3CLogFileElement.Properties.Item("period").Value = "Daily"

adminManager.CommitChanges()