我们尝试以 JSON 格式获取错误日志,就像获取访问日志一样。但我们在那里遇到了错误。 我们能否不像访问日志那样将从 NGINX 服务器获取的错误日志格式化为 JSON 格式?
如here所述,
json
日志格式在nginx中可用
log_format logger-json escape=json '{
"source": "nginx",
"time": $msec,
"resp_body_size": $body_bytes_sent,
"host": "$http_host",
"address": "$remote_addr",
"request_length": $request_length,
"method": "$request_method",
"uri": "$request_uri",
"status": $status,
"user_agent": "$http_user_agent",
"resp_time": $request_time,
"upstream_addr": "$upstream_addr"
}';
access_log /var/log/nginx/access.log logger-json;
目前无法将错误日志格式化为 JSON。