Ismayil Ibrahimov
Ismayil Ibrahimov

Reputation: 588

How to log soap request and response with custom messages to file in Spring Boot?

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.

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.

application.properties

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
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 {
                    }
                }}
        );

The log entries should be as follows:

[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

you can check project: https://github.com/ismayilibrahimov/calculatorservice

Upvotes: 3

Views: 5687

Answers (1)

Ismayil Ibrahimov
Ismayil Ibrahimov

Reputation: 588

I've re-imported all maven projects then "maven clean and install" solved my problem. I can see message from handleRequest method in the console now.

Upvotes: 2

Related Questions