I have generated my service using CXF 3.1 wsdl2java, so no cxf.xml.
I am trying to add the request and response XML for the service to my log4j2 setup. There is a lot of conflicting information due to version changes etc. My request/response xml CXF logging file is always empty.
This was the closest to my setup: How to log CXF webservice requests with log4j2?
So I have the following in my log4j2.xml
<logger name="org.apache.cxf" additivity="false" level="info">
<AppenderRef ref="APP_LOG_FILE"/>
</logger>
<logger name="org.apache.cxf.interceptor.LoggingInInterceptor" additivity="false" level="info">
<AppenderRef ref="WS_LOG_FILE" />
</logger>
<logger name="org.apache.cxf.interceptor.LoggingOutInterceptor" additivity="false" level="info">
<AppenderRef ref="WS_LOG_FILE" />
</logger>
Not showing the appenders, but they are there, the APP_LOG_FILE is populated but the WS_LOG_FILE appender files is always empty, while messages being exchanged.
I added a META-INF/cxf/org.apache.cxf.Logger file with this content
org.apache.cxf.common.logging.Slf4jLogger
I also tried using the additional command line parameter when running my jar as an alternative to the cxf.Logger file:
-Dorg.apache.cxf.Logger=org.apache.cxf.common.logging.Slf4jLogger
I added the additional dependency:
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.0</version>
</dependency>
I tried the following both with the logging interceptors (are they required or an alternative to the config in the log4j2.xml?) and without them, as shown currently commented out.
GetComparisonDecisionService equinitiComparisonService = new GetComparisonDecisionService();
GetComparisonDecisionInterface comparison = equinitiComparisonService.getGetComparisonDecision();
/*
Client client = ClientProxy.getClient(equinitiComparisonService.getPort(GetComparisonDecisionInterface.class));
client.getInInterceptors().add(new LoggingInInterceptor());
client.getOutInterceptors().add(new LoggingOutInterceptor());
*/
GetComparisonDecisionCallParameter comparisonDecisionCallParameter = new GetComparisonDecisionCallParameter();
comparisonDecisionCallParameter.setSecurityToken(token);
comparisonDecisionCallParameter.setComparisonApplication(equinitiApp);
GetComparisonDecisionResponseParameter eqDescn = comparison.getComparisonDecision(comparisonDecisionCallParameter);
I have run out of ideas at this point. The cxf documentation is very terse.
As requested as an answer: Setting the LoggingInterceptors the way you show in the last code-fragment is recommended for CXF < 3.1. You should use the @Feature-Annotation like this: @Features(features = "org.apache.cxf.feature.LoggingFeature")
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With