Log request headers

Hi All,
I’m searching for a way to log request headers on kong. can anyone help me on this.


we are using the below code to log the headers in our custom plugins.

local header=ngx.req.get_headers()[“Authorization”]
ngx.log(ngx.ERR, “Authorization header”,header)

Hope this helps.


1 Like

Found the simplest way : just create custom log format and add $http_custom_header_name

Also note that the logging plugins distributed with Kong (see the ‘logging’ tab on https://docs.konghq.com/hub/) will write out header data.