mercredi 3 juin 2015

Custom Log Handler using HTTP PUT Method and creates loop

i working on a Java Webservice. We want to build our own Custom Log Service on Bluemix. To use the log service i created a custom Log handler.

The log handler builds the request in the publish method and then try to send via http put method the log to the log service.

url = new URL(REQUEST_URL);         
connection = (HttpsURLConnection) url.openConnection();
//Content type
connection.setRequestProperty("Content-type", "application/json");
// Request Method
connection.setRequestMethod("PUT");
// return parameter
connection.setRequestProperty("Accept", "application/json");

if (body != null) {
  String length = Integer.toString(body.length());
  connection.setRequestProperty("Content-Length", length);
  connection.setDoOutput(true);
  connection.getOutputStream().write(body.getBytes("UTF8"));
}   

But if i use the level FINE or FINEST the HTTPURLConnection logs too and builds a inifinite loop.

Jun 03, 2015 8:01:52 AM sun.net.www.protocol.http.HttpURLConnection getInputStream
FINE: sun.net.http://www.MessageHeader@d423078012 pairs: {null: HTTP/1.1 202 Accepted}{X-Backside-Transport: OK OK}{Connection: Keep-Alive}{Transfer-Encoding: chunked}{Access-Control-Allow-Origin: *}{Content-Language: en-US}{Content-Type: application/json}{Date: Wed, 03 Jun 2015 08:01:52 GMT}{X-Cf-Requestid: ec6a22e8-123a-4699-6cf9-6d3d80818dda}{X-Powered-By: Servlet/3.1}{X-Client-IP: 184.172.29.74}{X-Global-Transaction-ID: 460768451}

Jun 03, 2015 8:01:51 AM sun.net.www.protocol.http.HttpURLConnection plainConnect
FINEST: Proxy used: DIRECT

Have i a logical missthinking or exisit a workaround for this problem?

Aucun commentaire:

Enregistrer un commentaire