如何在Tomcat 7中记录请求/响应的所有标头 [英] How to log all headers of request/response in Tomcat 7
问题描述
我试图在Tomcat 7中记录请求/响应的所有标头.我试图使用
I'm trying to log all headers of request/response in Tomcat 7. I tried to use access-log-valve. But as mentioned in the link, we can print headers only one by one. We have to specify each and every header we need.
例如
pattern="%{User-Agent}i %{Content-Type}i %{Accept}i %{Accept-Encoding}i
%{Accept-Language}i %{Accept-Charset}i %r %h %q"
是否无法同时记录所有标头,可能使用通配符?
Isn't there a way to log all headers at once, may be using a wildcard?
谢谢.
推荐答案
没有开箱即用的方法-但一种简单的替代方法是运行过滤器.过滤器会将您想要的所有标头都推入servlet请求中.然后在您的模式中使用%{foo} r",其中foo是servlet请求中变量的名称.
There's no way out of the box - but an easy alternative is to stuff run a filter. The filter shove's all the headers you want into the servlet request. Then use "%{foo}r" in your pattern where foo is the name of the variable in the servlet request.
这篇关于如何在Tomcat 7中记录请求/响应的所有标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!