title: cxf inbound and outbound message logging to the separate log file
body: <p>I looked up all messages but did not find a clear answer for that question.</p>
  
  <p>How can I configure logging to log CXF inbound and outbound restful messages ?</p>
  
  <p>I have the following setup.</p>
  
  <ul>
  <li><p>File org.apache.cxf.Logger with</p>
  
  <pre><code>org.apache.cxf.common.logging.Log4jLogger
  </code></pre></li>
  <li><p>applicationContext.xml has the following (it sounds silly, but it is the only place for interceptors I could get messages output)</p>
  
  <pre><code>&lt;bean id="abstractLoggingInterceptor" abstract="true"&gt;
  &lt;property name="prettyLogging" value="true"/&gt;
  &lt;/bean&gt;
  &lt;bean id="loggingInInterceptor" class="org.apache.cxf.interceptor.LoggingInInterceptor"
  parent="abstractLoggingInterceptor"/&gt;
  &lt;bean id="loggingOutInterceptor" class="org.apache.cxf.interceptor.LoggingOutInterceptor"
  parent="abstractLoggingInterceptor"/&gt;
  
  &lt;cxf:bus&gt;
  &lt;cxf:inInterceptors&gt;
  &lt;ref bean="loggingInInterceptor"/&gt;
  &lt;/cxf:inInterceptors&gt;
  &lt;cxf:outInterceptors&gt;
  &lt;ref bean="loggingOutInterceptor"/&gt;
  &lt;/cxf:outInterceptors&gt;
  &lt;cxf:outFaultInterceptors&gt;
  &lt;ref bean="loggingOutInterceptor"/&gt;
  &lt;/cxf:outFaultInterceptors&gt;
  &lt;cxf:inFaultInterceptors&gt;
  &lt;ref bean="loggingInInterceptor"/&gt;
  &lt;/cxf:inFaultInterceptors&gt;
  &lt;/cxf:bus&gt;
  </code></pre></li>
  </ul>
  
  <p>I tried to follow these instructions with slf4j and with log4j, but the the only output I get to the file is application log messages. I can see inbound and outbound messages on my console.</p>
  
  <p>Can I get something similar to logback.xml work for me, so I separate app logs and message logs. Example: <a href="http://www.wolfe.id.au/2011/05/20/apache-cxf-logging/" rel="nofollow">http://www.wolfe.id.au/2011/05/20/apache-cxf-logging/</a></p>
  
  <p>Thanks.</p>
  
  <p><strong>EDIT 1:</strong>
  I removed  org.apache.cxf.common.logging.Log4jLogger from my classpath, and placed the following to my log4j.xml. It logging to the file and to console when the level of logging is equal to INFO.</p>
  
  <pre><code>&lt;appender name="RSLOGFILE" class="org.apache.log4j.RollingFileAppender"&gt;
  &lt;param name="file" value="${project.basedir}/logs/cxf_inout_messages.log"/&gt;
  &lt;param name="MaxFileSize" value="100KB"/&gt;
  &lt;!-- Keep one backup file --&gt;
  &lt;param name="MaxBackupIndex" value="1"/&gt;
  &lt;layout class="org.apache.log4j.PatternLayout"&gt;
  &lt;!-- Print the date in ISO 8601 format --&gt;
  &lt;param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n"/&gt;
  &lt;/layout&gt;
  &lt;/appender&gt;
  &lt;logger name="org.apache.cxf"&gt;
  &lt;level value="ERROR"/&gt;
  &lt;appender-ref ref="RSLOGFILE"/&gt;
  &lt;/logger&gt;
  </code></pre>