[Nginx] nginx configuration json format log

nginx.conf module configuration log_format:

log_format main'{
“@timestamp”:”$time_iso8601″,
“host”:”$server_addr”,
“clientip”:”$remote_addr”,
“remote_user”:”$remote_user”,
“request”:”$ request”,
“http_user_agent”:”$http_user_agent”,
“size”:”$body_bytes_sent”,
“responsetime”:”$request_time”,
“upstreamtime”:”$upstream_response_time”,
“upstreamhost”:”$upstream_addr”,
“http_host”:”$host”,
“url”:”$uri”,
“domain”:”$ host”,
“xff”:”$http_x_forwarded_for”,
“referer”:”$http_referer”,
“status”:”$status”
}’;

After configuration, perform the following format verification: ../ sbin/nginx -t

After the verification is successful, reload the configuration: ../sbin/nginx -s reload

The log is shown as follows:

Share pictures

Leave a Comment

Your email address will not be published.