title: How to log soap request and response with custom messages to file in Spring Boot?
body: <p>I have created rest service as wrapper for soap service in Spring Boot 2.1.7, and I need log soap request and response (also rest request) with date and custom message to file.</p>
  
  <p>I've tried to get some message from handleRequest method (System.out.println("message from handleRequest")), but no any message in console or file. If you have another solution for this task please don't hestitate to offer.</p>
  
  <p>application.properties</p>
  
  <pre class="lang-java prettyprint-override"><code>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
  logging.file=consumeservice.log
  logging.pattern.file=%d{dd.MM HH:mm:ss} - %msg%n
  </code></pre>
  
  <pre class="lang-java prettyprint-override"><code>getWebServiceTemplate().setInterceptors(
                  new ClientInterceptor[]{new ClientInterceptor() {
  
                      @Override
                      public boolean handleRequest(MessageContext messageContext) throws WebServiceClientException {
                          System.out.println("message from handleRequest"); // I can not see this message in console or file
  
                          return true;
                      }
  
                      @Override
                      public boolean handleResponse(MessageContext messageContext) throws WebServiceClientException {
                          return true;
                      }
  
                      @Override
                      public boolean handleFault(MessageContext messageContext) throws WebServiceClientException {
                          return true;
                      }
  
                      @Override
                      public void afterCompletion(MessageContext messageContext, Exception ex) throws WebServiceClientException {
                      }
                  }}
          );
  </code></pre>
  
  <p>The log entries should be as follows:</p>
  
  <pre><code>[dd.MM HH:mm:ss] - Call 1. Request to JSON
  [dd.MM HH:mm:ss] - Call 1. Request to SOAP
  [dd.MM HH:mm:ss] - Call 1. Response from SOAP
  [dd.MM HH:mm:ss] - Call 2. Request to JSON
  [dd.MM HH:mm:ss] - Call 2. Request to SOAP
  [dd.MM HH:mm:ss] - Call 2. Response from SOAP
  </code></pre>
  
  <p>you can check project: <a href="https://github.com/ismayilibrahimov/calculatorservice" rel="nofollow noreferrer">https://github.com/ismayilibrahimov/calculatorservice</a></p>