Httpd – Disable log rotation for apache or move file location

apache-2.2httpdlogging

I need to change the log retention for apache, currently is seems to be running on the default from logrotate.conf which is weekly. It creates 'access_log.1' 'access_log.2' and so on for each week.
The problem is it deletes the last log file every week, 'access_log.5', I need the logs to keep going infinitely instead of the last log being deleted every week.
It seems to be running on the default value from logrotate.conf – I don't want to change the default values held in that file, so I assume there is a way to change the retention using the /etc/logrotate.d/httpd file?

the contents are as follows:

/var/log/httpd/*log {
    missingok
    notifempty
    sharedscripts
    postrotate
        /sbin/service httpd reload > /dev/null 2>/dev/null || true
    endscript
}

what can I add/change to stop the last log being deleted every week?

Best Answer

You would need to add the rotate {value} option to tell logrotate how many copies to keep. The below will keep 52 copies.

/var/log/httpd/*log {
    missingok
    rotate 52
    notifempty
    sharedscripts
    postrotate
    /sbin/service httpd reload > /dev/null 2>/dev/null || true
    endscript
}
Related Topic