我们用的nginx有做过一些定制开发,为了调试方便,加了一些自定义的response header,那么如何把这个自定义头记录到日志中以便于观察呢?
nginx log_format指令支持这种扩展,如下说明:
The headers, transmitted to client, begin
from the prefix
"sent_http_",
for example, $sent_http_content_range.
Note that variables produced by other modules can also be logged. For example you can log upstream response headers with the prefix "upstream_http_", see upstream .
wiki地址:http://wiki.nginx.org/HttpLogModule
举例:如果你自定义的响应header是My_Custom_Header,那么只需要在log_format中增加$sent_http_my_custom_header即可
PS:nginx对header的处理是大小写不敏感的。
转载于:https://www.cnblogs.com/searchappiness/p/4605877.html
相关资源:JAVA上百实例源码以及开源项目