2

On my webserver I have this file: /etc/logrotate.d/apache2

I know it is logrotating /var/log/apache2/.log, but if I want to add things that are in /usr/home/www/site1/logs/.log do I just duplicate everything below and stick that line in there? Each time I add a new site do I need to manually add lines to this file?

Or what is the most professional way to do this?

/var/log/apache2/*.log {
    weekly
    missingok
    rotate 52
    compress
    delaycompress
    notifempty
    create 640 root adm
    sharedscripts
    postrotate
        if [ -f "`. /etc/apache2/envvars ; echo ${APACHE_PID_FILE:-/var/run/apache2.pid}`" ]; then
            /etc/init.d/apache2 reload > /dev/null
        fi
    endscript
}
cwd
  • 2,763
  • 9
  • 33
  • 48

1 Answers1

4

How about:

/var/log/apache2/*.log /usr/home/www/*/logs/*.log {
  weekly    
  .
  .
  .
}

In other words, just list all the paths you need, separated by spaces. Logrotate will then check all the paths. By the way you can also test your config as noted here with the debug option -d:

logrotate -d /path/to/config

In the output it will list all the files it checks:

considering log /var/log/nginx/access.log
  log does not need rotating
dmourati
  • 25,540
  • 2
  • 42
  • 72
  • I like the wildcards - that should work. What about the other options - I guess I'm also asking: What are the standard {professional grade} options for apache access and error logs? – cwd Jun 24 '11 at 00:28
  • The question of what is "most professional" is hard to answer, because (a) it's ultimately an opinion question and (b) it really depends on your environment. Your solutions are going to be very different if you have hundreds of servers, or if you your server logs are covered by some sort of regulatory compliance (or company policy). – larsks Aug 01 '13 at 14:51