标签:time 解决 lan inux format www add byte lse
Nginx访问日志在处理中文时,默认使用16进制编码处理。使我们对访问日志进行分析处理时,带来很大不便。含有中文字符的请求,日志记录如下:
171.43.238.62 - - [05/Dec/2017:21:40:57 +0800] "GET /\xD6\xD0\xCE\xC4 HTTP/1.1" 404 171 "-" "curl/7.56.0"
问题解决方案:
escape=json
日志格式示例:
log_format main escape=json ‘$remote_addr - $remote_user [$time_local] "$request" ‘
‘$status $body_bytes_sent "$http_referer" ‘
‘"$http_user_agent" "$http_x_forwarded_for"‘;
结果:
47.52.167.143 - [05/Dec/2017:21:55:59 +0800] "GET /中文 HTTP/1.1" 404 171 "" "curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.27.1 zlib/1.2.3 libidn/1.18 libssh2/1.4.2" ""
来源:迅闻网
标签:time 解决 lan inux format www add byte lse
原文地址:https://www.cnblogs.com/1156184981651a/p/12813703.html