-
-
Save Ima8/0cbb25013c697ddc085fa3b28358dc8d to your computer and use it in GitHub Desktop.
W3C json log format for nginx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| map $request_uri $request_uri_path { | |
| "~^(?P<path>[^?]*)(\?.*)?$" $path; | |
| } | |
| log_format w3cjson escape=json | |
| '{' | |
| '"Date":"$time_iso8601",' | |
| '"Client IP Address":"$remote_addr",' | |
| '"Client Username":"$remote_user",' | |
| '"Server IP Address":"$server_addr",' | |
| '"Request Port":$server_port,' | |
| '"Request Protocol":"$server_protocol",' | |
| '"Request Method":"$request_method",' | |
| '"Request URI":"$request_uri_path",' | |
| '"Query String":"$query_string",' | |
| '"Status":$status,' | |
| '"User Agent":"$http_user_agent",' | |
| '"Cookie":"$http_cookie",' | |
| '"Referer":"$http_referer",' | |
| '"Bytes Received":$request_length,' | |
| '"Bytes Sent":$body_bytes_sent,' | |
| '"Request Time":$request_time,' | |
| '"X-Forwarded-For":"$http_x_forwarded_for",' | |
| '"Upstream":"$upstream_addr",' | |
| '"Upstream Response Time":$upstream_response_time,' | |
| '"Upstream Cache Status":"$upstream_cache_status",' | |
| '"Request Country Code","$geoip_country_code"' | |
| '}'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment