Apache CXF LoggingInInterceptor is deprecated - what to use instead?
Basically 4 things are needed to update from the old to the new cxf logging (rt/features/logging).
First, Set the logging feature:
final JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setFeatures(Collections.singletonList(new CustomLoggingFeature()));
You don't need anymore the interceptors (in case you used them, delete them):
factory.getInInterceptors().add(new CustomMaskedLoggingInInterceptor());
factory.getOutInterceptors().add(new CustomMaskedLoggingOutInterceptor());
Second, create your LoggingFeature:
public class CustomLoggingFeature extends org.apache.cxf.ext.logging.LoggingFeature {
public CustomLoggingFeature() {
super();
this.setSender(new CustomEventLogSender());
}
}
Third, create your EventLogSender:
public class CustomEventLogSender extends Slf4jVerboseEventSender {
@Override
protected String getLogMessage(LogEvent event) {
String logMessage = super.getLogMessage(event);
return CustomMasker.mask(logMessage);
}
}
Fourth, create a CustomMasker class where you have your own string manipulation logic to mask the desired information.
Let me know if it worked!
What this message is telling you, is to use the Apache CXF Advanced logging feature
module.
Its dependency is (latest version)
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-features-logging</artifactId>
<version>3.3.0</version>
<scope>test</scope>
</dependency>
Inside you'll find a comparable org.apache.cxf.ext.logging.LoggingInInterceptor
(link)
I'm not a CXF user, however I suppose you'll have to interact with a JaxWsProxyFactoryBean
.
Remember you need to use the same version for all the CXF modules.
After getting an hold on it, you can do
factory.getInInterceptors().add(new MyCustomInterceptor());