Wednesday, September 26, 2007

Logging request and response headers in Tomcat

What's the best way to dump out request or response headers in Tomcat?

Before rolling up your own solution, take a look at the valve component that Tomcat supports. In particular, the aptly named RequestDumperValve will log all the request and response headers in Tomcat. To enable the valve, just go to your server.xml file in the /conf directory and uncomment this line:

<Valve className="org.apache.catalina.valves.RequestDumperValve"/>

Then restart your server and the headers will appear in your log file.

10 comments:

Vinay Mehta said...

very useful information.
thnks

Anonymous said...

your the man cool-guy
see you at the beach

Anonymous said...

This was greatly helpful! Thanks,

Anonymous said...

Very useful post, thanks!

Anonymous said...

useful :)

Anonymous said...

Thank you sir. Exactly what I needed.

Anonymous said...

Very useful, but didn't print request POST body for me in tomcat6

Daniel Kaplan said...

This would be MUCH more helpful if you told us where to put that value. But, thank you for the post

Pega Tutorials said...

I am getting classnotfoundexception in Tomcat8.5

Pega Tutorials said...

I am getting classnotfoundexception in Tomcat8.5