服务器问答
nginx 版本 1.14.0,使用 lua-nginx-module 输出 resp body ;
# 默认情况下日志输出 resp_body 里面的引号都被转成\x22
"xxx.xxx.xx.xx" "-" "23/Aug/2019:02:34:23 +0000" "POST /tes/api HTTP/1.1" "200" "67" "-" "Python/3.6 aiohttp/3.5.4" "-" "0.004" "{\x22success\x22: \x22true\x22, \x22sysTime\x22: 1566527663202, \x22data\x22: \x220976604866\x22}"
# 在 log_format 加上 escape=none 后,resp_body 输出正常,但是空字段变为“”,我想要的是“-”
"xxx.xxx.xx.xx" "" "23/Aug/2019:02:18:21 +0000" "POST /tes/api HTTP/1.1" "200" "67" "" "Python/3.6 aiohttp/3.5.4" "" "0.004" "{"success": "true", "sysTime": 1566526701825, "data": "0976604866"}"
# 我想要输出的结果是这样
"xxx.xxx.xx.xx" "-" "23/Au抗投诉服务器g/2019:02:35:21 +0000" "POST /tes/api HTTP/1.1" "200" "67" "-" "Python/3.6 aiohttp/3.5.4" "-" "0.005" "{"success": "true", "sysTime": 1566527721618, "data": "0976604866"}"
通过修改 ngx_http_log_module.c 源码可以实现第三个结果,我想知道有没有办法不改源码,只通过配置实现?