how do I change log level in runtime without restarting spring boot application

后端 未结 10 996
北荒
北荒 2020-12-23 19:55

I have deployed springboot application in PCF . I want to log the message based on the environment variable .What should I do so that the run time log level change will work

10条回答
  •  再見小時候
    2020-12-23 20:19

    Changing the log level in Spring Boot 1.5+ can be done with a http-endpoint

    Add

    
        org.springframework.boot
        spring-boot-starter-actuator
    
    

    and than you can use

    curl -X "POST" "http://localhost:8080/loggers/de.springbootbuch" \
         -H "Content-Type: application/json; charset=utf-8" \
         -d $'{
      "configuredLevel": "WARN"
    }'  
    

    Where everything beyond /loggers/ is the name of the logger.

    If you running this in PCF it get's even better: This is directly supported from their backend.

提交回复
热议问题