Best way to rotate Apache log files [closed] Best way to rotate Apache log files [closed] apache apache

Best way to rotate Apache log files [closed]


Have you looked at logrotate - this is probably the simplest, most widely available and well understood method of achieving this. It is highly configurable and will probably do 90% of what you need.


I'm a big fan of Cronolog. Just install and pipe your logs through it. For daily log rotation, something like this would work:

ErrorLog  "|/usr/bin/cronolog /path/to/logs/%Y-%m-%d/error.log"CustomLog "|/usr/bin/cronolog /path/to/logs/%Y-%m-%d/access.log" combined

Pretty handy, and once installed, easier (in my experience) than logrotate.


The actual command for Windows, which is quite difficult to find online is:

CustomLog '|" "*Apache-Path/bin/rotatelogs.exe"     "**Apache-Path*/logs/backup/internet_access_%d-%m-%y.log" 86400' combined

Where the "internet_access" bit is the name you choose for your files, the 86400 is the number of seconds in one day. You need to change the Apache-Path to the relevant directory you've installed Apache to.