IIS Logs Growing Excessively (SBS)

Another common Small Business Server problem is that disk space on the main system partition gets consumed until there is very little free space available, leading to performance degradation.  (This also causes a number of other alarming problems, such as failure to boot, email services shutting down due to ‘Exchange Back Pressure’ and false warnings of disk corruption).  There are many reasons why this happens, but today we’ll be looking specifically at IIS log files.

Internet Information Services (IIS) is Microsoft’s web server implementation, and on Windows Small Business Server it actually has quite a lot of work to do, such as: Exchange services such as autodiscover, out of office, availability service etc; WSUS update delivery; running SharePoint sites.  In general it works well and will require little attention, but it may be storing trouble for the future.

When I’m alerted to a disk space issue, I usually use Jam Software’s TreeSize to get a quick overview of where the space is being used.  (Other freeware disk usage apps are available: try WinDirStat as an alternative).  You can see the below image showing 1.2GB of space used by IIS logs, which by default are at C:\inetpub\logs\logfiles:


This is a small example.  The worst cases I have seen had 50 GB+ of logfiles sprawling across the C: drive.  Once you’ve decided that you have more logs than you need, you must deal with them.  The obvious two approaches are to delete the logfiles when they exceed a certain size/age, and to prevent the logs being generated in the first place.

Here is a very, very basic bit of Powershell to delete the logs.  It can be adjusted to go on age only or size only or any combination:

$FilterDate = (Get-Date).AddDays(-3)
$MaxLogSize = 10mb
Get-ChildItem -Path C:\inetpub\logs\LogFiles -recurse | Where-Object { $_.LastWriteTime -lt $FilterDate -and $_.Length -gt $MaxLogSize } | Remove-Item

A better approach would be to identify the problematic IIS site that is generating the problematic quantity of logs and then disable logging there.  You will notice that the log files are split into folders named W3SVCxxxxxxxxx


The xxxxxxx portion corresponds to the site ID, which you can verify under site > Advanced settings in IIS:


And once you have identified the site generating excess logs, you can simply disable logging from IIS > [site] > Logging > Disable.



Reference: Microsoft Technet: Reclaiming Disk Space Lost to IIS Logs on SBS

No Comments Yet.

Leave a Comment