Recipe12.13.Configuring Web Site Logging


Recipe 12.13. Configuring Web Site Logging

Problem

You want to log visits to your web sites.

Solution

Using a graphical user interface

To enable logging for all web sites on the server, do the following:

  1. Open Internet Information Services (IIS) Manager.

  2. In the left pane, expand the console tree to display the Web Sites node, right-click on this node, and select Properties.

  3. Select the Web Site tab.

  4. Select the Enable logging checkbox.

  5. Select a log file format as desired (W3C Extended Log File Format is recommended).

To enable logging for an individual web site, do the following:

  1. Open Internet Information Services (IIS) Manager.

  2. In the left pane, expand the console tree to display your web site, right-click on the site, and select Properties.

  3. Select the Web Site tab.

  4. Select the Enable logging checkbox.

  5. Select a log file format as desired (W3C Extended Log File Format is recommended).

To enable or disable logging for content stored in your web site's home directory, do the following:

  1. Open Internet Information Services (IIS) Manager.

  2. In the left pane, expand the console tree to display your web site, right-click on the site, and select Properties.

  3. Select the Home Directory tab.

  4. Select or clear the Log visits checkbox as desired.

To enable or disable logging for content stored in a virtual directory:

  1. Open Internet Information Services (IIS) Manager.

  2. In the left pane, expand the console tree to display your web site, select a virtual directory within your site, right-click on the virtual directory, and select Properties.

  3. Select the Virtual Directory tab.

  4. Select or clear the Log visits checkbox as desired.

To enable or disable logging for an individual file, do the following:

  1. Open Internet Information Services (IIS) Manager.

  2. In the left pane, expand the console tree to display your web site, right-click on a particular file within the home directory or some other virtual directory, and select Properties.

  3. Select the File tab.

  4. Select or clear the Log visits checkbox as desired.

Using a command-line interface

The following command enables Centralized Binary Logging, which is new to IIS 6:

> cscript %systemroot%\inetpub\adminscripts\adsutil.vbs SET W3SVC/ CentralBinaryLoggingEnabled

After running this command you need to restart IIS (see Recipe 12.2) at which point IIS log files will have the format rayymmdd.ibl (ra stands for "raw") and will be found in %SystemRoot%\system32\logfiles\w3svc. Once you've enabled Centralized Binary Logging, any further changes you make to IIS logging settings in the GUI are ignored. These *.ibl log files can be read using the Log Parser (LogParser.exe) utility included in the IIS 6 Resource Kit Tools.

This command causes W3C Extended log files to roll over (create new log files) for all web sites at midnight local time:

> cscript %systemroot%\inetpub\adminscripts\adsutil.vbs SET W3WVC\LogFileLocaltimeRollover

Note that even if you do this, IIS still records times in W3C Extended log files using UTC, not local time.

Using VBScript
' This code enables logging ' ------ SCRIPT CONFIGURATION ------ strComputer = "<ServerName>" strSite = "<Site>" ' e.g., W3SVC/222 intEnableLog = 1  ' 1 to enable; 0 to disable ' ------ END CONFIGURATION --------- set objWS = GetObject("IIS://" & strComputer & "/" & strSite) objWS.Put "LogType", intEnableLog ' objWS.Put "LogDirectory", "d:\logs"  ' uncomment this to set the log dir objWS.SetInfo WScript.Echo "Logging enabled for web site: " & objWS.ServerComment

Discussion

Table 12-6 summarizes the different log file formats available for IIS.

Table 12-6. IIS log formats

Log file format

Description

W3C Extended Log File Format

A customizable format developed by the World Wide Web Consortium

IIS Log File Format

A fixed format developed by Microsoft for earlier versions of IIS

NCSA Log File Format

A fixed format developed by the National Center for Supercomputing Applications for the original ncsa-httpd web server

ODBC Logging

Enables logging to an ODBC-compliant database, such as Microsoft SQL Server

Centralized Binary Logging

Enables multiple web sites to write to a single log file using a proprietary binary format


Don't use ODBC Logging on IIS 6 because it disables kernel mode caching, which can significantly degrade web server performance.


See Also

MS KB 324279 (HOW TO: Configure Web Site Logging in Windows Server 2003), MS KB 814870 (INFO: IIS 6.0 Log Management Documentation), MS KB 242898 (IIS Log File Naming Syntax), MS KB 291279 (IIS Log File Is Not Created When There Is No Activity on a Web Site), MS KB 194699 (Extended Log File Format Always in GMT), MS KB 271196 (IIS Log File Entries Have the Incorrect Date and Time Stamp), and MS KB 832975 (Additional properties are now available for logging in the Httperr#.log file in IIS 6.0)



Windows Server Cookbook
Windows Server Cookbook for Windows Server 2003 and Windows 2000
ISBN: 0596006330
EAN: 2147483647
Year: 2006
Pages: 380
Authors: Robbie Allen

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net