Log request headers


#1

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


#2

Hi,

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.

Thanks
Raj


#3

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


#4

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