Recipe 12.13. Configuring Web Site LoggingProblemYou want to log visits to your web sites. SolutionUsing a graphical user interfaceTo enable logging for all web sites on the server, do the following:
To enable logging for an individual web site, do the following:
To enable or disable logging for content stored in your web site's home directory, do the following:
To enable or disable logging for content stored in a virtual directory:
To enable or disable logging for an individual file, do the following:
Using a command-line interfaceThe 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 DiscussionTable 12-6 summarizes the different log file formats available for IIS.
See AlsoMS 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) |