Apache Logfiles

Some receipes how to tune or rotate Apache logfiles

Conditional Logging

To exclude something not to be logged in your apache access (or error) log can be achieved like so:

SetEnvIf Request_URI "^/favicon\.ico$" special
SetEnvIf Request_URI "something.html" special
 
# no logging:
CustomLog /var/log/httpd/local-access.log combined env=!special
 
# explicit logging:
CustomLog /var/log/httpd/local-special.log combined env=special

This will exclude the given Request_URI from your main log and send them to the special log instead.

logrotate

The standard logfiles will be handled by logrotate:

/etc/logrotate.d/apache

/usr/local/apache/current/logs/access_log
/usr/local/apache/current/logs/error_log
/usr/local/apache/current/ssl_engine_log
/usr/local/apache/current/ssl_scache.pag {
        rotate 3
        compress
        missingok
        size 15M
        postrotate
                /usr/bin/killall -HUP /usr/local/apache/current/bin/httpd
        endscript
}

What you will find at Debian with apache2 installed:

/var/log/apache2/*.log {
        weekly
        missingok
        rotate 52
        compress
        delaycompress
        notifempty
        create 640 root adm
        sharedscripts
        postrotate
                if [ -f /var/run/apache2.pid ]; then
                        /etc/init.d/apache2 restart > /dev/null
                fi
        endscript
}
apache/logfiles.txt · Last modified: 2014-12 by tb
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0 ipv6 ready