开发者

How to get hold of the (un)marshalled message for logging

开发者 https://www.devze.com 2023-04-12 01:03 出处:网络
I have a Spring MVC REST service that uses XStream to convert the messages to and from XML. 开发者_如何学PythonIs there any way I can print the xml (ie the body) from the request and response to a no

I have a Spring MVC REST service that uses XStream to convert the messages to and from XML.

开发者_如何学Python

Is there any way I can print the xml (ie the body) from the request and response to a normal log4j logger?

Inside the controller won't work cause by then XStream has alread unmarshalled the request and not yet marshalled the response.

A filter in the servlet isn't very nice either as it will consume the body by reading it.

And thats where I run out if ideas. So, SO? Any takers? :)


You can use an interceptor to log your request and response content coming to your specific rest uri's - More details here

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号