skip to Main Content

We have tried to get the error logs in JSON format as we can do for access logs. But we are getting error there.
Can we not format the error logs we are getting from NGINX server to JSON format as we can do for access logs?

2

Answers


  1. At the moment is not possible to format the error logs as JSON.

    Login or Signup to reply.
  2. As described here
    http://nginx.org/en/docs/http/ngx_http_log_module.html#log_format

    json log format is available in 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"
    }';
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search