IIS 7.0 Advanced Logging: Is 1 Log File per Website Possible

iis-7loggingwindows-server-2008

We currently have normal IIS Logging enabled with the "One log file per: Site" option selected, allowing each website to have its own log files. I just set up IIS Advanced Logging and cannot find a comparable option. Advanced Logging for all websites is being done in a single file. How can I set up Advanced Logging so that each website will have its own log files?

Here's how things currently stand:

  • At the machine level, I enabled Advanced Logging and specified a log directory of D:\Logs.
  • For each website, I specified a unique log directory, e.g. D:\Logs\Website1.
  • After these changes were made, I restarted IIS using the command prompt by running iisreset, and successfully received the expected stop/start responses.
  • All logging is still being done in a single log file in the directory D:\Logs. No new log files have been created in the website-specific directories.

Best Answer

This is possible by creating a log definition for each site. Name each log definition to correspond to the site you want the logs collected for and enabling them for the specific site you want logged to that file. Microsoft goes into some detail on this in the Advanced Logging Readme:

Enabling and disabling logging for Web sites. The Advanced Logging feature can be enabled or disabled at the server level in IIS Manager, which also enables or disables logging at lower levels (matching the server-level setting). If you want to disable logging for certain Web sites or directories, while enabling logging for others, enable the Advanced Logging feature at the server level, and then disable the log definition files for the Web sites/directories for which you want to disable logging. To disable a log definition, do the following:

  • In the Connections pane, click the Web site or directory for which you want to disable logging.
  • In the Web site or directory Home page, double-click the Advanced Logging icon.
  • In the Advanced Logging feature page, click the log definition, and then in the Actions pane, click Edit Log Definition.
  • In the Log Definition page, clear the Enabled check box.
  • In the Actions pane, click Apply.
  • Repeat steps (3) through (5) for additional log definitions, if desired.

Source: https://www.iis.net/learn/extensions/advanced-logging-module/advanced-logging-readme

I've personally had trouble changing Advanced Logging settings at the site level in the past but you could also use a filter for each log definition to limit the scope to a single site.