4

Apache combined log files are getting too large each day in a single file, it is hitting over hundreds megabytes,

Which is a quick way or how can i configure to store files per day basis?

Will this work ?

CustomLog "|/usr/sbin/rotatelogs -l /var/log/httpd/access.log.%Y-%m-%d 2419200"

operating on LINUX

4

use rotatelogs

CustomLog "|/usr/sbin/rotatelogs PATH_TO_LOG_DIR/access_log.%Y%m%d 86400 -360" common

  • 2
    this should be put into your vhost file in sites-enabled of your apache config dir – mlaug Feb 8 '12 at 9:45
  • 2
    That's rotatelogs, not logrotate. logrotate is usually run from a cron job and rotates existing logs. The config directory is /etc/logrotate.d/. – Ladadadada Feb 8 '12 at 10:00
3

As you are using linux, you can use the logrotate. Something like this which is lifted from an Ubuntu system I have handy but note you'll probably need to modify it for other distributions.

/var/log/apache2/*.log {
        daily
        missingok
        rotate 7
        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
}
2

If you are using Linux then logrotate. Or you can log to a remote server directly for example with syslog-ng.

  • 1
    You can also use rsyslog instead of syslog-ng. – Ladadadada Feb 8 '12 at 10:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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