您可以擴展LoggingInInterceptor
和LoggingOutInterceptor
。基於soapAction
,您可以忽略僅記錄一項服務。
針對所有出站請求和覆蓋方法handleMessage
擴展LoggingOutInterceptor
這樣。
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);
}
現在還有一種方法需要在同一個類中重寫。
@Override
protected String transform(String originalLogString) {
if (doNotLog) {
return null;
}
return originalLogString;
}
對於所有入站響應,延伸LoggingInInterceptor
和僅覆蓋變換方法。你可以檢查originalLogString的responseType並忽略它。
非常感謝,我會試試這個解決方案 –