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;

赠人玫瑰,手有余香,如果我的文章有幸能够帮到你,麻烦帮忙点下右下角的推荐,谢谢!

作者: imcati

出处: https://www.cnblogs.com/imcati/>

本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出, 原文链接

原文地址:https://www.cnblogs.com/imcati/p/11294233.html