How to modify Apache httpd logging

Solution Verified - Updated

Environment

  • Red Hat Enterprise Linux (RHEL)
  • Red Hat Software Collections (RHSCL)
  • Red Hat JBoss Web Server (JWS)
  • Red Hat JBoss Core Services (JBCS)
  • Apache Web Server (httpd)

Issue

  • How to increase logging level to debug apache issues
  • How to reduce the verbosity of the Apache httpd log
  • How to customize log level per module
  • How to customize log level per directory
  • How to enable SSL debug in Apache httpd
  • We have some servers dedicated to providing Apache httpd services and we do not need the logging that is produced in the file /var/log/httpd/*. What is the recommended way to tune the httpd.conf file to reduce this logging to little or none at all?

Resolution

  • Edit httpd.conf file and modify the Content from httpd.apache.org is not included.LogLevel to tune the verbosity of error_log.

    • From least verbose to most verbose: emerg, alert, crit, error, warn, notice, info, or debug. And there's additional verbose log levels from trace1 to trace8 in Apache httpd 2.4. It defaults to warn.
    • Note: the level notice cannot be suppressed regardless of the LogLevel setting as noted in Apache's documentation.
  • For example, to enable debug logging change from:

    LogLevel warn
    

    to:

    LogLevel debug
    

    in httpd.conf. Then restart the httpd service:

    ]# service httpd restart
    
  • Similarly, for Apache httpd 2.4.x the log level can be defined per module and also per directory:

    LogLevel info ssl:debug proxy:trace8 proxy_ajp:trace8 
    
    LogLevel info
    <Directory "/var/www/html/myapp">
      LogLevel debug
    </Directory>
    
  • Afterwards, to supply those logs to Red Hat Support, command sosreport can be run with the apache option.

    ]# sosreport -k apache.log=on
    
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.