0

I am trying to log my rest service as below in cxf.xml,

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxrs="http://cxf.apache.org/jaxrs"
    xmlns:cxf="http://cxf.apache.org/core"
    xsi:schemaLocation="
    http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://cxf.apache.org/jaxrs
    http://cxf.apache.org/schemas/jaxrs.xsd">

    <jaxrs:server id="base" address="/Restful">

    <jaxrs:serviceBeans>
         <ref bean="Service" />
    </jaxrs:serviceBeans>

    <jaxrs:features>
         <cxf:logging />
    </jaxrs:features>

    </jaxrs:server>

    <bean id="Service" class="com.xxx.yyy.services.ServiceImpl" />

    </beans>

In console it prints only Outbound message as below,

Nov 27, 2015 3:36:47 PM org.apache.cxf.interceptor.LoggingOutInterceptor
    INFO: Outbound Message
    ---------------------------
    ID: 1
    Response-Code: 200
    Content-Type: text/plain
    Headers: {Content-Type=[text/plain], Date=[Fri, 27 Nov 2015 10:06:47 GMT]}
    Payload: your request has been proceed..
    --------------------------------------

Question,

It would be appreciated if you could let me know how to enable Inbound message as well?

Additional details,

CXF 3.1.4 Java 7

Thanks,

sasikals26
  • 835
  • 2
  • 18
  • 41

2 Answers2

0

Please refer the stackoverflow link How to log Apache CXF Soap Request and Soap Response using Log4j

Also, Apache CFX web site Apache CXF section "Enabling message logging using plain Spring bean elements"

Hope this helps!

Community
  • 1
  • 1
Shruthi Rao
  • 15
  • 1
  • 1
  • 7
  • Thanks for the response, 1. The stackoverflow link provided is regarding SOAP service. 2. I have referred the Apache CXF link already , However when i tried it i got the below exception while using bus--> Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cxf': Cannot resolve reference to bean 'cxf.config0' while setting bean property 'busConfig'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'cxf.config0' is defined – sasikals26 Nov 27 '15 at 11:30
0

You can set configuration like this:

  <?xml version="1.0" encoding="UTF-8"?>
  <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:cxf="http://cxf.apache.org/core" xsi:schemaLocation="http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">


<bean id="abstractLoggingInterceptor" abstract="true">
    <property name="prettyLogging" value="true"/>
</bean>
<bean id="loggingInInterceptor" class="org.apache.cxf.interceptor.LoggingInInterceptor" parent="abstractLoggingInterceptor"/>
<bean id="loggingOutInterceptor" class="org.apache.cxf.interceptor.LoggingOutInterceptor" parent="abstractLoggingInterceptor"/>



    <jaxrs:server id="base" address="/Restful">

    <jaxrs:serviceBeans>
         <ref bean="Service" />
    </jaxrs:serviceBeans>

    <jaxrs:inInterceptors>
       <ref bean="loggingInInterceptor"/>
    </jaxrs:inInterceptors>
    <jaxrs:outInterceptors>
       <ref bean="loggingOutInterceptor"/>
    </jaxrs:outInterceptors>
    <jaxrs:outFaultInterceptors>
       <ref bean="loggingOutInterceptor"/>
    </jaxrs:outFaultInterceptors>
    <jaxrs:inFaultInterceptors>
       <ref bean="loggingInInterceptor"/>
    </jaxrs:inFaultInterceptors>

    </jaxrs:server>

    <bean id="Service" class="com.xxx.yyy.services.ServiceImpl" />

    </beans>
Richard Kotal
  • 179
  • 1
  • 8