Wrap response in Tomcat custom valve to allow reading the response body

158 Views Asked by At

i need to log all response from an application using tomcat ValveBase class. For request i already created a wrapper org.apache.catalina.connector.Request and it logs all request. But for response, wrapper for org.apache.catalina.connector.Response is giving payload as null.can anybody help?

1

There are 1 best solutions below

0
Christopher Schultz On

If you don't need to use ValveBase, here is a Filter which may do what you are looking for. Note that using this will use-up a lot of memory for each request and reduce your performance, especially for very large responses.

The code is a little too long to put into an SO answer, so I'll just link to it.

https://markmail.org/message/kholzdskue5pctpw