How to configure traffic log to save request-response in APIM Gateway?
search cancel

How to configure traffic log to save request-response in APIM Gateway?

book

Article ID: 113615

calendar_today

Updated On:

Products

CA API Gateway

Issue/Introduction

The request/response is not saved by default. In some cases, it's required to save the request/response for certain purposes, such as debugging, auditing, etc.

There are a few ways to save requests/responses, by using the "Audit Messages in Policy" assertion and selecting Always save request/response, or using the "Add Audit Detail" assertion to save ${request.mainpart}/${response.mainpart}.

Environment

All supported versions of the API Gateway

Resolution

Here is an example of how to configure a traffic log sink to save a request/response to a log file.

1. Add a new log sink for the traffic log:



2. Add the trafficlogger.detail cluster-wide property to specify the output of the traffic log:



NOTE 1: If the ${response.mainpart} is not set due to an exception in the service policy, the response body will be empty. ie. the traffic log may not be able to save default/custom error response.
NOTE 2: The new log file can be found under folder /opt/SecureSpan/Gateway/node/default/var/logs
NOTE 3: The traffic log output can be customized in cluster-wide property trafficlogger.detail. The above is just an example - the format can be modified with more context variables.


The output of the above setting may look like,
2018-09-12T14:45:46.785+1000 INFO    19912 com.l7tech.traffic: traffic log -- start
request url --
http://<gateway host>:8080/testonly
request body --
here is request body
response body --
ok, this is response
traffic log -- end

Attachments

1559044902608000113615_sktwi1540jw434nkn.png get_app
1559044897951000113615_sktwi1540jw434nkm.png get_app
1559044890141000113615_sktwi1540jw434nkl.png get_app
1558695823315000113615_sktwi1f5rjvs16ian.png get_app
1558695821533000113615_sktwi1f5rjvs16iam.png get_app
1558695819556000113615_sktwi1f5rjvs16ial.png get_app