How to configure IIS log rollover by size?
Jul 22, 2025 am 12:18 AMIIS can automatically split logs by file size through registry configuration. 1. Enter the "Log" setting in IIS Manager, check "Enable log rollover based on file size", and uncheck "Schedule". 2. Modify the registry path HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\Parameters, add or modify the MaxFileSize DWORD value (unit bytes), such as 100MB to 104857600. 3. Restart the IIS effective settings and pay attention to setting the file size reasonably to balance performance and management needs. In addition, it is recommended to keep the default naming format, specify independent log paths, and clean the logs regularly.
IIS scrolls logs by day by day by default, but if you want the logs to be automatically divided by file size, for example, when the number of visits per day is particularly large, scrolling by size can avoid too large a single log file, affecting viewing and analysis. This setting is actually not complicated, but many people are not very clear about how to operate it.

Next, I will explain step by step how to configure IIS logs to scroll by size.
Modify the location of the log scroll settings
In IIS Manager, the settings for log scrolling are located in the Log section at the Website or Server level. The specific operations are as follows:

- Open IIS Manager, select the website you want to set up or set it directly on the server node (affects all sites).
- Double-click the Log icon.
- Click "Select Log File Format" in the "Operation" panel on the right.
- Click "Edit Log File Settings".
At this time, a window will pop up with two key options:
- Schedule
- Enable log rollover based on file size
Check "Enable log rollover based on file size", and uncheck "Schedule".

In this way, the logs will no longer scroll by the day, but will create a new log file based on the file size.
Set the maximum log file size
The default maximum log size of IIS is 20MB, but this value can be modified through the registry. Yes, you read that right. It is not set in the IIS management interface, but you need to change the registry.
The specific path is as follows:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\Parameters
Add or modify a DWORD value named MaxFileSize
in bytes under this path.
For example, if you want to set it to 100MB, fill in 104857600
(100 1024 1024).
After the modification, you need to restart IIS (you can use the iisreset
command) before the new settings will take effect.
What should be noted is:
- If set too small, it may cause frequent switching of log files, affecting performance
- If set too large, the purpose of "scroll by size" may not be achieved.
- Generally, it is recommended to set between 50MB and 200MB.
Log file naming and path suggestions
IIS uses dates as part of the log file name by default, such as u_ex240405.log
. If you enable Scroll by size, the file name will become a format similar to u_ex240405_0001.log
.
Suggest you:
- Keep the default naming method so that the log files are in order
- Set the log path to a separate disk partition to prevent excessive logs from filling the system disk
- Regularly clean old logs or set up script archives
You can also adjust log behavior by configuring period
and truncSize
properties of logFile
node (in the applicationHost.config
file).
Basically that's it. Although the IIS interface does not support setting the maximum value scrolling by size directly, it is not particularly difficult to modify through the registry. As long as you pay attention to the reasonable restart and size settings, you can control the log file size well.
The above is the detailed content of How to configure IIS log rollover by size?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

IIS logs are stored in the inetpub\logs\LogFiles directory of the C drive by default and will not be cleaned automatically. The retention period needs to be controlled manually or through scripts. To modify the path, you can open IIS Manager → select a site or server node → double-click "Login" → click "..." to select a new directory. It is recommended to use non-system disks such as D:\IISLogs or multiple servers to configure the network path in a unified manner; set retention time can be achieved through LogParser scripts, task planning PowerShell scripts (such as 30 days of retention), third-party tools, etc.; in addition, it is recommended to adjust the log format as needed, close unnecessary fields, or temporarily close the debug log, and enable log compression to optimize performance and space usage.

To search for specific strings in IIS logs, use built-in Windows tools or scripts. 1. Use the findstr command of the command prompt to search recursively, such as: findstr/s/i/m"string"*.log; 2. Use PowerShell to perform more flexible searches, such as: Get-ChildItem combined with Select-String and supports regular expressions; 3. When using frequently, you can use the LogParser tool to support SQL syntax query and can export results; 4. Note that the log location may be different, and large files need to optimize the search method.

ThedefaultIISlogfilepathisC:\inetpub\logs\LogFiles,butitcanbecustomized.1.EachwebsitehasitsownsubfolderlikeW3SVC1.2.Tofindtheexactpath,openIISManager,selectthesite,andchecktheLoggingsection.3.LogsusetheW3Cformatandcontaindetailslikerequesttime,IPaddr

ParsingIISlogswithPowerShell is a way to quickly get useful information without complex tools. 1. First understand the IIS log format, which defaults to W3C extended log format, and fields are separated by spaces; 2. Use the Import-Csv command to import the log file and skip the comment lines, pay attention to handling the quotation fields; 3. Use Where-Object, Group-Object and other commands to filter 404 errors, count IP requests, and query specific page access; 4. The analysis results can be exported to CSV for reporting; 5. This method is suitable for small and medium-sized log files. Large-scale or complex analysis can consider tools such as LogParser and ELKStack.

IIS logs on multiple servers can be implemented in the following ways: 1. Use Windows event forwarding, suitable for scenarios where logs have been written to event logs, create subscriptions on the central server and configure forwarding rules on each IIS server; 2. Use file sharing scripts to collect regularly, suitable for small environments, use scripts to copy log files from each server regularly, combining robocopy or xcopy with scheduled task execution; 3. Deploy log collection tools such as Logstash, NXLog, Fluentd, suitable for large-scale environments, support automatic collection, filtering, compression and forwarding, and have failed retry and breakpoint continuous transmission functions. In addition, it is necessary to unify the log path, configure access permissions, pay attention to the log rotation mechanism and consider compression

Application pool crashes can quickly locate the causes by analyzing the IIS log. 1. First check the W3SVC log at the crash time point, search for 503 errors, and determine whether it is caused by application pool crash or frequent recycling; 2. Combine the HTTPERR log to check whether there are any underlying error entries such as Connection_Dropped or RequestQueueFull, and confirm that the backend cannot respond; 3. Check the application and system logs in the event viewer, find events such as 5002, 5015, 5017 from WAS or IIS-WMSVC sources, and confirm that the application pool life cycle abnormality; 4. Troubleshoot common causes, such as code exceptions, unavailability of dependency resources, rapid failure triggering, memory leaks, etc., and combine debugging tools

IIS can automatically split logs by file size through registry configuration. 1. Enter the "Log" setting in the IIS manager, check "Enablelogrolloverbasedonfilesize", and uncheck "Schedule". 2. Modify the registry path HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\Parameters, add or modify the MaxFileSizeDWORD value (unit bytes), such as 100MB is 104857600. 3. Restart the IIS effective settings and pay attention to setting the file size reasonably to balance performance and management

To automatically archive IIS logs, you can automatically run by setting the log rolling cycle, using PowerShell scripts to compress legacy logs, and using task schedulers. 1. Set the log file scrolling interval in IIS Manager. It is recommended to scroll every day or scroll by size (such as 10MB~100MB) for easy subsequent processing; 2. Write PowerShell scripts, find log files that exceed the set number of days (such as 7 days) under the specified path, compress them to the specified directory and delete the original file; 3. Create basic tasks through the task scheduler, set the trigger frequency (such as daily), run the script with the highest permission, and add the parameter -ExecutionPolicyBypass to ensure the stable execution of the script. In addition, it must be clarified
