What are pros and cons of logrotate vs rotatelogs with Apache?

Apache provides a tool called rotatelogs which has the benefit of not restarting apache when rotating logs which happens with logrotate. I do not have enough experience to speak if this is enough criteria to use rotatelogs over logrotate.

My questions is does anyone have real life experience using either or of these two tools and what were your input would be?

What would you recommend and why?


I would recommend logrotate for most people since that is what will be rotating all the other logs (KISS: Keep it Simple Stupid). Logrotate doesn't restart all of Apache, rather it just sends it a signal that tells it to reopen all of it's log files and restart children. This signal can be SIGHUP, which causes the children to restart right away (which will interrupt downloads), or SIGUSR1, which does a graceful restart. With SIGUSR1, you have to delay the log processing until you think all the children would have died naturally. Either way, you probably want to analyze your logs, and time it for the lowest traffic period in the day or week.

Piped logs seems like it is the more powerful solution. A big advantage being that it will allow you to use a centralized logging system and take load of the web server itself. The manual itself says:

As with conditional logging, piped logs are a very powerful tool, but they should not be used where a simpler solution like off-line post-processing is available.

So apparently, don't use piped logging if you don't need it. I have used piped loging in the past as a hacky way to filter logs, and had no problem.


I've used both before. I found that using rotatelogs is a very useful tool in managing access logs and if you don't want apache downtime. On a high volume site I would recommend this, the only Issue I found was that if you want to manage the logs you will need to have a separate script cron'd to either clean up or move the logs to a backup server, obviously this depends on the requirement. With logrotate you do have more options with how logfiles are handled, the only issue is when logrotate runs as explained in the previous answer, you will need to restart apache.

Basically it all comes down to choice, if you need apache to running without interruptions then rotatelogs with a external cron script to manage, else logrotate will suffice. Just be sure to setup the logrotate cron not to rotate the logs when you have high traffic.

Lastly if you want to have apache log to your syslog you can always use the logger command which is on Redhat Based linuxes.