title: Logging request and response in one place with JAX-RS
body: <p>I have a RESTEasy web server with lot of methods. I want implement logback to track all requests and responses, but I don't want add <code>log.info()</code> to every methods.  </p>
  
  <p>Maybe there's way to catch requests and responses in one place and log it. Maybe something like a filter on HTTP request process chain on RESTEasy.</p>
  
  <pre><code>@Path("/rest")
  @Produces("application/json")
  public class CounterRestService {
  
      //Don't want use log in controler every method to track requests and responces
      static final Logger log = LoggerFactory.getLogger(CounterRestService.class); 
  
      @POST
      @Path("/create")
      public CounterResponce create(@QueryParam("name") String name) {
          log.info("create "+name)
          try {
              CounterService.getInstance().put(name);
              log.info("responce data"); // &lt;- :((
              return new CounterResponce();
          } catch (Exception e){
              log.info("responce error data"); // &lt;- :((
              return new CounterResponce("error", e.getMessage());
          }    
      }
  
      @POST
      @Path("/insert")
      public CounterResponce create(Counter counter) {
          try {
              CounterService.getInstance().put(counter);
              return new CounterResponce();
          } catch (Exception e){
              return new CounterResponce("error", e.getMessage());
          }
      }
  
      ...
  }
  </code></pre>