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.

Steps to log more verbosely for Apache:

  1. Open the terminal on your server.
  2. Search for LogLevel directive in Apache's configuration files.

    $ sudo grep -nr ^LogLevel /etc/{httpd,apache2}/
    grep: /etc/httpd/: No such file or directory
    /etc/apache2/apache2.conf:143:LogLevel warn
  3. Open the Apache configuration file using your preferred text editor.

    $ sudo /etc/apache2/apache2.conf
  4. Change the LogLevel value to a more verbose option.

    LogLevel debug

    Options range from emerg, alert, crit, error, warn, notice, info, to debug. The debug level logs the most information.

  5. Save the file and exit the text editor.
  6. Search for LogFormat directive in Apache's configuration files.

    $ 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
  7. Open the Apache configuration file using your preferred text editor.

    $ sudo /etc/apache2/apache2.conf
  8. Customize the LogFormat directives as required.

    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.

  9. Save the file and exit the text editor.
  10. Restart Apache to apply the changes.

    $ sudo systemctl restart apache2 # Ubuntu, Debian
    $ sudo systemctl restart httpd # CentOS, Red Hat
  11. Monitor the Apache logs to view the verbose output.

    $ tail -f /var/log/apache2/error.log # Ubuntu, Debian
    $ tail -f /var/log/httpd/error_log # CentOS, Red Hat