Log Invocation

This policy enables logging requests or responses to a specified destination. This action also logs other information about the requests or responses, such as the API name, operation name, the Integration Server user, a timestamp, and the response time.

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

Here is a sample code for the Log Invocation policy.

kind: Log
apiVersion: api.webmethods.io/beta
metadata:
  name: log_invocation
  version: 1.0
  namespace: sample
  tags:
    - log_invocation
spec:
  enabled: true
  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:
    - self 
    - dev_portals:
      - devportal 1 #name of the portal instance in the gateway
    - email:
      - nas@sag.com
      - daso@sag.com

The structure in the code view and what it denotes is as follows:

Type Description
kind Log.

This denotes the asset type, Log policy.

apiVersion This denotes the API version of the API on which this policy is enforced.
metadata This denotes the metadata or details of the asset type.
It covers the following metatdata:
  • name. Name of the policy.
  • version. Version of the policy.
  • namespace. The namespace identifier for the policy.
  • tags. The tags associated with the policy.
spec This denotes various policy properties you can configure for the policy.
You can configure the following policy properties:
  • enabled. Specifies whether the policy is enabled or disabled. Set the value to true to enable the policy, and set it to false to disable the policy.
  • logRequestHeaders. Logs all request headers. Default value is false. Set it to true if you want to log all request headers.
  • logResponseHeaders. Logs all response headers. Default value is false. Set it to true if you want to log all response headers.
  • logRequestPayload. Logs all request payloads. Default value is false. Set it to true if you want to log all request payloads.
  • logResponsePayload. Logs all response payloads. Default value is false. Set it to true if you want to log all response payloads.
  • compressPayloads. Compresses the logged payload data.
  • logGenerationFrequency. Specifies how frequently to log the payload. You can provide one of the following values:
    • always. Logs all requests and responses.
    • onfailure. Logs only the failed requests and responses.
    • onsuccess. Logs only the successful responses and requests.
  • destination. Specifies the destination where to log the payload. You can provide the options, self, dev_portals, or email.