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

ddatsh 发布于 2012/09/03 23:43
阅读 9K+
收藏 0

<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 格式良好


 

 

加载中
0
红薯
红薯
日志里都是 INFO 的信息,没有出错哦,连警告都不算:)
ddatsh
ddatsh
只是它不应该显示 :) 不加condition 的话就不会出现了
返回顶部
顶部