Skip to content

Instantly share code, notes, and snippets.

@DanielRussell
Created June 2, 2022 21:53
Show Gist options
  • Save DanielRussell/671e2942fdd74eab27d554c8fa837436 to your computer and use it in GitHub Desktop.
Save DanielRussell/671e2942fdd74eab27d554c8fa837436 to your computer and use it in GitHub Desktop.
A good starting point for a JSON log format for nginx
log_format json
'{'
' "path":"/var/log/nginx/access_log.json","type":"http",'
' "clientip":"$remote_addr","ident":"-","auth":"$remote_user",'
' "timestamp":"$time_local","verb":"$request_method",'
' "request":"$request_uri","request_path":"$uri",'
' "http_version":"$server_protocol","response":"$status",'
' "bytes":"$body_bytes_sent",'
' "referrer":"$http_referer","agent":"$http_user_agent",'
' "xff":"$http_x_forwarded_for","request_time":"$request_time",'
' "http_host":"$host","accept":"$http_accept",'
' "accept_language":"$http_accept_language",'
' "language_locale":"$http_x_language_locale",'
' "range":"$http_range",'
' "scheme":"$scheme"'
'}';
access_log /var/log/nginx/access_log.json json;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment