nginx日志配置

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":"$request_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;

如果配置了自定义字段,请在nginx.conf打开这个配置

#开启用户自定义header支持
underscores_in_headers on;

 

posted @ 2019-08-03 11:25  imcati  阅读(155)  评论(0编辑  收藏  举报