java - Custom Log Handler using HTTP PUT Method and creates loop -


i working on java webservice. want build our own custom log service on bluemix. use log service created custom log handler.

the log handler builds request in publish method , try send via http put method log 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 use level fine or finest httpurlconnection logs , builds inifinite loop.

jun 03, 2015 8:01:52 sun.net.www.protocol.http.httpurlconnection getinputstream fine: sun.net.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 sun.net.www.protocol.http.httpurlconnection plainconnect finest: proxy used: direct 

have logical missthinking or exisit workaround problem?

a simple solution configure logger not log messages or use higher level (such info) urlconnection class or whole package. see http://docs.oracle.com/javase/7/docs/api/java/util/logging/logmanager.html on how java.util.logging.

if app running on liberty buildpack in bluemix, can try use liberty's server.xml configure log levels, see http://www-01.ibm.com/support/knowledgecenter/ssd28v_8.5.5/com.ibm.websphere.wlp.core.doc/ae/rwlp_logging.html. can push server folder or server package include server.xml in app package.


Comments