1
votes

In my application I would like to log request and response with business logic. Application does some backend logic with SOAP communication and this is what I want to log.

Unfornatly in this same application I must serve data ( avg. is 4 request/s) Let's say this service name is PlatformDataService.

How to turn off cxf logging for only one web service?

Enviorment:

  • JDK 8
  • cxf 2.7.14
  • AS : Jboss EAP 6.4

I turn on login on server by:

  • add logger org.apache.cxf INFO
  • and system property org.apache.cxf.logging.enabled=true
1

1 Answers

2
votes

You can extend LoggingInInterceptor and LoggingOutInterceptor. Based on the soapAction you can ignore only logging for one service.

Extend LoggingOutInterceptor for all the outbound requests and override method handleMessage like this.

private boolean doNotLog=false;

public void handleMessage(Message message) throws Fault {
    TreeMap<String,List> protocolHeaders =
            (TreeMap<String, List>) message.get("org.apache.cxf.message.Message.PROTOCOL_HEADERS");
    if (protocolHeaders != null) {
        List value = protocolHeaders.get("SOAPAction");
        String soapAction = value != null ? (String)value.get(0) : "";
        if (soapAction.equalIgnoreCase(YOUR_SERVICE_SOAP_ACTION)) {
            doNotLog=true;
        }
    }
    super.handleMessage(message);
}

Now there is one more method you have to override in the same class.

@Override
    protected String transform(String originalLogString) {
        if (doNotLog) {
            return null;
        }
        return originalLogString;
    } 

For all inbound responses, extend LoggingInInterceptor and only override transform method. You can just check the responseType from the originalLogString and ignore it.