title: Capture Response Payload in JAX-RS filter
body: <p>I want to capture and log the response payload in JAX-RS filter. Here is the code snippet of the filter method that I'm using to intercept the response. (FYI - I'm using RestEasy for implementation)</p>
  
  <pre><code>@Override
  public void filter(final ContainerRequestContext requestContext, final ContainerResponseContext         responseContext) throws IOException {
      ...
        final OutputStream out = responseContext.getEntityStream();
         try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
                 out.write(baos.toByteArray());
          ....
     }
  }
  </code></pre>
  
  <p>However, the ByteArrayOutputStream turns out be empty. Looking at the RestEasy code, it's using DeferredOutputStream, but not sure how it would matter here in pulling the response payload. I have tried writing to byte[] directly, but that doesn't help either. Am I missing anything here ? Thanks.</p>