欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

logback 动态设置日志级别

程序员文章站 2022-07-03 16:23:36
...
    @Autowired(required = false)
    private LogbackLoggingSystem logbackLoggingSystem;

    @RequestMapping(value = "/log", method = RequestMethod.POST)
    @ResponseBody
    public Object log(HttpServletRequest request) {


        logbackLoggingSystem.setLogLevel("org.mybatis", LogLevel.DEBUG);
        logbackLoggingSystem.setLogLevel("com.hanshow.wise.base.data.mapper", LogLevel.DEBUG);
        logbackLoggingSystem.setLogLevel("com.hanshow.wise", LogLevel.DEBUG);

        return "";
    }

    <logger name="org.mybatis" level="INFO"></logger>
    <logger name="com.hanshow.wise" additivity="false">
        <level value="INFO" />
        <appender-ref ref="StdOut"/>
        <appender-ref ref="ALL"/>
        <appender-ref ref="ERROR"/>
        <appender-ref ref="INFO" />
        <appender-ref ref="WARN" />
    </logger>