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

link|improve this question

33% accept rate
1  
Which operating system are you using ? – Iain Feb 8 at 9:27
feedback

3 Answers

up vote 1 down vote accepted

use logrotate

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

link|improve this answer
1  
this should be put into your vhost file in sites-enabled of your apache config dir – mlaug Feb 8 at 9:45
1  
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 at 10:00
feedback

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

link|improve this answer
You can also use rsyslog instead of syslog-ng. – Ladadadada Feb 8 at 10:01
feedback

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
}
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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