title: How to log Apache CXF Soap Request and Soap Response using Log4j?
body: <p>I am using the Apache CXF Framework.
  Inside my client program, I need to log CXF SOAP Requests and SOAP Responses.
  When I used </p>
  
  <pre class="lang-java prettyprint-override"><code>JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
  factory.setAddress(host);
  factory.setServiceClass(MyService.class);
  factory.getInInterceptors().add(new LoggingInInterceptor());
  factory.getOutInterceptors().add(new LoggingOutInterceptor());
  </code></pre>
  
  <p>I got these SOAP Request and SOAP Responses in the console:</p>
  
  <pre><code>Nov 9, 2011 6:48:01 PM org.apache.cxf.interceptor.LoggingOutInterceptor$LoggingCallback onClose
  INFO: Outbound Message
  ---------------------------
  ID: 2
  Encoding: UTF-8
  Content-Type: text/xml
  Headers: {}
  Payload: &lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;&lt;soap:Body&gt;&lt;ns4:MYResponse
  --------------------------------------
  </code></pre>
  
  <p>But my actual requirement is, instead of printing them to the server console, I need to have them inside the log file.</p>
  
  <p>When I used log4j directly as shown </p>
  
  <pre class="lang-java prettyprint-override"><code>log4j(factory.getInInterceptors().add(new LoggingInInterceptor()));
  log4j(factory.getOutInterceptors().add(new LoggingOutInterceptor()));
  </code></pre>
  
  <p>It is only printing <code>true</code> and <code>true</code> inside the log file.</p>
  
  <p>Could anybody please let me know how to configure this?</p>