springboot自动更新日志的打印级别

添加依赖

spring-boot-starter-actuator是springboot提供用于监控和管理生产环境的模块

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

暴露日志结点

在application.properties文件中加入:

#暴露loggers这个endpoint
management.endpoints.web.exposure.include=health,info,loggers

查看日志级别信息

发送请求:

方式:GET

URL:http://localhost:18850/actuator/loggers

更新日志级别

请求方式:POST

URL:http://localhost:18850/actuator/loggers/ROOT

HEADER : Content-Type:application/json

BODY : {"configuredLevel":"DEBUG"}

就可以动态的刷新日志级别啦!!

以上内容均是自己亲自测试可以实现

原文地址:https://www.cnblogs.com/woxbwo/p/11256053.html