spring boot 设置 error 级别, 打印出来的却是 debug?

发布于 2022-09-07 03:23:37 字数 12158 浏览 14 评论 0

spring boot 设置 error 级别, 打印出来的却是 debug?

<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="true">

    <contextName>logback</contextName>

    <!--<include resource="org/springframework/boot/logging/logback/base.xml" />-->
    <include resource="org/springframework/boot/logging/logback/defaults.xml" />
    <property name="LOG_FILE" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}}/spring.log}"/>
    <include resource="org/springframework/boot/logging/logback/console-appender.xml" />
    <include resource="org/springframework/boot/logging/logback/file-appender.xml" />

    <appender name ="ASYNC" class= "ch.qos.logback.classic.AsyncAppender">
        <discardingThreshold >0</discardingThreshold>
        <queueSize>512</queueSize>
        <appender-ref ref ="FILE"/>
    </appender>

    <logger name="org.springframework.boot" level="error" />
    <logger name="org.hibernate.SQL" level="error" />

    <root level="error">
        <appender-ref ref="CONSOLE"/>
        <appender-ref ref="ASYNC"/>
    </root>


    <springProfile name="dev,test">
        <logger name="org.apache.ibatis" level="debug" />
        <logger name="java.sql" level="debug" />
    </springProfile>
    <springProfile name="prod">
        <logger name="org.apache.ibatis" level="error" />
        <logger name="java.sql" level="error" />
    </springProfile>

</configuration>

logback 自身日志打印结果:

