Entries tagged Apache

How to rotate Apache logs on Windows

Posted on Apr 15, 2009

Rotating Apache logs files on Windows platform is not so much different from doing it on Linux or other Unix. There are just two things to remember. First, the name of the utility provided for this purpose is “rotatelogs.exe” instead of just “rotatelogs”. It is in the “bin” directory of the Apache installation path. Plus, if your Apache installation path contains any space as in “C:/Program Files/Apache2”, you need to put the escape character, “\” (backslash) before and after the path string. (Note that you must use forward slashes within path strings where filenames are specified.)

The following is an example of rotating log files every seventh day. “ErrorLog” directive seems to require a full path, but somehow “CustomLog” does not.

ErrorLog “|\”C:/Program Files/Apache2/bin/rotatelogs.exe\” \”C:/Program Files/Apache2/logs/error.%Y%m%d.log\” 604800″

<IfModule log_config_module>

CustomLog “|bin/rotatelogs.exe logs/access.%Y%m%d.log 604800” common

</IfModule>