如何让 Spring WebServices 记录所有 SOAP 请求? [英] How can I make Spring WebServices log all SOAP requests?
问题描述
我需要在 CommonLogFormat
中记录所有 SOAP 请求(参见 http://en.wikipedia.org/wiki/Common_Log_Format),加上持续时间(处理请求所需的时间).
I need all SOAP requests logged in the CommonLogFormat
(see http://en.wikipedia.org/wiki/Common_Log_Format), plus the duration (the amount of time it takes to process the request).
这样做的最佳方法是什么?看起来可以为 Spring WebServices 配置 log4j,但它会记录我感兴趣的所有值吗?http://pijava.wordpress.com/2009/12/04/spring-webservice-soap-requestresponse-logging-with-log4j/
What's the best way to do this? It looks like it's possible to configure log4j for Spring WebServices but will it log all the values I'm interested in? http://pijava.wordpress.com/2009/12/04/spring-webservice-soap-requestresponse-logging-with-log4j/
我们实际上使用的是 SLF4J
,而不是 Log4j
.此外,看起来可以通过配置 PayloadLoggingInterceptor 来做到这一点:http://static.springsource.org/spring-ws/site/reference/html/server.html#server-endpoint-interceptor
We're actually using SLF4J
, not Log4j
. Also, it looks like it's possible to do this by configuring the PayloadLoggingInterceptor:
http://static.springsource.org/spring-ws/site/reference/html/server.html#server-endpoint-interceptor
但我不确定日志消息会去哪里.我将该拦截器添加到我们的拦截器中,但我没有看到任何日志消息.
But I am not sure where the log messages will go. I added that interceptor to our interceptors and I don't see any log messages.
推荐答案
对于 Spring Boot 项目,在 application.properties
中添加以下对我有用:
For Spring Boot project adding below in application.properties
worked for me:
logging.level.org.springframework.web=DEBUG
logging.level.org.springframework.ws.client.MessageTracing.sent=DEBUG
logging.level.org.springframework.ws.server.MessageTracing.sent=DEBUG
logging.level.org.springframework.ws.client.MessageTracing.received=TRACE
logging.level.org.springframework.ws.server.MessageTracing.received=TRACE
这篇关于如何让 Spring WebServices 记录所有 SOAP 请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!