title: How to log request body in JAX-RS client
body: <p>I need to see my request body with a client JAX-RS request in order to verify that the serialization works correct and reuse the request for test clients like <a href="https://www.getpostman.com/" rel="noreferrer">Postman</a>.</p>
  
  <p>I know it's possible to activate logging with Jersey using for example <code>resource.addFilter(new com.sun.jersey.api.client.filter.LoggingFilter());</code>. However, I don't use Jersey or RESTEasy implementation directly, but abstracted via JAX-RS API:</p>
  
  <pre><code>final WebTarget target = 
          ClientBuilder.newBuilder().build().target("http://localhost:8080");
  </code></pre>
  
  <p>How can I enable logging here?</p>
  
  <hr>
  
  <h1>Result</h1>
  
  <p><a href="https://stackoverflow.com/a/30195076/2854723">The answer from @peeskillet</a> + <a href="http://1987.io/questions/3342335/get-request-body-of-my-request" rel="noreferrer">this snippet</a>.</p>
  
  <p>However sometimes the <code>close()</code> method from the snippet is not being invoked by the JAX-RS implementation (<code>org.jboss.resteasy:resteasy-client-3.0.11.FINAL</code> in this case).</p>