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
|  
Report Content as Inappropriate

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);

loggerObj.setUseParentHandlers(false);

loggerObj.addHandler(logHandleObj);

 

//Initialize ClientConfig

ClientConfig clientConfig = new ClientConfig();

//Set configuration features

clientConfig.register(new JacksonFeature());

clientConfig.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, 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">
<log>
<record>
    <date>2017-02-25T15:30:06</date>
    <millis>1488016806253</millis>
    <sequence>0</sequence>
    <logger>org.glassfish.jersey.client.JerseyInvocation</logger>
    <level>WARNING</level>
    <class>org.glassfish.jersey.client.JerseyInvocation</class>
    <method>validateHttpMethodAndEntity</method>
    <thread>1</thread>
    <message>Entity must not be null for http method PUT.</message>
</record>

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

 

Loading...