In this article, we will explore different techniques to manage SCCM IIS log files. You can manage the amount of server disk space that Internet Information Services (IIS) log files consume by using compression, remote storage, and scripted deletion.
SCCM log files and IIS log files are mainly for troubleshooting and reviewing security. The log files that IIS generates can, over time, consume a large amount of disk space. In some cases, the logs can potentially fill up an entire hard drive. Many users disable logging entirely to avoid this problem, but there are some better ways to deal with these logs.
Recently, a customer complained that the SCCM server’s C:\ drive frequently filled up. Investigation revealed that SCCM IIS log files were taking up a significant amount of space on the C: drive. As the Configuration Manager logs all its activities in IIS logs, managing these IIS log files becomes critical for any organization.
Locate IIS Logs on SCCM Server
Before we look at how to manage the IIS logs on the SCCM server, let us find out where the logs are stored. Typically, C:\Inetpub\Logs\LogFiles is where the SCCM IIS log files are stored. You may notice that IIS creates several folders to store the log files, such as W3SVC1, W3SVC2, etc.
The size of log files can be anywhere between 10 MB and 700 MB. The logging is so rigorous that sometimes the log files eat up complete C: drive space.
In the screenshot below, we see a list of IIS log files. IIS log files, which have the potential to take up several GB of space on the drive, can be the cause of low disk space. You cannot delete these logs without knowing the correct procedure. Do not worry; we will go over some best practices for dealing with these IIS logs on the SCCM server.
Ways to Manage IIS logs on SCCM Server
Microsoft advises the following techniques if you want to manage IIS logs on the SCCM server:
- Enable folder compression
- Move the log folder to a remote system
- Delete IIS log files on SCCM server by script
- Delete SCCM IIS Logs Files Manually
- Delete IIS logs using IIS log file cleaner tool
In addition to the above mitigations described above, you may also want to do the following to control disk usage for IIS logs:
- Limit log size by omitting unneeded property fields
- Create separate logs for Websites and applications
- Preserve memory resources by using centralized binary logging
Read more about Managing IIS log file storage by Microsoft.
Method 1: Enable Folder compression for IIS log files
Typically, IIS log files compress to about 2% of their original size. You must be an administrator to perform this procedure.
Perform these steps to turn on the folder compression for IIS log files:
- Navigate to the folder containing IIS log files: %SystemDrive%\inetpub\logs\LogFiles.
- Right-click on the folder and select Properties.
- On the General tab of the Properties page, click Advanced.
- Click Compress contents to save disk space, and then click OK.
When you compress a folder containing IIS logs, you have the option of applying the compression to the entire folder or enabling it on individual folders, subfolders, and files. Once you have turned on the compression on the IIS LogFiles folder, the name of the folder and the name of each file should be colored blue, and the size of a compression file should be smaller.
Method 2: Delete IIS Log files using Script
Microsoft recommends running a script that automatically deletes log files that are older than a certain age. You can either manually run this script when required or run this script as a scheduled task to resolve the problem of a disk filling up under control without constant maintenance.
Microsoft provides the VBScript listed below to manage the IIS logs on Windows Server. Before using this script, please read the following points:
- The VBScript will examine the age of each log file in a folder and delete any log file that is older than a certain age.
- The script can be customized for your organization. For example, you can change the name and path of the folder in line 1 of the script and change the maximum age to the desired value in days in line 2.
- The best part is that the script above will scan all subfolders, so it will process logs for all sites in and under the folder specified.
Copy the below script and paste it in a notepad or text document. Save the file as cleanIISLogs.vbs. To run the script manually, execute the following script in an administrator command line:
sLogFolder = "c:\inetpub\logs\LogFiles"
iMaxAge = 30 'in days
Set objFSO = CreateObject("Scripting.FileSystemObject")
set colFolder = objFSO.GetFolder(sLogFolder)
For Each colSubfolder in colFolder.SubFolders
Set objFolder = objFSO.GetFolder(colSubfolder.Path)
Set colFiles = objFolder.Files
For Each objFile in colFiles
iFileAge = now-objFile.DateCreated
if iFileAge > (iMaxAge+1) then
objFSO.deletefile objFile, True
Method 3: Create a scheduled task to delete SCCM IIS log files
You can automate the task of deleting IIS log files on the SCCM server by using a script and creating a Windows task schedule to run the script periodically. You can schedule the script to run at any time using the Windows Task Scheduler.
Perform the following steps to create a scheduled task to delete IIS logs on Windows Server:
Step 1: Open Server Manager, click the Tools menu, and then click Task Scheduler. In the Actions pane of the Task Scheduler dialog box, click Create Task.
Step 2: On the General tab of the Create Task dialog box, enter a name for the task, such as “Delete SCCM IIS Log Files“. Under the security options, select a user account with sufficient privileges to run the script.
Step 3: Click the Triggers tab, and then click New. In the New Trigger dialog box, set Begin the Task to On a Schedule. You can schedule the script to run once, daily, weekly, or monthly. In the example below, the script is scheduled to run every week, and it runs on Saturday and Sunday. You can configure the options based on your organization’s requirements. Click OK.
Step 4: Now click the Actions tab, and then select New. In the New Action dialog box, select a value for Action, in this case, Start a program. In Program/script, enter ‘cscript,’ and in Add arguments (optional), enter the path and name of the script file, for example, E:\Sources\scripts\CleanLogs\cleaniislogs.vbs. Click OK.
Step 5: Once you have performed the above steps, you should find a new scheduled task in the list along with others. You can let this script run on a configured schedule. In case you need to run this task manually, right-click the task and select Run.
Method 4: Disable IIS Logging
This method can be used to turn off logging completely. If you are not going to refer to the IIS logs while troubleshooting issues with SCCM and it’s components, you can disable IIS logging.
Here’s how you can turn off IIS logging permanently. Launch the Internet Information Services Manager (IIS Manager) on Windows Server. Select the IIS server, and in the right pane, select Logging.
On the Logging pane, under the Actions section, select Disable. This will turn off IIS logging permanently.
Method 5: Delete Old SCCM IIS Log files using IIS Log Cleaner Tool
The IIS Log Cleaner tool is a third-party tool for removing old SCCM IIS logs. This tool is no longer updated, so we do not recommend it. We do not know when the tool’s host website will go back online, so it is currently unavailable.
This tool was used to delete IIS logs automatically by deleting log files older than the maximum age that you set. In order to prevent possible data loss, the log files are transferred to the recycle bin. Although Microsoft does not officially support the tool, it functions well and is useful for cleaning up log files.
Right-click the IIS Log Cleaner tool and select Run as administrator.
When you run the tool for the first time, it lets you configure the settings.
The tool now places an icon in the system tray. In the system tray, right-click the IIS icon and choose Settings. On the message box, click OK. This opens up the settings file in a notepad. The text file includes a command to clean up log files. You can change Max Age from 30 days to custom days. The settings.txt file is stored in the same folder as IISLogCleaner.
Right-click the IIS Log Cleaner tool and select Clean Now. Instead of deleting log files, the cleaner tool moves them to the recycle bin.
You can see how well the log cleaner tool performed in the screenshot below. The IIS log files, weighing 118 GB, were successfully cleaned up by the tool.
Method 6: Change IIS Logs location
If your Configuration Manager server has a limitation on disk space, the IIS logs can be moved to a different server. The IIS log files are stored by default in the %SystemDrive%\inetpub\logs\LogFiles folder of your IIS server.
The folder is configured in the Directory property on the Logging page for either the server or an individual site. You can move your IIS log files to a folder on another server that has more space. This server can either be in the same domain as the local IIS server or in a different domain. You can save log files remotely, either for the entire server or for individual websites.
Use the following steps to change the logging directory for IIS Logs.
Step 1: Launch the Internet Information Services Manager (IIS Manager) on Windows Server. Select the IIS server, and in the right pane, select Logging.
Step 2: The default directory is set to %SystemDrive%\inetpub\logs\LogFiles. Click Browse and set a directory to move your IIS log files to a folder on another server that has more space.
How to view IIS logs
During the SCCM troubleshooting, administrators may need to review the IIS logs to locate errors related to components. So how do you view or open the IIS logs on the SCCM server? The answer is the CMTrace tool. Refer to the following guide on log file viewer tools in ConfigMgr.
The CMTrace log viewer can be obtained from two locations:
- SCCM Server: The tool is located in the \Program Files\Microsoft Configuration Manager\Tools folder.
- Windows Client: On the computer that is installed with the SCCM client, the tool is located in C:\Windows\CCM folder.