Apache Better Log Rotation mod_log_rotate
Important: The Apache provided tool rotatelogs.exe is to buggy to use "for real", see: Apache Rotatelogs.exe for Windows Server
Using the module mod_log_rotate, the log rotation is handled by the server process so you save on the process count and file descriptors. I've compiled that code for windows using VC++ 6 for Apache 2.0.x and Apache 2.2.x. You can find the windows binaries of mod_log_rotate at the bottom of this article.
If you want to keep the names simple rename the downloaded file without the Apache version number it was compiled for like (mod_log_rotate.dll or mod_log_rotate.so). I made a dll version (mod_log_rotate.dll) and a dynamic Apache module version (mod_log_rotate.so). I use both versions on different Apache instances on the same server. If you have limited resource or very high traffic you might see a difference in performance. Please let me know any metric, if you experience real noticeable differences between the .dll and .so. The theory is the mod_log_rotate.dll might take a little more RAM but might be faster (load + runtime?).
To load this module, modify your httpd.conf:
LoadModule log_rotate_module modules/mod_log_rotate.so
#or if using the DLL version
LoadModule log_rotate_module modules/mod_log_rotate.dll
#Add the following line to use the module
The directive for your individual sites custom logs, will not change:
CustomLog "E:/DomZeus/123test/W3SVC1383061124/ex.log" combined
Your log file will be in the format: ex.log.1140048000
The numeral is the number of seconds since: 01-01-1970
To translate that number into a date, the equation is: 01-01-1970 + 1140048000 seconds
Enable / disable automatic log rotation. Note: On Apache 2, once enabled mod_log_rotate takes responsibility for all log output server wide even if RotateLogs Off is subsequently used. That means that the BufferedLogs directive that is implemented by mod_log_config will be ignored. As BufferedLogs isn’t document and is flagged as an experimental feature this shouldn’t be a problem in production environments. This doesn’t apply to the Apache 1.3 version of the module.
Normally the log rotation interval is based on UTC. For example an interval of 86400 (one day) will cause the logs to rotate at UTC 00:00. When this option is on, log rotation is timed relative to the local time.
RotateInterval <interval> [<offset>]
Set the interval in seconds for log rotation. The default is 86400 (one day). The shortest interval that can be specified is 60 seconds. An optional second argument specifies an offset in minutes which is applied to UTC (or local time if RotateLogsLocalTime is on). For example RotateInterval 86400 60 will cause logs to be rotated at 23:00 UTC.