IBM Support

HTTP message logging

News


Abstract

HTTP message logging logs the messages that are being exchanged between web service clients and the web services server.

Content

What is it?

HTTP message logging logs the messages that are being exchanged between web service clients and the web services server.  You can enable message logging in the IWS server by navigating to the Web Services tab as follows: Server Properties -> Logging, then selecting the Web Services tab as shown in the following figure:
image 12634
All messages are written to messages.log. Content data in the request or response is logged only if the content media type indicates that the data is JSON, XML, text, or form data. For all other media types, the value 'NOT-LOGGED-CONTENT' corresponding to the content field in the log record will be used.
  • Message format: The format used when logging client requests and server responses. Valid values are SIMPLE or JSON format. The SIMPLE format does not add quotation marks around field names and does not encode the content data if it is not JSON.
  • Multi-line logging: When message logging is enabled, the log record includes such fields as timestamp, host, and remote address, in addition to the content in the client request or server response. This data can be logged over multiple lines (one field per line) or on a single line.
  • Log response: Indicates whether the response should be logged or not.
  • Content limit: The maximum size of the content to log. If a message exceeds the size, the message is not logged. A value of -1 (*NOMAX) indicates that there is no limit. A value of zero indicates that the content should not be logged. When the content is not logged because the size exceeds the specified limit, you will see a value of 'NOT-LOGGED-SIZE' corresponding to the content field in the log record.
  • HTTP header filter: A list of comma-delimited HTTP headers for which the values will not be logged. If the header has a value, it will be replaced by the following string: 'REDACTED'. A value of '*NONE' indicates that all HTTP headers are to be logged without modification. A value of '*ALL' indicates that HTTP headers are not to be logged. Note that HTTP headers are case-insensitive. The filter may contain generic names. A generic name is a character string that contains one or more characters followed by an asterisk (*). If a generic name is specified, all headers that have names with the same prefix as the generic name will not be logged.
  • HTTP parameter filter: A list of comma-delimited HTTP parameters for which the values will not be logged. HTTP parameters include query string parameters and form parameters and are case-sensitive unless the Case-sensitive filter is set to false. If the HTTP parameter has a value, it will be replaced by the following string: 'REDACTED'. A value of '*NONE' indicates that all HTTP parameters are to be logged without modification. A value of '*ALL' indicates that HTTP parameters are not to be logged. In addition, if the client request contains query string data or form data and the HTTP parameter filter is set to not log HTTP parameters, the value 'NOT-LOGGED-REDACTED' corresponding to the content field and query string field in the log record will be used. The filter may contain generic names. A generic name is a character string that contains one or more characters followed by an asterisk (*). If a generic name is specified, all parameters that have names with the same prefix as the generic name will not be logged.
  • Case-sensitive filter: Specify whether HTTP parameter names should be treated as case-sensitive or not case-sensitive when HTTP parameter filtering is performed.
  • Select services for message logging: Select the web services for which messages will be logged.
The following examples show sample output in each of the available message formats: SIMPLE, and JSON. Each of the sample output includes a request and a response.
SIMPLE request
{
type: liberty_ibmihttpmessagelog,
host: HOST52P12,
ibm_flow: request,
ibm_datetime: 2022-03-27T19:36:59.338,
ibm_correlation: 0000000008052_1648427819337,
ibm_remoteIP: 10.10.220.148,
ibm_remoteUserID: null,
ibm_requestMethod: GET,
ibm_requestHost: HOST52P12.ibm.com,
ibm_requestPort: 10000,
ibm_uriPath: /web/services/QIWSSAMPLE,
ibm_queryString: null,
ibm_contentType: null,
ibm_headers: { 
  Accept: ["text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"], 
  Accept-Encoding: ["gzip, deflate"], 
  Accept-Language: ["en-US,en;q=0.9"], 
  Connection: ["keep-alive"], 
  Cookie: ["REDACTED"], 
  Host: ["HOST52P12.ibm.com:10000"], 
  Upgrade-Insecure-Requests: ["1"], 
  User-Agent: ["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Safari/605.1.15"]
},
ibm_messageBodyLength: 0,
ibm_messageBody: null
}
SIMPLE response
{
type: liberty_ibmihttpmessagelog,
host: HOST52P12,
ibm_flow: response,
ibm_datetime: 2022-03-27T19:36:59.343,
ibm_correlation: 0000000008052_1648427819337,
ibm_contentType: application/json;charset=utf-8,
ibm_headers: { 
  Content-Type: ["application/json;charset=utf-8"]
},
ibm_responseCode: 200,
ibm_messageBodyLength: 19,
ibm_messageBody: {"TEMPOUT":"-4.99"}
}
JSON request
{
"type": "liberty_ibmihttpmessagelog",
"host": "HOST52P12",
"ibm_flow": "request",
"ibm_datetime": "2022-03-27T19:49:47.527",
"ibm_correlation": "0000000000071_1648428587509",
"ibm_remoteIP": "10.10.220.148",
"ibm_remoteUserID": null,
"ibm_requestMethod": "GET",
"ibm_requestHost": "HOST52P12.ibm.com",
"ibm_requestPort": "10000",
"ibm_uriPath": "/web/services/QIWSSAMPLE",
"ibm_queryString": null,
"ibm_contentType": null,
"ibm_headers": { 
  "Accept": ["text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"], 
  "Accept-Encoding": ["gzip, deflate"], 
  "Accept-Language": ["en-US,en;q=0.9"], 
  "Connection": ["keep-alive"], 
  "Cookie": ["REDACTED"], 
  "Host": ["HOST52P12.ibm.com:10000"], 
  "Upgrade-Insecure-Requests": ["1"], 
  "User-Agent": ["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Safari/605.1.15"]
},
"ibm_messageBodyLength": 0,
"ibm_messageBody": null
}
JSON response
{
"type": "liberty_ibmihttpmessagelog",
"host": "HOST52P12",
"ibm_flow": "response",
"ibm_datetime": "2022-03-27T19:49:48.147",
"ibm_correlation": "0000000000071_1648428587509",
"ibm_contentType": "application/json;charset=utf-8",
"ibm_headers": { 
  "Content-Type": ["application/json;charset=utf-8"]
},
"ibm_responseCode": 200,
"ibm_messageBodyLength": 19,
"ibm_messageBody": "{\"TEMPOUT\":\"-4.99\"}"
}
If you enable JSON message formatting for the application server as described in Server JSON logging and you enable JSON message formatting for web services, you must set the mult-line logging property to false in order for the JSON log record to be logged without modification.  Otherwise, the message log record will be embedded in a liberty_message event. 

Why use it?

Logs are granular, timestamped, complete, and immutable records of application events that can be used for troubleshooting and debugging purposes.
 
HTTP message logging records information about all requests handled by a web service.  The logs can be used as a mechanism to verify transactions or as an audit record.
 
Logs can also be used to detect API problems, performance or otherwise.  Finally, and most importantly, logging allows one to backtrack and do forensic analysis when an intrusion is detected.
 

Availability

The support is enabled in the following HTTP group PTFs and PTFs:

V7R3M0 SF99722 Level 38
V7R4M0 SF99662 Level 19

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"HW1A1","label":"IBM Power Systems"},"Component":"","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"All Versions","Edition":"","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]

Document Information

Modified date:
27 March 2022

UID

ibm16566799