美文网首页
springboot动态调整日志级别

springboot动态调整日志级别

作者: DimonHo | 来源:发表于2019-11-23 14:53 被阅读0次

    准备工作:

    1. 引入jar包
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    
    1. 在application.yml中添加配置
    management:
      endpoints:
        web:
          exposure:
            include: "*"
    

    使用方式

    查看日志配置

    GET http://ip:port/actuator/loggers
    

    返回如下结果


    image.png

    动态修改ROOT的日志级别:

    POST http://ip:port/actuator/loggers/ROOT 
    {
      "configuredLevel":"DEBUG"
    }
    

    也可以具体到某一个包或者类下面

    POST http://ip:port/actuator/loggers/com.xxx.controller.BaseController
    {
      "configuredLevel":"DEBUG"
    }
    

    相关文章

      网友评论

          本文标题:springboot动态调整日志级别

          本文链接:https://www.haomeiwen.com/subject/zkrhwctx.html