Search code examples
spring-webfluxspring-cloudspring-cloud-gateway

Enable HTTP request/response logging in Spring-cloud-gateway


I need to check the details of the HTTP request/response. I notice that I can see the log by setting to true enableLoggingRequestDetails in HttpWebHandlerAdapter. I don't understand what the correct configuration is for getting the details.

I obtain this:

org.springframework.web.server.adapter.HttpWebHandlerAdapter                     : enableLoggingRequestDetails='false': form data and headers will be masked to prevent unsafe logging of potentially sensitive data

Solution

  • I fixed it with this configuration:

    @Configuration
    public class WebFluxConfig implements WebFluxConfigurer {
    
        @Override
        public void configureHttpMessageCodecs(ServerCodecConfigurer configurer) {
            configurer.defaultCodecs().enableLoggingRequestDetails(true);
        }
    }