让nginx日志支持json格式

图片.png

log_format log_json '{ "@timestamp": "$time_iso8601", '
                     '"remote_addr": "$remote_addr", ' # 客户端的ip地址
                     '"remote_user": "$remote_user", '  # 客户端用户名称
                     '"body_bytes_sent": "$body_bytes_sent", ' # 发送给客户端文件主体内容大小
                     '"request_time": "$request_time", '
                     '"status": "$status", '
                     '"host": "$host", '
                     '"request": "$request", ' # 请求的url与http协议
                     '"request_method": "$request_method", '
                     '"uri": "$uri", '
                     '"http_referrer": "$http_referer", ' # 从那个页面链接访问过来的
                     '"http_x_forwarded_for": "$http_x_forwarded_for", ' # 客户端真实ip地址

                     '"http_user_agent": "$http_user_agent" '  # 客户端浏览器的相关信息

                '}';
access_log  /var/log/nginx/access-json.log  log_json;


猜你喜欢

转载自blog.51cto.com/silencezone/2672550