Advanced Logging is an additional IIS feature that helps administrators customizing web server logs. IIS 7, 7.5, and 8 used this feature as a detailed and customized logging option. With IIS 8.5, Enhanced Logging which is a built-in feature in IIS was introduced.
In this post, I will explain a solution for the scenario where Advanced Logging is not recording any logs. I will also provide a trick to enable it per websites.
What to do if Advanced Logging is not working
First of all, check the module in IIS to make sure it’s enabled.
If everything looks good on the window above, check your
applicationHost.config file. In my case, it was not working because
enabled-"true" attribute were not present. After adding it as shown below, it started logging.
How to enable or disable Advanced Logging per website
It sounds straightforward but -unfortunately- it isn’t because the suggested solution in the official documentation results in the error below.
There was an error while performing this operation.
The request is not supported. (Exception from HRESULT: 0x80070032)
Suggested solution which DOES NOT WORK:
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).
1- In the Connections pane, click the Web site or directory for which you want to disable logging.
2- In the Web site or directory Home page, double-click the Advanced Logging icon.
3- In the Advanced Logging feature page, click the log definition, and then in the Actions pane, click Edit Log Definition.
4- In the Log Definition page, clear the Enabled check box.
5- In the Actions pane, click Apply.
6- Repeat steps (3) through (5) for additional log definitions, if desired.
The trick that works
Instead of disabling Advanced Logging per site, you can create a filter for sites that we don’t want logs for.
For example: In my test environment, let’s say I don’t want logs for MigrationTest site. So created a filter as shown below. It doesn’t log for that site anymore (If there is no log file in the folder, it creates a new file. However, it doesn’t log requests in this file)
In order to create a filter to disable logging for a site:
- Go to IIS Manager
- Click the server name
- Double click Advanced Logging
- Double click the log definition (
- Click Edit Filter
- Click Add Expression
- From Field list, select Site Name
- From Operator list, select Not Equals
- In the Value field, type the site name
- Click OK to close Edit Log Definition Filter window
- Click Apply
- Repeat Step 6-9 for the other sites you want to disable logging for
- Reset IIS
You can use Advanced Logging to actual client IP address when there is a load balancer in between. Here is how to make this configuration: How to log actual client IP address in IIS?