Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

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.

share|improve this answer
    
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 9:00
2  
If 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 9:41
1  
Also, 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
    
@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

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.