In a Spring Boot application using the spring-boot-starter-actuator loggers endpoint, setting the web log group, or any of it's individual member loggers, to debug level doesn't have any effect for RestTemplate logging.

We would like to be able to use the loggers endpoint to change the web log group logger levels on a deployed application in order to see web related debug logging.

It appears HttpAccessor is using an org.springframework.core.log.CompositeLog which initializes at application startup to current log levels, so adjusting the log levels through the actuator loggers endpoint doesn't have the desired effect.

Steps to duplicate:

Create a Spring Boot application using spring-initializr with spring-boot-starter-web and spring-boot-starter-actuator. I am using Spring Boot 2.6.7

In application.properties, set:

logging.level.web=debug

Application code

@SpringBootApplication
@RestController
public class DemoApplication {

  private final RestTemplate restTemplate;

  public DemoApplication(RestTemplateBuilder builder) {
    this.restTemplate = builder.build();
  }

  @GetMapping
  public String doSomething() {
    return restTemplate.getForEntity("https://httpbin.org/get", String.class).getBody();
  }

  public static void main(String[] args) {
    SpringApplication.run(DemoApplication.class, args);
  }

}

Startup the application and execute:

curl --location --request GET 'localhost:8080/'

You should see the [RestTemplate] related logging in the application console.

Now comment out the logger line in application.properties and restart the application.

Now set the logger level after application startup using the actuators endpoint

curl --location --request POST 'http://localhost:8080/actuator/loggers/web' \
--header 'Content-Type: application/json' \
--data-raw '{
  "configuredLevel": "DEBUG"
}'

Call the endpoint again

curl --location --request GET 'localhost:8080/'

Outcome

No [RestTemplate] related logging occurs.

Comment From: philwebb

I've transferred this issue to the framework team since I think changes will be needed to CompositeLog to account for the fact that a Log instance be reconfigured (regardless of if it's by Spring Boot or something else).

Comment From: philwebb

I think we'll need to do something like this. We should also add some tests.