8:52 - Saturday, 19 April 2014

Apache Log Files Getting Too Big , How Do I Make It Save On A Per-day Basis

#Topics: apache log too big,apache logs too big,log files apache too big

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

use rotatelogs

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

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

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}