This morning I got a warning on one of our dev servers that the disks were almost full. Whoops! Time to take some action before our dev environment goes down…
After running some diagnostics on the server we found out that most of the disk usage was caused by the IIS logs. After removing some older log files, we already felt a little better.
But how can we prevent this from happening again in the future? I could add a recurring task in my agenda and check the server every month. But there have to be some better alternatives. And no, just disabling the log files is not an option.
First thing we did is enabling folder compression. The IIS logs are simple TXT files which compress very well. Just by doing that we were able to shrink the files to about 2%(!) of their original size.
Here are the steps:
- Open File Explorer.
- Browse to the folder containing IIS log files (by default, %SystemDrive%\inetpub\logs\LogFiles).
- Right-click on the folder and click Properties.
- On the General tab of the Properties page, click Advanced.
- Click Compress contents to save disk space, and then click OK.
If you want to go one step further and really want to remove log files after X time, I would recommend creating a small Powershell script and execute it using a Scheduled Task.