java - How to turn on tracing in Jersey WS calls, when using Guice servlet configuation -
i'm trying turn on tracing debug jersey ws call. tried adding init-param described here, both in guice servlet config , in web.xml, can't seem work.
here's guice servlet config looks like:
public class guiceservletconfig extends guiceservletcontextlistener { private static final logger log = loggerfactory.getlogger(guiceservletconfig.class); public guiceservletconfig() { super(); log.debug("creating guiceservletconfig"); } private static class servletmodule extends jerseyservletmodule { private inputstream getinputstream() throws filenotfoundexception { file file = new file("tmp"); string pathtotempfile = file.getabsolutepath(); log.debug("path config: {}", pathtotempfile); string pathwithouttmp = pathtotempfile.substring(0, pathtotempfile.indexof(file.separator + "tmp")); stringbuilder stringbldr = new stringbuilder(pathwithouttmp) .append(file.separator).append("extensions") .append(file.separator).append("__lib__") .append(file.separator).append("gelato.config.properties"); log.debug("loading guice properties from: {}", stringbldr.tostring()); return new fileinputstream(new file(stringbldr.tostring())); } @override protected void configureservlets() { properties properties = new properties(); try { inputstream = getinputstream(); properties.load(is); names.bindproperties(binder(), properties); } catch (exception ex) { log.error("error binding properties: {}", ex.tostring()); } // must configure @ least 1 jax-rs resource or // server fail start. // must configure @ least 1 jax-rs resource or // server fail start. bind(userresource.class); bind(playersmanager.class).to(gelatoplayersmanager.class); bind(messagehandler.class).to(sfsmessagehandler.class); map<string, string> params = new hashmap<string, string>(); params.put(packagesresourceconfig.property_packages, "org.buffalo.gelato.resources"); // route requests through guicecontainer params.put("com.sun.jersey.config.feature.trace", "true"); serve("/rest/*").with(guicecontainer.class, params); } }
and tried putting in web.xml, suppose ignored, since i'm configured jersey via guice.
<servlet> <servlet-name>jersey rest service value codes</servlet-name> <servlet-class>com.sun.jersey.spi.container.servlet.servletcontainer</servlet-class> <init-param> <param-name>com.sun.jersey.config.feature.trace</param-name> <param-value>true</param-value> </init-param> </servlet>
if want see log message in server log (your first configuration of tracing right one), need add resourceconfig.property_container_request_filters and/or resourceconfig.property_container_response_filters properties configuration, like:
params.put(resourceconfig.property_container_request_filters, com.sun.jersey.api.container.filter.loggingfilter.class); params.put(resourceconfig.property_container_response_filters, com.sun.jersey.api.container.filter.loggingfilter.class);
see javadoc of container loggingfilter.
Comments
Post a Comment