Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
1  
Which operating system are you using ? –  Iain Feb 8 '12 at 9:27

3 Answers 3

up vote 2 down vote accepted

use rotatelogs

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

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

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

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

share|improve this answer
1  
You can also use rsyslog instead of syslog-ng. –  Ladadadada Feb 8 '12 at 10:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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