Is there any mod or program for Apache Httpd which rotate logs as well as purge them without the restarting of server processes? I have checked a few options, mod_autorotate, rotatelogs, mod_log_rotate and cronologs. Scratched out mod_autorotate because of the server restarts everytime log needs to be rotated. Scratched out mod_log_rotate, rotatelogs and cronologs because they don't have purging capabilities. I'm not entirely sure if I can use "logrotate" because it involves cron jobs, and it impossible for me to schedule cron jobs for a lot of Apache servers with a lot of applications running on them.
Asked
Active
Viewed 1,066 times
2 Answers
5
The standard logrotate
is what everyone uses for this. Just because it uses cronjobs doesn't mean that applications go down whenever the rotate happens. Logrotate uses a graceful apache restart, thereby eliminating any downtime due to the log rotation.

EEAA
- 109,363
- 18
- 175
- 245
-
Thanks ErikA. But I'm afraid it doesn't solve my problem. Just to give a context, imagine having multiple users in multiple groups running multiple Apache servers (I'm talking like having atleast 200 Apache servers running). Leaving alone the fact that there is no way for me to setup cronjobs for each of these servers, I think it is also highly inefficient to do so. That's why I'm looking for a module or a program which I can specify in my **httpd.conf** file so that rotation and purging is taken care off with a single program. – latestVersion Feb 14 '12 at 09:00
-
3If you have 200 servers of any sort and you aren't using some form of configuration management like Chef or Puppet, you are doing it wrong. – ThatGraemeGuy Feb 14 '12 at 09:41
-
1Also, the on some Linux flavors (e.g., Ubuntu for sure) the Apache package brings its own config file for logrotate's config directory. It has a wildcard rule that basically says, "rotate any/all of my logs". So as you add more apache processes, or vhosts, etc, it's just that one log rotate rule. And it uses logrotate's sharedscripts option so it's just one Apache "graceful" signal after logrotate moves all the files. – Craig Constantine Feb 14 '12 at 15:53
-
I would like to add that graceful apache restart is out of the question as this will be in production environment and I don't want even a little bit of downtime. It's a very tough criteria that I have here and I know that the solutions you guys have suggested will indeed work but just not in my scenario. – latestVersion Feb 15 '12 at 14:28
-
1@latestVersion - you need to do your research if you don't trust what I'm saying. The type of reload used by logrotate (`/etc/init.d/apache2 reload`) **does not** cause downtime. Not even a tiny little bit. – EEAA Feb 15 '12 at 16:01
-
Thanks ErikA. I wasn't aware graceful restarts work that way. If that's the case, it would really help out to hear your views on this module called "mod_autorotate" [link](http://www.poptart.org/bin/view/Poptart/ModAutorotate) – latestVersion Feb 21 '12 at 08:33
-
I've never used it nor heard of it. – EEAA Feb 21 '12 at 13:11
1
If you use syslog-ng or rsyslog there is no need for even a graceful restart or a HUP of Apache.
As soon as logrotate moves the old file, syslog-ng will create a new one. I like to have the date injected into the filename: web-$YEAR-$MONTH-$DAY.log
Some other nice advantages of these syslog-type programs are that you can stream the logs off to another server and you can combine the logs from many web servers into a single file on the logging server.

Ladadadada
- 26,337
- 7
- 59
- 90