打印日志内容的时候,遇到中文会被转换为16进制
解决办法
在nginx 1.11.8 以上版本中log_format 增加了escape=json 参数,在配置日志格式时加上此参数可以不转义变量内容
log_format main escape=json '$http_x_forwarded_for | $remote_addr | [$time_local] "$request" | $status | $request_time | ' "$request_body"
' | $body_bytes_sent | "$http_referer" | '
'"$http_user_agent"';
location 中配置日志
access_log /usr/local/openresty/nginx/logs/access.log main;
最后修改于 2022-07-21 15:46:06
如果觉得我的文章对你有用,请随意赞赏
扫一扫支付

