Custom nginx log format

Hi Folks,

I’m trying to change the default log format for kong by modifying nginx_kong.lua template file:

I can see my configuration in /usr/local/kong/nginx-kong.conf file but log format isn’t changed.

I’m trying to match nginx ingress controller format:

# The following is a sneaky way to do "set $the_real_ip $remote_addr"
# Needed because using set is not allowed outside server blocks.
map '' $the_real_ip {

  # Get IP address from Proxy Protocol
  default          $proxy_protocol_addr;

}
  log_subrequest      on;
  log_format upstreaminfo '$the_real_ip - [$the_real_ip] - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $request_length $request_time [$proxy_upstream_name] $upstream_addr $upstream_response_length $upstream_response_time $upstream_status $req_id';

map $request_uri $loggable {

  default 1;
}

# Reverse proxies can detect if a client provides a X-Request-ID header, and pass it on to the backend server.
# If no such header is provided, it can provide a random value.
map $http_x_request_id $req_id {
  default   $http_x_request_id;

  ""        $request_id;

}

server {
    server_name kong;
    set $proxy_upstream_name "-";

Any ideas?

I’m using the following sw version:
Kong 1.0.0
Kong ingress 0.3.0

Also how do I dump active configuration?

Thanks

1 Like