Adindu Stevens
Adindu Stevens

Reputation: 3567

How to set enableLoggingRequestDetails='true' in Spring Boot

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?

Upvotes: 46

Views: 40793

Answers (6)

Arigion
Arigion

Reputation: 3548

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.

Upvotes: 74

Drakta
Drakta

Reputation: 21

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"]

Upvotes: 2

engilyin
engilyin

Reputation: 1100

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

Upvotes: 1

FRIVEROS
FRIVEROS

Reputation: 61

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

Upvotes: 3

ApeJungle
ApeJungle

Reputation: 19

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

Upvotes: 0

Doctor Parameter
Doctor Parameter

Reputation: 1211

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

Upvotes: 11

Related Questions