nginx log configuration

log_format access_log_json '{"@timestamp":"$time_iso8601",'
                 #'"http_x_forwarded_for":"$http_x_forwarded_for",'
                 '"clientip":"$remote_addr",'
                 '"host":"$server_addr",'
                 '"upstreamhost":"$upstream_addr",'
                 '"remote_user":"$remote_user",'
                 '"status":"$status",'
                 '"upstreamtime":"$upstream_response_time",'
                 '"responsetime":"$request_time",'
                 '"size":"$body_bytes_sent",'
                 '"http_host":"$host",'
                 '"url":"$uri",'
                 '"request_method":"$request_method",'
                 '"request_body":"$request_body",'
                 '"Authorization":"$http_authorization",' #自定义header
                 '"custom_info": "$http_custom_info",' #自定义header
                 '"referer":"$http_referer",'
                 '"agent":"$http_user_agent"}';
access_log  /var/log/nginx/access.log access_log_json;

If the custom field configuration, open the configuration nginx.conf

# Enable User-defined header support 
underscores_in_headers on;

 

Guess you like

Origin www.cnblogs.com/imcati/p/11294233.html