title: Implementing custom logging for Dropwizard resources
body: <p>I have a dropwizard application with multiple resources. I need to implement some custom logging which should be the same for all resources and should contain things like URL, response time, response size and some data extracted from the request header. Generally, I would like to be able to specify what exactly I want there and in what format. I don't want to have to add code to any of the resources (because there is 50+ of them).</p>
  
  <p>I did some searching and found a few interesting articles but I don't know how to implement it - a few things I tried didn't work:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/27356918/drop-wizard-request-response-logging">Drop-wizard request response logging</a></li>
  <li><a href="https://docs.codehaus.org/display/JETTY/Logging+Requests" rel="nofollow noreferrer">https://docs.codehaus.org/display/JETTY/Logging+Requests</a></li>
  <li><a href="http://jersey.576304.n2.nabble.com/Logging-HTTP-Body-of-Request-td7580414.html" rel="nofollow noreferrer">http://jersey.576304.n2.nabble.com/Logging-HTTP-Body-of-Request-td7580414.html</a></li>
  </ul>
  
  <p>I considered using aspect oriented programming, as all resources return <code>Response</code>, but <code>AspectJ</code> requires <code>Spring</code> which I don't want to bring into the project only for that reason.</p>
  
  <p>I have also found <code>InstrumentedHandler</code> in Dropwizard's metrics, with <a href="http://tech.gilt.com/post/50426747760/monitoring-network-traffic-and-service-chatter" rel="nofollow noreferrer">this article</a> it looks like exactly something that I need, but I cannot find any example how to plug it to the application.</p>
  
  <p>Do you have any suggestions how to implement this logging?</p>