Log files are great places to look when troubleshooting or analyzing your website traffic. Every time your IIS receives a client’s request, it records that request in a log file. In this post, I want to show you how to use PowerShell to configure and manage IIS log files, such as changing the logging frequency or setting the folder where IIS will store log files or, if you prefer, how to turn off logging.

The following post assumes that you have a Windows Server 2008 R2 or higher with the installed web server role. If you want to know how to do this configuration, maybe my previous post:How to install IIS on Windows Server with SSL using PowerShell,” may interest you.

PowerShell Workaround


  • PowerShell version 3.0 or higher.
  • You must be logged on to a server as an administrator to install or uninstall roles, role services, and features.

Import the WebAdministration module

To make sure the IIS provider is loaded, import the WebAdministration module using the following command.

Verify the current configurations

The above module import also loads the WebAdministration Powershell provider. This provider allows you to browse aspects of the webserver, including sites, application pools, and SSL bindings on the host.

IIS logging

Check the current location of IIS Log files.

Using the following commands, you can get the current location of the Logs files.

IIS logging
By default, the IIS store the log file in the %systemdrive%\inetpub\logs\LogFiles.

Set the Log Files new Location

To change the location of your website’s log files, you should use the following command.

Note that best practices recommend that the log files be stored in a directory other than % systemroot%.

Change the Log Files output format.

If you want to change the log file format, you should use the following command to modify the logformat attribute. By default, the format is W3C, but you can select the following formats: W3C, IIS, NCSA, and custom.

If you want to know more about this topic, check out this link.

Log Event Destination

In IIS 8.5, the administrator can send log information to Event Tracing for Windows (ETW). To do this, you should change the logTargetW3C attribute use the following command. By default, IIS sends the information to the Log file only, but you can use the following options: File, ETW, or both.

Set Log File Rollover Options

Change the frequency of the log file changes.

You can change the frequency of the log file changes. By default, IIS produces one file per day, but you can set your logfile changes: Hourly, Daily, Weekly, Monthly, or Maximum size.

Set a maximum size for the log file

To create a log file when the file reaches a certain size, you should use the following command. In the following example, I set the maximum value of the file to 1 Gb expressed in bytes.

By default, the minimum file size is 1048576 bytes. If this attribute is set to a value less than 1048576 bytes, the default value is implicitly assumed as 1048576 bytes.

Use the local time instead of UTC for naming and logging

Set the value to true for the localTimeRollover attribute if you want to create a new log file based on local time
by default, the value is false, and Coordinated Universal Time (UTC) is used

Disable IIS Logging

Finally, if you want to disable your website’s Logging, you should use the following command.

Thanks for reading my post. I hope you find it useful.

If you want to know more about Internet Information Server (IIS), check out this link:https://www.iis.net/.