views:

58

answers:

1

In CXF, you can enable logging using this:

<cxf:bus>
   <cxf:features>
      <cxf:logging/>
   </cxf:features>
</cxf:bus>

Source: http://cxf.apache.org/docs/configuration.html

Everything seems to go to files or console and can be configured using Log4j as well it seems.

My question is, how do you enable logging on server side so that you can intercept these raw requests and responses and store them in a table in the database along with other application specific information related to the service call.

This is all for server-side service implementation class.

A: 

The example you quoted was the simplest possible config to do basic logging. If you look at the example right before, you can see a slightly more expanded approach to logging interceptors:

<cxf:bus>
    <cxf:inInterceptors>
        <ref bean="logInbound"/>
    </cxf:inInterceptors>
    <cxf:outInterceptors>
        <ref bean="logOutbound"/>
    </cxf:outInterceptors>
    <cxf:inFaultInterceptors>
        <ref bean="logOutbound"/>
    </cxf:inFaultInterceptors>
</cxf:bus> 

Here, the logInbound, logOutbound and logOutbound beans are any implementation of CXF's interceptor interface. You can implement your own interceptor beans to do any type of logging you choose, including database logging.

skaffman