Home

Niklas Gawell
There is a newer version of this page. You can find it here.

Request tracing in jersey:

  • Add the setrace-jersey.jar and setrace-logging.jar to your classpath. If you use maven, just add:

    <dependency>
    <groupid>se.gawell</groupid>
    <artifactid>setrace-jersey</artifactid>
    <version>0.0.2</version>
    </dependency>

  • Add the following annotation to your resources:
    @ResourceFilters({ServletRequestTraceIdFilter.class})

  • Use the se.gawell.setrace.jersey.RequestTracingJerseyClient rather than com.sun.jersey.api.client.Client
  • Add %X{requestTraceId} to your log4j.xml. Example:

    <appender name="CONSOLE" class="">
    <layout class="">
    <param name="ConversionPattern" value="&lt;a class=" alink="" notfound"="" href="%25d%7Bdd/MM/yy%20hh%3Amm%3Ass%3Asss%20z%7D">%d{dd/MM/yy hh\:mm:ss:sss z} %X{requestTraceId} %5p %c{2}: %m%n" />
    </layout>
    </appender>


MongoDB Logo MongoDB