How to get jersey logs at server?

If you want to turn on logging on the server side, you need to register the LoggingFilter Jersey filter (on the container side).

This filter will log request/response headers and entities.

Here’s what you need to add to your ResourceConfig class:

@ApplicationPath("https://stackoverflow.com/")
public class MyApplication extends ResourceConfig {

    public MyApplication() {
        // Resources.
        packages(MyResource.class.getPackage().getName());

        register(LoggingFilter.class);    
    }
}

Note that the same filter also works on the client side.

Client client = Client.create();
client.addFilter(new LoggingFilter());

Leave a Comment