How can I make Spring WebServices log all SOAP requests?

前端 未结 7 1957
遇见更好的自我
遇见更好的自我 2020-12-04 16:43

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

相关标签:
7条回答
  • 2020-12-04 16:56

    Include the following in the log4j.properties file...

    1. To log all server-side messages: log4j.logger.org.springframework.ws.server.MessageTracing=DEBUG
    2. To log all client-side messages: 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

    0 讨论(0)
  • 2020-12-04 16:57

    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
    
    0 讨论(0)
  • 2020-12-04 17:01

    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
    
    0 讨论(0)
  • 2020-12-04 17:04

    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

    0 讨论(0)
  • 2020-12-04 17:08

    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
    
    0 讨论(0)
  • 2020-12-04 17:14

    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

    0 讨论(0)
提交回复
热议问题