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:
      file_name: "<path to log file>"
    format: "<directives>"

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

Directive                      Description
%aRemote IP address
%ALocal IP address
%bBytes in the response excluding HTTP headers in CLF format: '-' instead of 0 when no bytes are returned.
%BBytes in the response excluding HTTP headers
%{Attribute}CAttribute from the user credential named 'Attribute'
%dTransaction identifier, or session sequence number
%FTime that it takes to serve the request in microseconds
%hRemote host
%HRequest protocol
%{header-name}iContents of the Header 'header-name' in the request
%jThe name of the junction that services the request
%JThe 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.
%lRemote log name
%mRequest method (that is, GET, POST, HEAD)
%{header-name}oContents of the Header 'header-name' in the response
%pPort over which the request was received
%qThe query string (prefixed with '?' or empty)
%QRaw query strings that must be decoded manually.
%rFirst line of the request
%RFirst line of the request including HTTP://HOSTNAME
%sResponse status
%tTime and date in CLF format
%{format}tThe time and date in the specified format
%TTime that it takes to serve the request in seconds
%uRemote user
%UThe URL requested
%vCanonical ServerName of the server that serves the request
%{cookie-name}eContents of the cookie 'cookie-name' in the request
%{cookie-name}EContents 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:
      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 

Did this page help you?