Jersey client 2.25 logging not working for request/response traffic

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Jersey client 2.25 logging not working for request/response traffic

Manpreet Singh

Hi All,


Need some assistance with logging.

I'm using jersey client v2.25.1 for a REST automation framework and here is how I am registering the Logger and initializing the Client:


//Initialize FileHandler

Path currPath = Paths.get(System.getProperty("user.dir"));

Path logFilePath = Paths.get(currPath.toString(), "logs", testCaseName+".log");

logHandleObj = new FileHandler(logFilePath.toString(), 0, 1, true);


//Initialize Logger

Logger loggerObj = Logger.getLogger(testCaseName);




//Initialize ClientConfig

ClientConfig clientConfig = new ClientConfig();

//Set configuration features

clientConfig.register(new JacksonFeature());, true);

clientInstance = ClientBuilder.newClient(clientConfig);

//Register LoggingFeature

clientInstance.register(new LoggingFeature(loggerObj, Level.ALL,

        LoggingFeature.Verbosity.PAYLOAD_ANY, LoggingFeature.DEFAULT_MAX_ENTITY_SIZE));


As per documentation, this is supposed to be logging complete request/response traffic like so:

1 May 09, 2016 2:55:33 PM org.glassfish.jersey.logging.LoggingInterceptor log
2 INFO: 1 * Server has received a request on thread grizzly-http-server-0
3 1 > GET http://localhost:9998/helloworld

However, I am getting:

<?xml version="1.0" encoding="windows-1252" standalone="no"?>
<!DOCTYPE log SYSTEM "logger.dtd">
    <message>Entity must not be null for http method PUT.</message>

So two problems here:

  • Not getting the HTTP traffic
  • Format is XML for some reason instead of plain text

Will really appreciate any assistance on this.


- Manpreet