Skip to content

Instantly share code, notes, and snippets.

@phiresky
Last active December 2, 2020 23:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save phiresky/3a1489697a97ed6a4020b5d2818a2f21 to your computer and use it in GitHub Desktop.
Save phiresky/3a1489697a97ed6a4020b5d2818a2f21 to your computer and use it in GitHub Desktop.
Log as much information as possible in nginx to json format
http {
log_format json_combined escape=json
'{'
'"time_iso8601":"$time_iso8601", "remote_addr":"$remote_addr", "remote_user":"$remote_user", "request":"$request",'
'"status": "$status", "body_bytes_sent":"$body_bytes_sent", "request_time":"$request_time","http_host":"$http_host","host":"$host",'
'"args":"$args",'
'"connection":"$connection","content_length":"$content_length","content_type":"$content_type","uri":"$uri","request_filename":"$request_filename",'
'"http_referrer":"$http_referer", "http_user_agent":"$http_user_agent",'
'"upstream_connect_time": "$upstream_connect_time", "upstream_response_time":"$upstream_response_time"'
'}';
access_log /var/log/nginx/access-legacy.log combined;
access_log /var/log/nginx/access.jsonl json_combined;
error_log /var/log/nginx/error.log;
}
@phiresky
Copy link
Author

needs nginx at least 1.11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment