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 p
Include the following in the log4j.properties
file...
log4j.logger.org.springframework.ws.server.MessageTracing=DEBUG
log4j.logger.org.springframework.ws.client.MessageTracing=TRACE
On the DEBUG
level - only the payload root element is logged
On the TRACE
level - the entire message content is logged
Lastly to log only the sent or received messages use the .sent
or .received
at the end of the configurations.
ex : log4j.logger.org.springframework.ws.server.MessageTracing.received=DEBUG
logs the client-side received massages payload root element
returning :
DEBUG WebServiceMessageReceiverHandlerAdapter:114 - Accepting incoming [org.springframework.ws.transport.http.HttpServletConnection@51ad62d9] to [http://localhost:8080/mock-platform/services]
For more info
First, SLF4J is just a simple facade. It means you still need a logging framework(e.g. java.util.logging, logback, log4j).
Second, Spring-ws uses Commons Logging interface that is another simple facade like SLF4J.
Finally, you can use below setting to enable Spring-ws message logging functionality.
log4j.logger.org.springframework.ws.client.MessageTracing.sent=DEBUG
log4j.logger.org.springframework.ws.client.MessageTracing.received=TRACE
log4j.logger.org.springframework.ws.server.MessageTracing.sent=DEBUG
log4j.logger.org.springframework.ws.server.MessageTracing.received=TRACE
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
Add a servlet filter to the spring ws (to move with org.springframework.web.servlet.DispatcherServlet) in web.xml
you can find a filter here http://www.wetfeetblog.com/servlet-filer-to-log-request-and-response-details-and-payload/431
inside the filter you can log as you wish
This worked for me. It logs the request message sent and the response received. You could work out the total time taken from the log.
log4j.logger.org.springframework.ws.client.MessageTracing.sent=TRACE
log4j.logger.org.springframework.ws.client.MessageTracing.received=TRACE
You can use this to log the raw paylod of incoming and outgoing web service calls.. I'm not sure how to log how long the webservice communication took.
<!-- Spring Web Service Payload Logging-->
<logger name="org.springframework.ws.client.MessageTracing">
<level value="TRACE"/>
</logger>
<logger name="org.springframework.ws.server.MessageTracing">
<level value="TRACE"/>
</logger>
Additional details can be found at http://static.springsource.org/spring-ws/site/reference/html/common.html#logging