Logging JSON request and response for jersey
aop, aspectj, java, jax-rs, jersey
Solution
use LoggingFilter. Just add the following to your web.xml:
<init-param>
<param-name>com.sun.jersey.spi.container.ContainerRequestFilters</param-name>
<param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
<param-value>com.sun.jersey.api.container.filter.LoggingFilter</param-value>
</init-param>
Problem
I have a JAVA web application application, which exposes RESTful apis. My requirement is to log all the JSON requests and responses that are handled by the server. Is there any parameter like `-Dcom.sun.xml.internal.ws.transport.http.client.HttpTransportPipe.dump=true` for JAX-WS? I am also exploring AOP approach. What method signature should I add in the AOP pattern? I am using Tomcat server and jersey for the JAX-RS implementation.