Logback 日志级别更改不起作用

Logback log level change not working

我正在使用一个名为 Apache Drill 的应用程序,它使用 logback 进行日志记录。我正在尝试编辑它附带的 logback.xml 配置文件以输出调试消息。

这是文件,未动过

<?xml version="1.0" encoding="UTF-8" ?>
<!--
 Licensed to the Apache Software Foundation (ASF) under one or more
 contributor license agreements.  See the NOTICE file distributed with
 this work for additional information regarding copyright ownership.
 The ASF licenses this file to You under the Apache License, Version 2.0
 (the "License"); you may not use this file except in compliance with
 the License.  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->
<configuration>
  <!--  <appender name="SOCKET"
    class="de.huxhorn.lilith.logback.appender.ClassicMultiplexSocketAppender">
    <Compressing>true</Compressing>
    <ReconnectionDelay>10000</ReconnectionDelay>
    <IncludeCallerData>true</IncludeCallerData>
    <RemoteHosts>${LILITH_HOSTNAME:-localhost}</RemoteHosts>
  </appender>
   -->

  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
      </pattern>
    </encoder>
  </appender>

    <appender name="QUERY" class="ch.qos.logback.core.rolling.RollingFileAppender">
      <file>${log.query.path}</file>
      <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
        <fileNamePattern>${log.query.path}.%i</fileNamePattern>
        <minIndex>1</minIndex>
        <maxIndex>10</maxIndex>
      </rollingPolicy>

      <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
        <maxFileSize>100MB</maxFileSize>
      </triggeringPolicy>
      <encoder>
        <pattern>%msg%n</pattern>
      </encoder>
    </appender>


    <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
      <file>${log.path}</file>
      <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
        <fileNamePattern>${log.path}.%i</fileNamePattern>
        <minIndex>1</minIndex>
        <maxIndex>10</maxIndex>
      </rollingPolicy>

      <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
        <maxFileSize>100MB</maxFileSize>
      </triggeringPolicy>
      <encoder>
        <pattern>%date{ISO8601} [%thread] %-5level %logger{36} - %msg%n</pattern>
      </encoder>
    </appender>


  <logger name="org.apache.drill" additivity="false">
    <level value="info" />
    <appender-ref ref="FILE" />
  </logger>

  <logger name="query.logger" additivity="false">
    <level value="info" />
    <appender-ref ref="QUERY" />
    <!--     <appender-ref ref="SOCKET" /> -->
  </logger>

  <!-- 
  <logger name="org.apache.drill" additivity="false">
    <level value="debug" />
    <appender-ref ref="SOCKET" />
  </logger>
   -->

  <root>
    <level value="error" />
    <appender-ref ref="STDOUT" />
  </root>

</configuration>

之后我所做的就是编辑

<logger name="org.apache.drill" additivity="false">
  <level value="info" />
  <appender-ref ref="FILE" />
</logger>

成为

<logger name="org.apache.drill" additivity="false">
  <level value="debug" />
  <appender-ref ref="FILE" />
</logger>

绝对没有任何改变! 这是用于启动应用程序的java命令(搜索-cp /home/gelbana/drillv11/conf,logback.xml文件位于conf目录中)

/usr/java/jdk1.8.0_112/bin/java -Xms10G -Xmx10G -XX:MaxDirectMemorySize=230G -XX:ReservedCodeCacheSize=1G -Ddrill.exec.enable-epoll=false -XX:MaxPermSize=512M -Djava.io.tmpdir=/home/gelbana/drillv11/tmp -Ddrill.memory.debug.allocator=true -XX:+CMSClassUnloadingEnabled -XX:+UseG1GC -Dlog.path=/home/gelbana/drillv11/log/drillbit.log -Dlog.query.path=/home/gelbana/drillv11/log/drillbit_queries.json -cp /home/gelbana/drillv11/conf:/home/gelbana/drillv11/jars/*:/home/gelbana/drillv11/jars/ext/*:/home/gelbana/drillv11/jars/3rdparty/*:/home/gelbana/drillv11/jars/classb/* org.apache.drill.exec.server.Drillbit

drillbit.out文件开头有以下几行

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/gelbana/drillv11/jars/3rdparty/slf4j-simple-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/gelbana/drillv11/jars/classb/logback-classic-1.0.13.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]

我尝试将所有级别更改为 DEBUGALL,但仍然没有任何改变。我在日志中找不到一个 DBEUG

您所做的更改应该有效。我做了同样的更改和 运行 一个钻头,我可以在 drillbit.log 中看到调试日志。例如:

DEBUG o.a.drill.exec.server.StartupOptions - Parsing arguments.

drillbit.out 文件应该会告诉您一些有关 Logback 如何配置自身的信息。查看该文件,特别是与 LoggerContext 相关的条目,例如:

Found resource [logback.xml] at ...

Resource [logback.xml] occurs multiple times on the classpath

您可能会发现 Logback 通过它自己的日志记录来揭示答案。