Router Log Configurations

As Choreo Connect uses an Envoy proxy as the Router component, it only supports the logging mechanisms provided by the Envoy proxy (read more details about router). In the following sections, you may find how to enable Router access logs and debug logs.

Router Access Logging

You can enable Router access logs by using the following configs. Router access logs related configurations are in the log_config.toml file, which is located in these directories based on your Choreo Connect deployment method.

[accessLogs]
enable = <true or false>
logfile = <file_path> # This file will be created inside router container.
format = <format_string>
[accessLogs]
enable = true
logfile = "/tmp/envoy.access.log"
format = "[%START_TIME%] '%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)% %PROTOCOL%' %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION% %RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)% '%REQ(X-FORWARDED-FOR)%' '%REQ(USER-AGENT)%' '%REQ(X-REQUEST-ID)%' '%REQ(:AUTHORITY)%' '%UPSTREAM_HOST%'\n"

Setting enable as true will let you enable the Router access logs and the file path can be set up using the logfile. Follow format strings and command operators for more information on the supported options for log format, format configuration.

Router debug logs

To enable Router debug logs, provide the log level as trailing arguments for the envoy command as follows.

-l <level>, 
--log-level <level>
--component-log-level <component>:<level>,<component>:<level>...
-l trace, 
--log-level trace
--component-log-level upstream:debug,connection:trace

You can do this by setting the TRAILING_ARGS environment variable in the Router. For example, Add the following line to the docker-compose.yaml in the directory <CHOREO-CONNECT_HOME>/docker-compose/<choreo-connect>/.

  router:
    environment:
      - TRAILING_ARGS=--log-level trace
The following example configuration can log request headers and response headers, and ext_authz information.

  router:
    environment:
      - TRAILING_ARGS=--component-log-level http:debug,http2:debug,conn_handler:debug,ext_authz:trace
The following are different sections of an example log with the above log configuration. This log is generated by invoking an API request with /pet/findByStatus?status=sold path in Swagger Petstore API deployed to Choreo Connect. Different log sections are given in the order same as the order in which they are logged to the console.

Client to Router request headers:

