nginx日志使用json输出

  

在nginx中使用json格式输出日志记录

  

log_format json ' {“time_local":“time_local"美元;,“
”“remote_addr":“remote_addr"美元;,“
”“referer":“http_referer"美元;,“
”“request":“request"美元;,“
”“status":美元地位,“
”“bytes": body_bytes_sent美元,
的“agent":“http_user_agent"美元;,“
”“x_forwarded":“http_x_forwarded_for"美元;,“
”“up_addr":“upstream_addr"美元;,“
”“up_host":“upstream_http_host"美元;,“
”“upstream_time":“upstream_response_time"美元;,“
”“request_time":“request_time"美元;'
'} ';

  

access_log/var/log/nginx/access.日志json;

  

对于使用filebeat来收集日志很重要。

nginx日志使用json输出