Tiny permalink to this page.
compress.vbs is a Windows script (VBS) designed to compress the log files generated by the Apache webserver. It is intended to be used with rotatelogs so that the file lock is removed from the current logfile. The script will filter the source directory to exclude today's log files. It will then call 7zip to compress the files individually and remove the uncompressed version.
Tested on Windows 7 64bit, Windows 2008 32bit and Windows 2008 R2 64bit

The script expects that you create your logfiles with "%Y_%m_%d" as your date string. So your CustomLog setting in httpd.conf should look like this
CustomLog "| C:/Apache24/bin/rotatelogs.exe  -l C:/Apache24/logs/access-%Y_%m_%d.log 86400" combined
ErrorLog "| C:/Apache24/bin/rotatelogs.exe  -l C:/Apache24/logs/error-%Y_%m_%d.log 86400"

The script can be used from command line or executed as a Windows task.
* compress all .log files in the same directory
 wscript compress.vbs .log
 * compress all .log files in C:\foo\bar
 wscript compress.vbs .log "c:\foo\bar"
 * compress all .log files in C:\foo\bar and store them in c:\logstore
 wscript compress.vbs .log "c:\foo\bar" "c:\logstore"

Usage Windows task:
Use the following settings and everything should work properly.
Script: C:\Windows\System32\wscript.exe
Arguments: compress.vbs .log "C:\Apache24\logs" "D:\Logs\httpd"
Start in: D:\Logs\compress (location of compress.vbs)

The script supports the following to make configuration simpler.
* any errors will be written to "compress_errors.log"
* set "log_commands" to true to log all the executed 7Zip commands
* set "msgbox_on_error" to true to get visual feedback when an error occurs but don't forget to turn this off for background tasks
* set "keep_files" to true to keep the files after 7Zip compressed them
* the script will automatically exlude todays error and access log (by filename) and add it to "exclude_files"



(will not be posted but I may reply)

Image CAPTCHA, please select the image representing a/an: arrow