<bean id="loggingInInterceptor" class="org.apache.cxf.interceptor.LoggingInInterceptor"/> <bean id="loggingOutInterceptor" class="org.apache.cxf.interceptor.LoggingIOutInterceptor"/> <jaxws:endpoint id="service1" implementor="#springService1" address="/service1"> <jaxws:inInterceptors> <ref bean="logginInInterceptor"/> </jaxws:inInterceptors> <jaxws:outInterceptors> <ref bean="loggingOutInterceptor"/> </jaxws:inInterceptors> </jaxws:endpoint> <jaxws:endpoint id="service2" implementor="#springService2" address="/service2"> <jaxws:inInterceptors> <ref bean="logginInInterceptor"/> </jaxws:inInterceptors> <jaxws:outInterceptors> <ref bean="loggingOutInterceptor"/> </jaxws:inInterceptors> </jaxws:endpoint>
The trick is that CXF prints each message in a specify log category, based in the service name, port name and portTypeName. These parameters are part of the own service configuration, so they will be unique for each web service.
You can see their values in the logging message (the minimum log level required is INFO). For example:
20:54:19,421 INFO [stdout] (http-localhost/127.0.0.1:8080-2) [2016-06-25 20:54:19,420] (AbstractLoggingInterceptor.java:249) INFO http-localhost/127.0.0.1:8080-2 org.apache.cxf.services.service1.MyService1WebServiceImplPort.MyService1WebService Inbound Message ...
You can handle these categories by using your log configuration, for example, with log4j:
<logger name="org.apache.cxf.services.service1"> <level value="INFO" /> <appender-ref ref="FILE1" /> </logger> <logger name="org.apache.cxf.services.service2"> <level value="INFO" /> <appender-ref ref="FILE2" /> </logger>
No hay comentarios:
Publicar un comentario