Skip to main content

Customizing the Request Log

You can customize the content of the request log file by adding configuration entries under the request_log key in the IBM Application Gateway (IAG) configuration file. The syntax is as follows:

logging:
  request_log:
    file_name: "<path to log file>"
    format: "<directives>"

The following directives can be used to customize the log format:

Directive                       Description
%a Remote IP address
%A Local IP address
%b Bytes in the response excluding HTTP headers in CLF format: '-' instead of 0 when no bytes are returned.
%B Bytes in the response excluding HTTP headers
%{Attribute}C Attribute from the user credential named 'Attribute'
%d Transaction identifier, or session sequence number
%F Time that it takes to serve the request in microseconds
%h Remote host
%H Request protocol
%{header-name}i Contents of the Header 'header-name' in the request
%j The name of the junction that services the request
%J The length of time, in microseconds, that the junction server spent processing the request. This includes the time that it took to send the request to the server, the length of time that it took the server to process the request, and the length of time that it took to read and process the response header.
%l Remote logname
%m Request method (that is, GET, POST, HEAD)
%{header-name}o Contents of the Header 'header-name' in the response
%p Port over which the request was received
%q The query string (prefixed with '?' or empty)
%Q Raw query strings that must be decoded manually.
%r First line of the request
%R First line of the request including HTTP://HOSTNAME
%s Response status
%t Time and date in CLF format
%{format}t The time and date in the specified format
%T Time that it takes to serve the request in seconds
%u Remote user
%U The URL requested
%v Canonical ServerName of the server that serves the request
%{cookie-name}e Contents of the cookie 'cookie-name' in the request
%{cookie-name}E Contents of the cookie 'cookie-name' in the response

The following configuration entry shows an example of customizing the request.log file:

logging:
  request_log
    file_name: "/tmp/var/request.log"
    format: "%h %l %u %t '%r' %s %b"

Customized HTTP logs also support the new line '\n', carriage return '\r', and tab '\t' special characters. Any character that is either not part of a directive or not a special character is written out in the log entry. You can direct the system to ignore the '%' and '\' characters by prefixing them with the backslash '\' character.

For example:

    format: "\%{header}i\t->\t%{header}i"

renders the following output:

	%{header}i  ->  header