logback.xml 使用condition时,自身调试信息无法关闭

发布于 2021-11-14 21:22:13 字数 3051 浏览 840 评论 1

<configuration debug="false"> 可以关闭启动时,logback自身的调试输出如

 23:39:12,858 |-INFO in ch.qos.logback.classic.LoggerContext[cpic_web] - Could NOT find resource [logback.groovy]
23:39:12,858 |-INFO in ch.qos.logback.classic.LoggerContext[cpic_web] - Could NOT find resource [logback-test.xml]
23:39:12,858 |-INFO in ch.qos.logback.classic.LoggerContext[cpic_web] - Found resource [logback.xml] at [file:/F:/git/sxtbweb/cpic-web/target/classes/logback.xml]
23:39:13,016 |-INFO in ch.qos.logback.classic.joran.action.ContextNameAction - Setting logger context name as [cpic_web]
23:39:13,016 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
23:39:13,020 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [STDOUT]
23:39:13,043 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
23:39:13,102 |-ERROR in ch.qos.logback.core.joran.conditional.IfAction - Could not find Janino library on the class path. Skipping conditional processing.
23:39:13,103 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to ERROR
23:39:13,103 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [STDOUT] to Logger[ROOT]
23:39:13,103 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - End of configuration.
23:39:13,105 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@7c504887 - Registering current configuration as safe fallback point

 

但一旦使用condition,xml就被认为是格式不良好的了?

 <if condition='property("HOSTNAME").contains("xxxx")'>
    <then>
      <appender name="CON" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
          <pattern>%d %-5level %logger{35} - %msg %n</pattern>
        </encoder>
      </appender>
      <root>
        <appender-ref ref="CON" />
      </root>
    </then>
  </if>

 启动时会有自身调试日志和以下这句

23:39:13,013 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set

 

http://logback.qos.ch/manual/configuration.html

官方提到

Setting the debug attribute within the <configuration> element will output status information, assuming that:

  1. the configuration file is found
  2. the configuration file is well-formed XML.

需要 XML 格式良好


 

 

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

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

发布评论

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

评论(1

悲喜皆因你 2021-11-18 19:36:07

日志里都是 INFO 的信息,没有出错哦,连警告都不算:)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文