DEBUG StatusLogger org.slf4j.helpers.Log4jLoggerFactory is not on classpath. Good!
17:41:48,956 |-WARN in Logger[org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator] - No appenders present in context [default] for logger [org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator].
17:41:48,956 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Will scan for changes in [file:/D:/code_local/fmt/websocket/web/target/classes/config/logback-spring.xml] 
17:41:48,956 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - Setting ReconfigureOnChangeTask scanning period to 1 minutes
17:41:48,956 |-INFO in ch.qos.logback.classic.joran.action.ContextNameAction - Setting logger context name as [logback]
17:41:48,956 |-INFO in ch.qos.logback.core.joran.util.ConfigurationWatchListUtil@333291e3 - Adding [jar:file:/D:/Maven/repository/org/springframework/boot/spring-boot/2.0.1.RELEASE/spring-boot-2.0.1.RELEASE.jar!/org/springframework/boot/logging/logback/defaults.xml] to configuration watch list.
17:41:48,956 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@479d31f3 - URL [jar:file:/D:/Maven/repository/org/springframework/boot/spring-boot/2.0.1.RELEASE/spring-boot-2.0.1.RELEASE.jar!/org/springframework/boot/logging/logback/defaults.xml] is not of type file
17:41:48,956 |-INFO in ch.qos.logback.core.joran.action.ConversionRuleAction - registering conversion word clr with class [org.springframework.boot.logging.logback.ColorConverter]
17:41:48,956 |-INFO in ch.qos.logback.core.joran.action.ConversionRuleAction - registering conversion word wex with class [org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter]
17:41:48,956 |-INFO in ch.qos.logback.core.joran.action.ConversionRuleAction - registering conversion word wEx with class [org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter]
17:41:48,956 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.catalina.startup.DigesterFactory] to ERROR
17:41:48,956 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@1d9b7cce - Propagating ERROR level on Logger[org.apache.catalina.startup.DigesterFactory] onto the JUL framework
17:41:48,956 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.catalina.util.LifecycleBase] to ERROR
17:41:48,956 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@1d9b7cce - Propagating ERROR level on Logger[org.apache.catalina.util.LifecycleBase] onto the JUL framework
17:41:48,956 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.coyote.http11.Http11NioProtocol] to WARN
17:41:48,956 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@1d9b7cce - Propagating WARN level on Logger[org.apache.coyote.http11.Http11NioProtocol] onto the JUL framework
17:41:48,956 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.sshd.common.util.SecurityUtils] to WARN
17:41:48,956 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@1d9b7cce - Propagating WARN level on Logger[org.apache.sshd.common.util.SecurityUtils] onto the JUL framework
17:41:48,956 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.tomcat.util.net.NioSelectorPool] to WARN
17:41:48,956 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@1d9b7cce - Propagating WARN level on Logger[org.apache.tomcat.util.net.NioSelectorPool] onto the JUL framework
17:41:48,956 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.eclipse.jetty.util.component.AbstractLifeCycle] to ERROR
17:41:48,956 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@1d9b7cce - Propagating ERROR level on Logger[org.eclipse.jetty.util.component.AbstractLifeCycle] onto the JUL framework
17:41:48,956 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.hibernate.validator.internal.util.Version] to WARN
17:41:48,956 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@1d9b7cce - Propagating WARN level on Logger[org.hibernate.validator.internal.util.Version] onto the JUL framework
17:41:48,971 |-INFO in ch.qos.logback.core.joran.util.ConfigurationWatchListUtil@333291e3 - Adding [jar:file:/D:/Maven/repository/org/springframework/boot/spring-boot/2.0.1.RELEASE/spring-boot-2.0.1.RELEASE.jar!/org/springframework/boot/logging/logback/console-appender.xml] to configuration watch list.
17:41:48,971 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@479d31f3 - URL [jar:file:/D:/Maven/repository/org/springframework/boot/spring-boot/2.0.1.RELEASE/spring-boot-2.0.1.RELEASE.jar!/org/springframework/boot/logging/logback/console-appender.xml] is not of type file
17:41:48,971 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
17:41:48,971 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [CONSOLE]
17:41:48,971 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
17:41:49,002 |-INFO in ch.qos.logback.core.joran.util.ConfigurationWatchListUtil@333291e3 - Adding [jar:file:/D:/Maven/repository/org/springframework/boot/spring-boot/2.0.1.RELEASE/spring-boot-2.0.1.RELEASE.jar!/org/springframework/boot/logging/logback/file-appender.xml] to configuration watch list.
17:41:49,002 |-INFO in ch.qos.logback.core.joran.spi.ConfigurationWatchList@479d31f3 - URL [jar:file:/D:/Maven/repository/org/springframework/boot/spring-boot/2.0.1.RELEASE/spring-boot-2.0.1.RELEASE.jar!/org/springframework/boot/logging/logback/file-appender.xml] is not of type file
17:41:49,002 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.rolling.RollingFileAppender]
17:41:49,002 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FILE]
17:41:49,002 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
17:41:49,002 |-INFO in c.q.l.core.rolling.SizeAndTimeBasedRollingPolicy@1434234664 - Archive files will be limited to [10 MB] each.
17:41:49,018 |-INFO in c.q.l.core.rolling.SizeAndTimeBasedRollingPolicy@1434234664 - Will use gz compression
17:41:49,018 |-INFO in c.q.l.core.rolling.SizeAndTimeBasedRollingPolicy@1434234664 - Will use the pattern logs/spring.log.%d{yyyy-MM-dd}.%i for the active file
17:41:49,018 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@5b12b668 - The date pattern is 'yyyy-MM-dd' from file name pattern 'logs/spring.log.%d{yyyy-MM-dd}.%i.gz'.
17:41:49,018 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@5b12b668 - Roll-over at midnight.
17:41:49,018 |-INFO in ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP@5b12b668 - Setting initial period to Fri Apr 20 17:40:01 CST 2018
17:41:49,018 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - Active log file name: logs/spring.log
17:41:49,018 |-INFO in ch.qos.logback.core.rolling.RollingFileAppender[FILE] - File property is set to [logs/spring.log]
17:41:49,018 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.classic.AsyncAppender]
17:41:49,018 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [ASYNC]
17:41:49,018 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FILE] to ch.qos.logback.classic.AsyncAppender[ASYNC]
17:41:49,018 |-INFO in ch.qos.logback.classic.AsyncAppender[ASYNC] - Attaching appender named [FILE] to AsyncAppender.
17:41:49,018 |-INFO in ch.qos.logback.classic.AsyncAppender[ASYNC] - Setting discardingThreshold to 0
17:41:49,018 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.springframework.boot] to ERROR
17:41:49,018 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@1d9b7cce - Propagating ERROR level on Logger[org.springframework.boot] onto the JUL framework
17:41:49,018 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.hibernate.SQL] to ERROR
17:41:49,018 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@1d9b7cce - Propagating ERROR level on Logger[org.hibernate.SQL] onto the JUL framework
17:41:49,018 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to ERROR
17:41:49,018 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@1d9b7cce - Propagating ERROR level on Logger[ROOT] onto the JUL framework
17:41:49,018 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [CONSOLE] to Logger[ROOT]
17:41:49,018 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [ASYNC] to Logger[ROOT]
17:41:49,034 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.apache.ibatis] to DEBUG
17:41:49,034 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@1d9b7cce - Propagating DEBUG level on Logger[org.apache.ibatis] onto the JUL framework
17:41:49,034 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [java.sql] to DEBUG
17:41:49,034 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@1d9b7cce - Propagating DEBUG level on Logger[java.sql] onto the JUL framework
17:41:49,034 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
17:41:49,034 |-INFO in org.springframework.boot.logging.logback.SpringBootJoranConfigurator@185a6e9 - Registering current configuration as safe fallback point
17:41:49,034 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@1d9b7cce - Propagating DEBUG level on Logger[org.springframework.boot] onto the JUL framework
17:41:49,034 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@1d9b7cce - Propagating DEBUG level on Logger[org.hibernate.SQL] onto the JUL framework
17:41:49,034 |-INFO in ch.qos.logback.classic.jul.LevelChangePropagator@1d9b7cce - Propagating ERROR level on Logger[org] onto the JUL framework

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

流年里的时光 2022-09-14 03:23:37

你的环境是 prod 还是 test

旧夏天 2022-09-14 03:23:37
  1. 检查配置文件,除了在logback.xml配置外,还有其他的配置方式,如Springboot yml方式 日志配置,检查完后再确认下等级是否是正确的。
  2. 还有就是区分环境。不同的环境配置可能也不一样。
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文