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?
Asked
Active
Viewed 97 times
0
-
Is it a *requirement* that you use `ValveBase`? Or is that just how you have decided to solve the original problem? – Christopher Schultz Oct 21 '22 at 20:58
-
Yes i don't want to change legacy existing application. Using filter i have to change in web.xml. Using Valvebase, when i implemented RequestWrapper i dont have to change existing application web.xml.But for Response i am not able to implement it wrapper. – trapti vishnoi Oct 25 '22 at 05:44
-
https://github.com/codekoenig/RequestLoggerValve/tree/b580cc91a9a21e6e7c8596e9dc988b0aa504c04f/capture/src/main/java/org/apache/catalina/connector. followed this link for RequestWrapper – trapti vishnoi Oct 25 '22 at 05:45
-
If you are able to wrap the request, wrapping the response should not be too much of a problem. What have you tried so far? – Christopher Schultz Oct 26 '22 at 15:55
1 Answers
0
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.

Christopher Schultz
- 20,221
- 9
- 60
- 77