Apache web server is a versatile platform serving millions of websites. Its efficiency and effectiveness often depend on proper tuning and understanding its behavior. To troubleshoot issues or optimize performance, you may need to delve into Apache's log files.
By default, Apache logs information related to client requests, server responses, and various events. However, you might sometimes need to increase the verbosity of these logs to gain more insights into the server's operation.
Verbose logging provides more detailed information and helps in understanding what exactly is happening within the Apache server. It's particularly useful when troubleshooting intricate issues that require insights into specific request and response headers, connection errors, or other granular details.
Verbose logging can quickly fill up disk space and may affect performance. It's generally recommended to use verbose logging temporarily and revert to normal levels once you have obtained the necessary information.
$ sudo grep -nr ^LogLevel /etc/{httpd,apache2}/ grep: /etc/httpd/: No such file or directory /etc/apache2/apache2.conf:143:LogLevel warn
Related: Location for Apache configuration
$ sudo /etc/apache2/apache2.conf
LogLevel debug
Options range from emerg, alert, crit, error, warn, notice, info, to debug. The debug level logs the most information.
$ sudo grep -nr ^LogFormat /etc/{httpd,apache2}/ grep: /etc/httpd/: No such file or directory /etc/apache2/apache2.conf:212:LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined /etc/apache2/apache2.conf:213:LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined /etc/apache2/apache2.conf:214:LogFormat "%h %l %u %t \"%r\" %>s %O" common /etc/apache2/apache2.conf:215:LogFormat "%{Referer}i -> %U" referer /etc/apache2/apache2.conf:216:LogFormat "%{User-agent}i" agent </WRAP> LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-agent}i"" combined CustomLog ${APACHE_LOG_DIR}/access.log combined
$ sudo /etc/apache2/apache2.conf
Related: LogFormat string reference
The word at the end of the LogFormat directives (common, combined, vhost_combined, etc.) are nicknames for the format strings. These nicknames can be used in the CustomLog directive for your VirtualHost to specify which format to use when logging.
$ sudo systemctl restart apache2 # Ubuntu, Debian $ sudo systemctl restart httpd # CentOS, Red Hat
$ tail -f /var/log/apache2/error.log # Ubuntu, Debian $ tail -f /var/log/httpd/error_log # CentOS, Red Hat
Comment anonymously. Login not required.