千家信息网

nginx日志使用json输出

发表于:2025-12-03 作者:千家信息网编辑
千家信息网最后更新 2025年12月03日,在nginx中使用json格式输出日志记录log_format json '{ "time_local": "$time_local", ''"remote_addr": "$remote_addr"
千家信息网最后更新 2025年12月03日nginx日志使用json输出

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

log_format json '{ "time_local": "$time_local", '
'"remote_addr": "$remote_addr", '
'"referer": "$http_referer", '
'"request": "$request", '
'"status": $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.log json;

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

0