[2022-04-11 08:18:03.917][15][debug][http] [source/common/http/conn_manager_impl.cc:867] [C19][S3973774370179828478] request headers complete (end_stream=true):
':authority', 'localhost:9095'
':path', '/v2/pet/findByStatus?status=sold'
':method', 'GET'
'user-agent', 'curl/7.68.0'
'accept', 'application/json'
'authorization', 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1UWm1ZemsxWlRJeVkyTmlNR00wT1RJMFpqTXdNRE5rTldZek16QTJOVEl4TWpRelpERTFNdz09In0.eyJhdWQiOiJodHRwOlwvXC9vcmcud3NvMi5hcGltZ3RcL2dhdGV3YXkiLCJzdWIiOiJhZG1pbiIsInNjb3BlIjoicmVhZDpwZXRzIiwiaXNzIjoiaHR0cHM6XC9cL2xvY2FsaG9zdDo5MDk1XC90ZXN0a2V5Iiwia2V5dHlwZSI6IlBST0RVQ1RJT04iLCJleHAiOjE2NDk2Njg2NjUsImlhdCI6MTY0OTY2NTA2NSwianRpIjoiZDI3MTRiYmMtMWE5OC00ODc5LThmM2QtM2I5ZGYwNjI1NDcwIn0.MXkSAq98Zx32j5ijK4MLvlocMhjVW_xxW3ECeGVmHaRkqg43bO2PLtdoh952YBbK4xzK3mDhAxF1VxynDyD5u1qpu696e4w3UwF2pfU3hAdbG2fDdcm82KiSfydawOnivxFr-QX08tQxDTO9i5Fgo7nZMsZkNRN2er1asctDaDRcqcR00Jh6h1jyqBU6Ixf67dkZk61et8yNdGeSiuy-QXLVHsN8YbvXNyct1d1nVjZrE3d_kDkk_ZQlqHj327BXolCl_tiinj_bBDovmqIDNwTXkL47rtuWX6sB1uBJ0xBHtuZxT7-IgB1WUVvVcbAqNebQFs1bV8A-h0efQKKBdg'
Router to Enforcer request information:
[2022-04-11 08:18:03.917][15][trace][ext_authz] [source/extensions/filters/common/ext_authz/ext_authz_grpc_impl.cc:42] Sending CheckRequest: attributes {
  source {
    address {
      socket_address {
        address: "172.18.0.1"
        port_value: 40312
      }
    }
  }
  destination {
    address {
      socket_address {
        address: "172.18.0.5"
        port_value: 9095
      }
    }
    principal: "adapter"
  }
  request {
    time {
      seconds: 1649665083
      nanos: 917501000
    }
    http {
      id: "3973774370179828478"
      method: "GET"
      headers {
        key: ":authority"
        value: "localhost:9095"
      }
      headers {
        key: ":method"
        value: "GET"
      }
      headers {
        key: ":path"
        value: "/v2/pet/findByStatus?status=sold"
      }
      headers {
        key: ":scheme"
        value: "https"
      }
      headers {
        key: "accept"
        value: "application/json"
      }
     ...
     ...

Enforcer to Router response information:

[2022-04-11 08:18:03.937][15][trace][ext_authz] [source/extensions/filters/common/ext_authz/ext_authz_grpc_impl.cc:48] Received CheckResponse: status {
}
ok_response {
  headers {
    header {
      key: "X-JWT-Assertion"
      value: "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1UWm1ZemsxWlRJeVkyTmlNR00wT1RJMFpqTXdNRE5rTldZek16QTJOVEl4TWpRelpERTFNdz09In0=.eyJzdWIiOiJhZG1pbiIsImh0dHA6XC9cL3dzbzIub3JnXC9jbGFpbXNcL2FwcGxpY2F0aW9udGllciI6IlVubGltaXRlZCIsImh0dHA6XC9cL3dzbzIub3JnXC9jbGFpbXNcL3ZlcnNpb24iOiIxLjAuNiIsImh0dHA6XC9cL3dzbzIub3JnXC9jbGFpbXNcL2tleXR5cGUiOiJQUk9EVUNUSU9OIiwiaXNzIjoid3NvMi5vcmdcL3Byb2R1Y3RzXC9hbSIsImh0dHA6XC9cL3dzbzIub3JnXC9jbGFpbXNcL2FwcGxpY2F0aW9ubmFtZSI6ImFub246TUdXIiwia2V5dHlwZSI6IlBST0RVQ1RJT04iLCJodHRwOlwvXC93c28yLm9yZ1wvY2xhaW1zXC9lbmR1c2VyVGVuYW50SWQiOiIwIiwiaHR0cDpcL1wvd3NvMi5vcmdcL2NsYWltc1wvYXBwbGljYXRpb25VVUlkIjoiNWE2YmNiMGMtZjdjMi0zYmNkLWJiMGEtMDIxZWYyMWYyMWViIiwic2NvcGUiOiJyZWFkOnBldHMiLCJleHAiOjE2NDk2NjQwODEsImh0dHA6XC9cL3dzbzIub3JnXC9jbGFpbXNcL2FwcGxpY2F0aW9uaWQiOiI1YTZiY2IwYy1mN2MyLTNiY2QtYmIwYS0wMjFlZjIxZjIxZWIiLCJodHRwOlwvXC93c28yLm9yZ1wvY2xhaW1zXC91c2VydHlwZSI6IkFwcGxpY2F0aW9uX1VzZXIiLCJpYXQiOjE2NDk2NjUwODEsImp0aSI6Ijc1NWEwYzI4LWE2ODUtNDYzNC1hNzNiLWYzOGU4NDNmODYxNyIsImh0dHA6XC9cL3dzbzIub3JnXC9jbGFpbXNcL2FwaWNvbnRleHQiOiJcL3YyIn0=.iphgEpqjBVA48rGZdv14A_iLZE81V2p0iObUGg5UPefGHDVMZoi_w2Z30oMuBpRougXoPmMWkQ_Cj4llG31d9CPW7HkQyicHup4UH1n25L4Iv3D1Pny_NhDvDmeixT3PQ_FU-1NK1tB1lxW1c4WVoRfbrIqvD5ojYx6aPy7eBNp1Hx-pZib53rd_LKkmHXH0WGW_N-vjwhlXOlCu9pANkJeRx4QWDiNvooCEgwqG2Dwgh2z8ck5XWgCVLb4Pm24Zqg0GucKfy3LTBi7uupYvDIQtUfM_HExm2OimxyCwOYDpyRGMmRqGIS2zCRq5lt8Cc3HbPpa5rxJvCXF848Aj5A=="
    }
  }
  headers {
    header {
      key: "x-wso2-cluster-header"
      value: "carbon.super_clusterProd_localhost_SwaggerPetstore1.0.6"
    }
  }
  headers {
    header {
      key: "X-TRACE-KEY"
      value: "3973774370179828478"
    }
  }
  headers_to_remove: "api_key"
  headers_to_remove: "internal-key"
}
dynamic_metadata {
  fields {
    key: "keyType"
    value {
      string_value: "PRODUCTION"
    }
  }
  fields {
    key: "token"
    value {
      string_value: "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6Ik1UWm1ZemsxWlRJeVkyTmlNR00wT1RJMFpqTXdNRE5rTldZek16QTJOVEl4TWpRelpERTFNdz09In0.eyJhdWQiOiJodHRwOlwvXC9vcmcud3NvMi5hcGltZ3RcL2dhdGV3YXkiLCJzdWIiOiJhZG1pbiIsInNjb3BlIjoicmVhZDpwZXRzIiwiaXNzIjoiaHR0cHM6XC9cL2xvY2FsaG9zdDo5MDk1XC90ZXN0a2V5Iiwia2V5dHlwZSI6IlBST0RVQ1RJT04iLCJleHAiOjE2NDk2Njg2NjUsImlhdCI6MTY0OTY2NTA2NSwianRpIjoiZDI3MTRiYmMtMWE5OC00ODc5LThmM2QtM2I5ZGYwNjI1NDcwIn0.MXkSAq98Zx32j5ijK4MLvlocMhjVW_xxW3ECeGVmHaRkqg43bO2PLtdoh952YBbK4xzK3mDhAxF1VxynDyD5u1qpu696e4w3UwF2pfU3hAdbG2fDdcm82KiSfydawOnivxFr-QX08tQxDTO9i5Fgo7nZMsZkNRN2er1asctDaDRcqcR00Jh6h1jyqBU6Ixf67dkZk61et8yNdGeSiuy-QXLVHsN8YbvXNyct1d1nVjZrE3d_kDkk_ZQlqHj327BXolCl_tiinj_bBDovmqIDNwTXkL47rtuWX6sB1uBJ0xBHtuZxT7-IgB1WUVvVcbAqNebQFs1bV8A-h0efQKKBdg"
    }
  }
  fields {
    key: "tokenType"
    value {
      string_value: "JWT"
    }
  }
  ...
  ...

Router to client response headers:

[2022-04-11 08:18:04.956][15][debug][http] [source/common/http/conn_manager_impl.cc:1467] [C19][S3973774370179828478] encoding headers via codec (end_stream=false):
':status', '200'
'date', 'Mon, 11 Apr 2022 08:18:04 GMT'
'content-type', 'application/json'
'access-control-allow-origin', '*'
'access-control-allow-methods', 'GET, POST, DELETE, PUT'
'access-control-allow-headers', 'Content-Type, api_key, Authorization'
'server', 'envoy'
'x-envoy-decorator-operation', 'localhost:^/v2/pet/findByStatus(\?([^/]+))?$'

Follow command line options for more information.

Router wire logs

By enabling wire logs in the Router component, you can inspect headers, body, and trailers of the request/response. This is helpful to see the changes applied to the request or response after request path and/or response path interceptors.

To enable the wire logs, add the following configuration to the log_config.toml file in these directories depending on your Choreo Connect deployment setup.

[wireLogs]
enable = true
include = ["Headers", "Body", "Trailers"]

You need to set enable property as true as well as keep at least one from the set {"Headers", "Body", "Trailers"} depending on which parts you want to inspect in the include array.

An API request invoked at Choreo Connect with the above wire log configuration will generate logs similar to the following.

[2022-06-03 09:53:03.304][24][info][lua] [source/extensions/filters/http/lua/lua_filter.cc:795] script log: 
[wirelog] >> request headers >> :authority: localhost:9095
[wirelog] >> request headers >> :path: /trailers/test
[wirelog] >> request headers >> :method: POST
[wirelog] >> request headers >> :scheme: https
[wirelog] >> request headers >> user-agent: curl/7.77.0
[wirelog] >> request headers >> accept: */*
[wirelog] >> request headers >> content-type: text/plain
[wirelog] >> request headers >> content-length: 12
[wirelog] >> request headers >> x-forwarded-proto: https
[wirelog] >> request headers >> x-request-id: 3f236205-f5be-4e65-b348-5d23a9b32a1b
[wirelog] >> request headers >> x-wso2-cluster-header: carbon.super_clusterProd_localhost_http-trailersv1
[wirelog] >> request headers >> x-trace-key: 17001635652092319657

[2022-06-03 09:53:03.307][24][info][lua] [source/extensions/filters/http/lua/lua_filter.cc:795] script log: 
[wirelog] >> request body >> 
request data
[wirelog] >> request body >> 

[2022-06-03 09:53:03.307][24][info][lua] [source/extensions/filters/http/lua/lua_filter.cc:795] script log: 

[2022-06-03 09:53:03.311][24][debug][http2] [source/common/http/http2/codec_impl.cc:1083] [C9] stream closed: 0
[2022-06-03 09:53:03.322][24][info][lua] [source/extensions/filters/http/lua/lua_filter.cc:795] script log: 
[wirelog] << response headers << :status: 200
[wirelog] << response headers << x-powered-by: Express
[wirelog] << response headers << content-type: text/plain
[wirelog] << response headers << trailer: Content-MD5
[wirelog] << response headers << trialer: Time-Taken
[wirelog] << response headers << date: Fri, 03 Jun 2022 09:53:03 GMT
[wirelog] << response headers << connection: keep-alive
[wirelog] << response headers << keep-alive: timeout=5
[wirelog] << response headers << transfer-encoding: chunked

[2022-06-03 09:53:03.323][24][info][lua] [source/extensions/filters/http/lua/lua_filter.cc:795] script log: 
[wirelog] << response body << 
sample text data. abcd 1234 
[wirelog] << response body << 

[2022-06-03 09:53:03.323][24][info][lua] [source/extensions/filters/http/lua/lua_filter.cc:795] script log: 
[wirelog] << response trailers << content-md5: 7895bf4b8828b55ceaf47747b4bca667
Top