1、springboot项目增加pom文件
配置Actuator
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
2、修改配置信息 修改management.endpoints.web.exposure.include为"*" 在application.yml或者bootstarp.yml里增加配置:
management:
endpoints:
web:
exposure:
include: "*"
3、请求接口查看所有日志级别 根据IP+端口+请求路径(/actuator/loggers)获取所有日志级别。如: localhost:8080/actuator/loggers
4、获取某一个类(包)的日志级别 根据IP+端口+请求路径(/actuator/loggers/包名或者全类名)获取单个日志日志级别。如: localhost:8080/actuator/loggers/com.alibaba.druid.pool.DruidDataSourceStatLoggerImpl
5、修改某个类(包)的日志级别 通过postman请求修改某个日志级别,如: 请求的curl为:
curl --location --request POST 'http://localhost:9151/actuator/loggers/com.alibaba.druid' \
--header 'Content-Type: application/json' \
--data-raw '{
"configuredLevel": "DEBUG"
}'
结果为
注意:
通过接口进行修改logger级别,仅在当前运行项目有效。项目重启后就会失效!!!
|