2017-08-14 271 views
1

我正在使用名为Apache Drill的应用程序,它使用logback进行日志记录。我试图编辑它的配置文件logback.xml以输出调试消息。Logback日志级别更改不起作用

这里是文件的,不变的

<?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

+1

FWIW,您所做的更改_sh​​ould_work。我做了相同的更改并运行钻头,我可以在drillbit.log中看到调试日志。例如:'DEBUG o.a.drill.exec.server.StartupOptions - 解析参数.'。 'drillbit.out'文件应该告诉你一些** ** Logback如何配置它自己。你能否更新你的答案以包含来自'drillbit.out'的摘录,其中包含与LoggerContext相关的条目?例如:“在...找到资源[logback.xml]”(可能)“资源[logback.xml]在类路径上多次出现”等 – glytching

+0

谢谢!我做了,我想这就是我搞砸了!之前我添加了'slf4j-simple-1.7.25.jar',因为我看到了类似的SLF4J警告。 –

+0

删除'slf4j-simple-1.7.25.jar'解决它。我会更愿意接受这个答案。 –

回答

1

您所做的更改应该工作。我做了相同的更改并运行钻头,我可以在drillbit.log中看到调试日志。例如:

DEBUG o.a.drill.exec.server.StartupOptions - 解析参数。

drillbit.out文件应该告诉你一些关于如何配置自身的Logback。看看这个文件,特别是其中涉及到LoggerContext例如条目:

找到的资源[logback.xml]在...

资源[logback.xml]在classpath中出现多次

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