Created
July 30, 2012 14:15
-
-
Save aaronfeng/3207188 to your computer and use it in GitHub Desktop.
nginx json log format
This file contains 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
# /etc/nginx/nginx.conf | |
log_format main '{' | |
'"remote_addr": "$remote_addr",' | |
'"remote_user": "$remote_user",' | |
'"time_local": "$time_local",' | |
'"request": "$request",' | |
'"status": "$status",' | |
'"body_bytes_sent": "$body_bytes_sent",' | |
'"http_referer": "$http_referer",' | |
'"http_user_agent": "$http_user_agent"' | |
'}'; |
\xXX is not valid in a json string (http://json.org/)
so ,it's not a good idead
Yeah this is definitely not correct JSON escaping
so, does an available solution come out?
oh please...
@ayiis You can check https://github.com/jiaz/nginx-http-json-log and kayrus/nginx@682f368
Nginx logging json format(http(s)&stream):
https://gist.github.com/hzbd/9dd768087f65d6026e14642bcc859e37
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think it's fine in recent versions of nginx:
Changes with nginx 1.1.6 17 Oct 2011
Changes with nginx 0.7.0 19 May 2008