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:
I turn on login on server by:
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.