Skip to main content
Version: Next



http-logger is a plugin which push Log data requests to HTTP/HTTPS servers.

This will provide the ability to send Log data requests as JSON objects to Monitoring tools and other HTTP servers.


uristringrequiredThe URI of the HTTP/HTTPS server.
auth_headerstringoptional""Any authorization headers.
timeoutintegeroptional3[1,...]Time to keep the connection alive after sending a request.
namestringoptional"http logger"A unique identifier to identity the logger.
include_req_bodybooleanoptionalfalse[false, true]Whether to include the request body. false: indicates that the requested body is not included; true: indicates that the requested body is included. Note: if the request body is too big to be kept in the memory, it can't be logged due to Nginx's limitation.
include_resp_bodybooleanoptionalfalse[false, true]Whether to include the response body. The response body is included if and only if it is true.
include_resp_body_exprarrayoptionalWhen include_resp_body is true, control the behavior based on the result of the lua-resty-expr expression. If present, only log the response body when the result is true.
concat_methodstringoptional"json"["json", "new_line"]Enum type: json and new_line. json: use json.encode for all pending logs. new_line: use json.encode for each pending log and concat them with "\n" line.
ssl_verifybooleanoptionalfalse[false, true]Whether to verify certificate.

The plugin supports the use of batch processors to aggregate and process entries(logs/data) in a batch. This avoids frequent data submissions by the plugin, which by default the batch processor submits data every 5 seconds or when the data in the queue reaches 1000. For information or custom batch processor parameter settings, see Batch-Processor configuration section.

How To Enable#

The following is an example of how to enable the http-logger for a specific route. You could generate a mock HTTP server at mockbin to view the logs.

curl -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '{      "plugins": {            "http-logger": {                "uri": ""            }       },      "upstream": {           "type": "roundrobin",           "nodes": {               "": 1           }      },      "uri": "/hello"}'

Test Plugin#


$ curl -i 200 OK...hello, world


log_formatobjectoptional{"host": "$host", "@timestamp": "$time_iso8601", "client_ip": "$remote_addr"}Log format declared as key value pair in JSON format. Only string is supported in the value part. If the value starts with $, it means to get APISIX variable or Nginx variable.

Note that the metadata configuration is applied in global scope, which means it will take effect on all Route or Service which use http-logger plugin.


curl -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '{    "log_format": {        "host": "$host",        "@timestamp": "$time_iso8601",        "client_ip": "$remote_addr"    }}'

It is expected to see some logs like that:


Disable Plugin#

Remove the corresponding json configuration in the plugin configuration to disable the http-logger. APISIX plugins are hot-reloaded, therefore no need to restart APISIX.

$ curl  -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '{    "uri": "/hello",    "plugins": {},    "upstream": {        "type": "roundrobin",        "nodes": {            "": 1        }    }}'