简体   繁体   中英

Apache cxf file logging

I've configured CXF and now I want to use logging and configure it from xml without extra code. For this purpose, I've added this xml configuration to my appContext :

<import resource="classpath:META-INF/cxf/cxf.xml" />
    <bean class="org.apache.cxf.interceptor.LoggingInInterceptor" id="logInInterceptor" />
    <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor" id="logOutInterceptor" />
    <cxf:bus>
        <cxf:inInterceptors>
            <ref bean="logInInterceptor" />
        </cxf:inInterceptors>
        <cxf:outInterceptors>
            <ref bean="logOutInterceptor" />
        </cxf:outInterceptors>

    </cxf:bus>

    <jaxws:endpoint id="myServiceBean" implementor="com.mysite.webservice.myWSDLBean_Client" address="/mySearch">
    </jaxws:endpoint>

but it doesn't log anything during call, though when there is server deployment, I see that logInInterceptor and logOutInterceptor are mapped. What am I doing wrong?

And is there any way to configure writing logs to an external file (not to console) ?

Make the following changes and it should work for you -

  1. Add fault interceptors to your <cxf:bus> :

     <cxf:bus> . . . <cxf:outFaultInterceptors> <ref bean="loggingOutInterceptor"/> </cxf:outFaultInterceptors> <cxf:inFaultInterceptors> <ref bean="loggingInInterceptor"/> </cxf:inFaultInterceptors> </cxf:bus>`
  2. Add a file org.apache.cxf.Logger in your /META-INF/cxf with contents:

     org.apache.cxf.common.logging.Slf4jLogger
  3. In JBoss's standalone.xml , add the following property after <extensions> :

     <system-properties> <property name="org.apache.cxf.logging.enabled" value="true"/> </system-properties>`

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM