Log

This policy enables logging requests or responses to a specified destination.

The Log action also logs other information about the requests or responses. You can configure information like API name, operation name, the Integration Server user, a timestamp, and the response time.

In IBM API Studio, this policy is identified by the kind Log.

Example of a Log Invocation policy in code view.

kind: Log
apiVersion: api.ibm.com\v1
metadata:
  name: log_invocation
  version: 1.0
  namespace: sample
  tags:
    - log_invocation
spec:
  logRequestHeaders: true # default value is false
  logResponseHeaders: true # default value is false
  logRequestPayload: true # default value is false
  logResponsePayload: true # default value is false
  compressPayloads: true # default value is false
  logGenerationFrequency: always #Other values are 'onfailure' &  'onsuccess'
  destination:
    - api_gateway
    - dev_portals
    - email:
        - nas@email.com
        - daso@email.com
    - snmp
    - jdbc
    - centraSite
    - elasticsearch
    - log-file:
        level: info
    - auditLog
    - apic

For the Log policy kind, configure these specifications:

Code view Form view Description
logRequestHeaders Store request headers

Specifies that the request headers are to be logged.

In the code view, set the value to true to enable the policy, and set it to false to disable the policy.

In the form view, select the box to set it to true.

logRequestPayload Store request payload

Specifies that the response headers are to be logged.

In the code view, set the value to true to enable the policy, and set it to false to disable the policy.

In the form view, select the box to set it to true.

logResponseHeaders Store response headers

Specifies that the request payload is to be logged.

In the code view, set the value to true to enable the policy, and set it to false to disable the policy.

In the form view, select the box to set it to true.

logResponsePayload Store response payload

Specifies that the response payload is to be logged.

In the code view, set the value to true to enable the policy, and set it to false to disable the policy.

In the form view, select the box to set it to true.

compressPayloads Compress payload

Specifies that the payload is to be compressed.

In the code view, set the value to true to enable the policy, and set it to false to disable the policy.

In the form view, select the box to set it to true.

logGenerationFrequency Log generation frequency

Specifies how frequently to log the payload. You can choose one of the following options:

  • always. Logs all requests and responses.
  • onfailure. Logs only the failed requests and responses.
  • onsuccess. Logs only the successful responses and requests.
destination Destination

Specifies the destination to log the payload.

You can specify one of these destinations:
  • API Gateway
  • API Portal
  • CentraSite
  • Elasticsearch
  • Email
  • JDBC
  • Local log
  • SNMP