NGINX JSON日志格式

dkqlctbz  于 2022-11-02  发布在  Nginx
关注(0)|答案(2)|浏览(170)

我们尝试过将错误日志转换为JSON格式,就像我们可以对访问日志所做的那样。但是我们在那里得到了错误。我们能不能像对访问日志所做的那样,将从NGINX服务器得到的错误日志格式化为JSON格式?

pbgvytdp

pbgvytdp1#

如此处所述http://nginx.org/en/docs/http/ngx_http_log_module.html#log_format
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"
}';
ymdaylpp

ymdaylpp2#

目前无法将错误日志格式化为JSON。

相关问题