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

logback日志级别控制

程序员文章站 2022-07-03 16:59:00
...

日志级别及代表整数值:

  1. off-intMaxValue
  2. error-40000
  3. warn-30000
  4. info-20000
  5. debug-10000
  6. trace-5000
  7. all-intMinValue

项目启动时,我们设置的日志打印级别为有效级别,比如设置为debug(10000),那么服务运行过程中,打印的trace(5000)级别将不再打印,以下是源码(ch.qos.logback.classic.Logger#filterAndLog_0_Or3Plus)

private void filterAndLog_0_Or3Plus(final String localFQCN, final Marker marker, final Level level, final String msg, final Object[] params,
                    final Throwable t) {

        final FilterReply decision = loggerContext.getTurboFilterChainDecision_0_3OrMore(marker, this, level, msg, params, t);

        if (decision == FilterReply.NEUTRAL) {
            if (effectiveLevelInt > level.levelInt) {
                return;
            }
        } else if (decision == FilterReply.DENY) {
            return;
        }

        buildLoggingEventAndAppend(localFQCN, marker, level, msg, params, t);
    }

 

相关标签: java web logback