19 September
2022
Customizing Apache default access log
After installing Apache I like to immediately customize the default access log. I change the default log file from other_vhosts_access.log to access.log, and I disable logging of specific “status” check URLs. Note I’m working on Ubuntu, other distros could have different file names and paths.
1 2 3 4 5 |
# don't log status checks SetEnvIf Request_URI "^/status\.php.*" dontlog SetEnvIf Request_URI "^/server-status" dontlog # Define an access log for VirtualHosts that don't define their own logfile CustomLog ${APACHE_LOG_DIR}/access.log vhost_combined env=!dontlog |
Finish up by deleting any existing “other_vhosts_access.log” log files, making sure other-vhosts-access-log is enabled, and restarting apache:
1 2 3 |
rm /var/log/apache2/other_vhosts_access.log* a2enconf other-vhosts-access-log service apache2 restart |