1

Trying to add the %D and %T format string to my Apache log to see time for request processing but apparently not able to. Here are the LogFormat directives in my httpd.conf

[root@server01 admin_ad2]# grep LogFormat /etc/httpd/conf/httpd.conf
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
[root@server01 admin_ad2]# httpd -v
Server version: Apache/2.4.6 (Red Hat Enterprise Linux)
Server built:   May 28 2018 16:19:32

Adding the format string a shown below and restarting the Apache service does not have any affect - still can't see the value in my /var/log/httpd/ssl_access_log

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" **%T/%D**" combined

What am I doing wrong ?

  • 1
    On RHEL, the httpd SSL configuration should be defined in a separate .conf file that also specifies log settings. Can you take a look inside the conf.d directory? – Haxiel Jan 17 at 6:49
  • @Haxiel Makes sense. So the LogFormat directive is not inherited from the main configuration file ? How would I declare it in ssl.conf? can't see any LogFormat directive in there .... – blabla_trace Jan 17 at 7:25
  • 1
    The RPM I have shows a TransferLog directive for ssl_access_log. The linked page shows an example on how to define LogFormat for that directive. – Haxiel Jan 17 at 7:34
  • Thank you indeed it seams to work :) Please create an answer so that I can accept it for you :)! BTW do you know how would I convert the value in microseconds 18/18695953 to seconds ? – blabla_trace Jan 17 at 7:56
  • I've added my answer :-). I didn't quite understand your question about converting the time value. Can you please clarify that with a little more detail? – Haxiel Jan 17 at 9:14
1

The RHEL version of Apache HTTP server defines the SSL configuration in a separate configuration file, which is located at /etc/httpd/conf.d/ssl.conf.

This configuration file also defines the log file for the SSL virtual host using the TransferLog directive:

# Use separate log files for the SSL virtual host; note that LogLevel
# is not inherited from httpd.conf.
ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
LogLevel warn

The TransferLog directive uses the log format defined by the most recent LogFormat directive, which does not have a nickname. As a result, the format can be controlled by defining it just prior to the TransferLog directive:

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" **%T/%D**"
TransferLog /var/log/httpd/ssl_access_log

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.