This is a question related to Capture and log the response body. What if I only want to log the response headers, and not the entire body? Is there a different approach than described in the linked question?
相关问题
- Angular RxJS mergeMap types
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
You'd like to override the
HttpServletResponse#addHeader()
andHttpServletResponse#setHeader()
method instead.There are indeed more methods which sets the headers, but in a bit decent servletcontainer implementation they all delegate to this one method (I've verified it in both Tomcat and Glassfish).
Alternatively, you can also make use of servletcontainer specific logging capabilities. Tomcat for example seems to support logging of response headers by a valve.