- 首先需要在项目中添加 actuator 依赖
1
2
3
4<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency> - actuator 默认暴露的http端口只有 info 和 health,需要把 loggers 端点暴露出来
1
2
3
4
5management:
endpoints:
web:
exposure:
include: health, info, loggers - 查看日志信息
1
curl -X GET 'http://localhost:8080/actuator/loggers'
- 动态修改日志级别
1
2url最后跟的是想要改变日志级别的包名
curl -H "Content-Type:application/json" -X POST -d '{"configuredLevel":"DEBUG"}' 'localhost:8080/actuator/loggers/com.xxx.xxx'