I'm running a Jersey 2.2 Servlet inside Jetty 9.0.4 in order to serve REST requests.
Mostly everything is good and requests get served, but I have never seen ANY log from Jersey classes. And I can't find any doco indicating what chickens I need to sacrifice to make that happen with Jersey 2.2
So my first question is - what do I need to do to get Jersey to generate some log.
When a request does run awry (eg because the Json request body can't be parsed) Jersey will throw a ContainerException with message like "Can not deserialize instance of java.util.ArrayList out of START_OBJECT token" etc. At that point it would be really lovely to have logged the incoming request body so I can inspect the Json. Again I can't find anything in the current doco outlining such a beast although I'm sure there is one. And in any case until I solve question 1 up above it's moot.
So my 2nd question is how do I log the incoming request body (without disrupting the request).
The Jersey Servlet config in web.xml looks like:
<servlet >
<servlet-name>Jersey Servlet</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>au.com.xandar.wirelesstiming.recorder.web.rest.JerseyApplication</param-value>
</init-param>
<init-param>
<param-name>jersey.config.server.provider.classnames</param-name>
<param-value>org.glassfish.jersey.filter.LoggingFilter</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
My JerseyApplication is:
public final class JerseyApplication extends ResourceConfig {
public JerseyApplication() {
super(
//JacksonFeature.class // Switching on Jackson
// (My) JerseyLoggingFilter.class // Log requests using Jersey ContainerRequestFilter
MyApplicationEventListener.class // Log Requests using Jersey RequestEventListener
);
packages("au.com.xandar.wirelesstiming.recorder");
// Enable LoggingFilter & output entity.
// NB This does NOT generate any log.
registerInstances(new LoggingFilter(Logger.getLogger(JerseyApplication.class.getName()), true));
}
}