47

I'm trying to debug my app today but the spring boot console displays the following message:

enableLoggingRequestDetails='false': request parameters and headers will be masked to prevent unsafe logging of potentially sensitive data

Meanwhile, I want to know everything that is going on in the app.

So my question is: How can I enable logging request details in application.properties?

4
  • 8
    add spring.http.log-request-details=true to your application.properties. Assuming you are using Spring Boot 2.1 here. Commented Dec 11, 2018 at 12:00
  • @M.Deinum you solved it. Please Add you comment as an answer so that i will mark it, that way other people will easily find it. Thank you! Commented Dec 11, 2018 at 12:11
  • @AdinduStevens It's working fine, but I don't have any informations about the request... Do you have to configure something else ? Commented Dec 20, 2018 at 8:19
  • 1
    @Phoste You need to also configure the web logging level to DEBUG or any lower level: logging.level.web: DEBUG Commented Mar 14, 2019 at 17:32

6 Answers 6

75

For Spring Boot 2.1 and below use

logging.level.org.springframework.web=DEBUG
spring.http.log-request-details=true

For Spring Boot 2.2 and above spring.http.log-request-details has been deprecated so use

logging.level.org.springframework.web=DEBUG
spring.mvc.log-request-details=true

in your application.properties if you want to see loggingRequestDetails.

From the documentation:

Whether logging of (potentially sensitive) request details at DEBUG and TRACE level is allowed.

Sign up to request clarification or add additional context in comments.

3 Comments

one point of clarification for those who didn't catch on quickly (like me): If you are not using application.properties and using another framework for app configuration, then set these values in your app config.. where ever that may be.
Property spring.http.log-request-details is Deprecated: Use spring.mvc.log-request-details instead.
Note that you need use TRACE instead of DEBUG if you want to the headers to be logged.
12

When using webflux and spring boot 2.3.0 the following properties can be set to log request details.

logging.level.org.springframework.web.server.adapter.HttpWebHandlerAdapter=DEBUG
spring.codec.log-request-details=true

Comments

3

for spring boot v2.6.2 you can use this: spring.mvc.log-request-details=true and make sure also you have logging.level.org.springframework.web=DEBUG

2 Comments

This answer is already added as a comment in the accepted answer.
@AdinduStevens which is wrong. answers should be added in answers, not in comments. comments are always subject to removal.
3

With Springboot 3 in order to get request logs from org.springframework.web.reactive.function.client.WebClient

Without header just add trace logs of class ExchangeFunctions in application.yml

logging:
  level:
    org.springframework.web.reactive.function.client.ExchangeFunctions: trace

Example

2023-11-03T13:21:29.907-04:00 TRACE [...] 14608 --- [nio-8080-exec-1] o.s.w.r.f.client.ExchangeFunctions       : [652413fc] HTTP GET https://......, headers={masked}

With headers, set log details for codecs in application.yml

spring:
  codec:
    log-request-details: true

Example

2023-11-03T13:39:52.459-04:00 TRACE [...] 5872 --- [nio-8080-exec-2] o.s.w.r.f.client.ExchangeFunctions       : [4a841d85] HTTP GET https://......., headers=[Accept:"application/json", Authorization:"Bearer .....", X-B3-TraceId:"...", X-B3-SpanId:"...", X-B3-ParentSpanId:"...", X-B3-Sampled:"0"]

Comments

2

If you are using WebFlux turn on the enableLoggingRequestDetails='true' you can by adding:

@Configuration
@EnableWebFlux
public class WebFluxConfig implements WebFluxConfigurer {

    @Override
    public void configureHttpMessageCodecs(ServerCodecConfigurer configurer) {
        configurer.defaultCodecs().enableLoggingRequestDetails(true);
    }
}

And setting the config param:

debug:
  logging.http-requests: true
  
logging:
  level:
    ROOT: INFO
    org:
      springframework:
        web: 
          server:
            adapter:
              HttpWebHandlerAdapter: TRACE

Comments

0

spring boot version is 2.2.6.RELEASE.This configuration item below helps me solve the problem.
spring.http.log-request-details=true

1 Comment

Thanks. Who would have thought there would be soo many ways?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.