0

access_log seems to be permanently size 0. But error_log is written to fine.

Surprisingly access_log.[1-5].gz are created but only access_log.3.gz and access_log.4.gz contain non-empty logs.

Ok, so here is the logrotate.conf that is also in the logfiles directory:

# create new (empty) log files after rotating old ones
create

# compress old logs with gzip
compress

/home/default/example.com/user/logfiles/access_log {
        missingok
        rotate 5
        daily
        postrotate
                /usr/bin/killall -HUP syslogd
        endscript
}

/home/default/example.com/user/logfiles/error_log {
        missingok
        rotate 5
        size=5M
        postrotate
                /bin/kill -USR1 `cat /var/run/httpd.pid`
        endscript
}

/home/default/example.com/user/logfiles/agent_log {
        missingok
        rotate 5
        size=5M
        postrotate
                /bin/kill -USR1 `cat /var/run/httpd.pid`
        endscript
}

/home/default/example.com/user/logfiles/referer_log {
        missingok
        rotate 5
        size=5M
        postrotate
                /bin/kill -USR1 `cat /var/run/httpd.pid`
        endscript
}

There are no agent_log, referer_log files though. So is there something obviously wrong with this logrotate.conf? If not, how do I even know if this file is being used or is the problem? I can post more info if needed.

The server is Ubuntu 8.10 by the way.

Update: htttd.pid doesn't even exist.

ubuntu:~# cat /var/run/httpd.pid  
cat: /var/run/httpd.pid: No such file or directory
Tom Viner
  • 101
  • 2

2 Answers2

3

Your postrotate is set to restart syslogd. I believe you need to do that to httpd.

Kevin M
  • 2,312
  • 1
  • 16
  • 21
  • I just restarted apache (/etc/init.d/apache2 restart) and the access_log started to receive log lines. What is the command to restart httpd from logrotate? – Tom Viner Jul 09 '10 at 16:40
  • To restart Apache from the command line without aborting open connections, use the command "/usr/sbin/apachectl graceful". According to the apachectl manpage, it "[g]racefully restarts the Apache httpd daemon. If the daemon is not running, it is started. This differs from a normal restart in that currently open connections are not aborted." – Kevin M Jul 10 '10 at 16:59
  • I don't seem to have have apachectl on my system. I restart apache as I mentioned above. Again today the logs were actually writing to name_log.1 but restarting apache fixed this. So I'm adding the "/bin/kill -USR1 `cat /var/run/httpd.pid`" line to the access_log section in logrotate.conf. – Tom Viner Jul 12 '10 at 08:57
0

Have you checked your Apache settings? Logrotate just rotates log files, it doesn't write to them. So if your log files are missing content then you should start by looking at your Apache settings.

Martin
  • 490
  • 2
  • 5
  • I've checked the apache settings and they are fine. I've now added agent_log & referer_log, which are being written fine. – Tom Viner Jul 09 '10 at 16:38