Depending on the server, you may have a variety of services that are configured to
generate log files. Over time these log files can get quite large and — if not properly managed — you can quickly end up with a log directory gigabytes in size.
Certainly, it would be to your advantage to periodically review logs and purge them as necessary, but that sort of work typically falls to the bottom of the to-do list, especially in shops with very limited manpower.
The tip is to compact the log folder. Since log files are text files, you can get great compression. You simply open Windows Explorer, right-click the log folder, typically C:\Windows\System32\Logfiles, choose Properties and compress the folder.
Because there are a few other directories and files you can compress on the system drive, there is a better way. The Debug folder also contains a number of log files.
Within the Windows directory itself there are usually a number of bitmaps, text and log files that also compress nicely.
Use a batch file like this to compact the specified folders and files. The folders are marked as compressed so that new files will automatically be compressed.
compact /c /s:%windir%\system32\logfiles /i
compact /c /s:%windir%\debug /i
compact /c /f %windir%\*.log /i
compact /c /f %windir%\*.bmp /i
The /i parameter instructs the utility to ignore errors and keep working. It will skip any files it can’t compress that might be in use.
If you include this batch file in your server build process, then you’ll be ahead of the game.
If you find you have a large number of files to process on an existing server, you might want to set up a scheduled task to run the batch file during off-peak hours.
Microsoft doesn’t recommend compressing files on the system drive, and I wouldn’t compress files that are constantly in use. But once a log file is written and a new one started, the old file is rarely touched again — it’s just taking up space. Plus, today’s servers have so much horsepower that a little bit of compression on active log files should be minimal.