如何阻止石英警告记录器

时间:2013-09-14 05:59:43

标签: java logging log4j quartz-scheduler

控制台一直充满了Quartz WARN记录器,对于在项目中工作以在控制台中查找其他记录器消息的开发人员而言,这真的很烦人。

[2013-09-14 11:18:35,142]  WARN {org.quartz.simpl.PropertySettingJobFactory} -  No setter on Job class lk.gov.elg.admin.action.detain.DetainJob for property 'system-id'
[2013-09-14 11:18:35,142]  WARN {org.quartz.simpl.PropertySettingJobFactory} -  No setter on Job class lk.gov.elg.admin.action.detain.DetainJob for property 'end-at'
[2013-09-14 11:18:35,143]  WARN {org.quartz.simpl.PropertySettingJobFactory} -  No setter on Job class lk.gov.elg.admin.action.detain.DetainJob for property 'cron-expression'
[2013-09-14 11:18:35,144]  WARN {org.quartz.simpl.PropertySettingJobFactory} -  No setter on Job class lk.gov.elg.admin.action.detain.DetainJob for property 'start-at'
[2013-09-14 11:18:35,144]  WARN {org.quartz.simpl.PropertySettingJobFactory} -  No setter on Job class lk.gov.elg.admin.action.detain.DetainJob for property 'scheduled-job-id'
[2013-09-14 11:18:35,144]  WARN {org.quartz.simpl.PropertySettingJobFactory} -  No setter on Job class lk.gov.elg.admin.action.detain.DetainJob for property 'size'
[2013-09-14 11:18:40,086]  WARN {org.quartz.simpl.PropertySettingJobFactory} -  No setter on Job class lk.gov.elg.admin.action.detain.DetainJob for property 'GNS'
[2013-09-14 11:18:40,087]  WARN {org.quartz.simpl.PropertySettingJobFactory} -  No setter on Job class lk.gov.elg.admin.action.detain.DetainJob for property 'limit'
[2013-09-14 11:18:40,087]  WARN {org.quartz.simpl.PropertySettingJobFactory} -  No setter on Job class lk.gov.elg.admin.action.detain.DetainJob for property 'tenantId'

我谷歌并找到了一种方法,但它没有提供解决方案。

<logger name="org.quartz">
        <level value="info" />
</logger>

我们使用log4j.xml而不是log4j.properties。

以下是log4j.xml文件的快照

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration debug="true" xmlns:log4j="http://jakarta.apache.org/log4j/">

    <!--
       Read http://logging.apache.org/log4j/docs/api/org/apache/log4j/DailyRollingFileAppender.html
       for more information on DaliyRollingFileAppender configuration options.
    -->
    <appender name="error" class="org.apache.log4j.DailyRollingFileAppender">
        <param name="File" value="/elg/logs/scandium-error.log"/>
        <param name="Threshold" value="error"/>
        <param name="DatePattern" value="'.'yyyy-MM-dd"/>
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{DATE} %-5p - [%t] [%x] %m%n"/>
        </layout>
    </appender>

    <appender name="debug" class="org.apache.log4j.DailyRollingFileAppender">
        <param name="File" value="/elg/logs/scandium-debug.log"/>
        <param name="Threshold" value="trace"/>
        <param name="DatePattern" value="'.'yyyy-MM-dd"/>
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{DATE} %-5p [%t] - %c{1} [%x] - %m%n"/>
        </layout>
    </appender>

    <appender name="info" class="org.apache.log4j.DailyRollingFileAppender">
        <param name="File" value="/elg/logs/scandium-info.log"/>
        <param name="Threshold" value="info"/>
        <param name="DatePattern" value="'.'yyyy-MM-dd"/>
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{DATE} %-5p %c{1} - [%t] [%x] %m%n"/>
        </layout>
    </appender>

    <appender name="trace" class="org.apache.log4j.DailyRollingFileAppender">
        <param name="File" value="/elg/logs/scandium-trace.log"/>
        <param name="Threshold" value="info"/>
        <param name="DatePattern" value="'.'yyyy-MM-dd"/>
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{DATE} %-5p %c{1} - [%t] [%x] %m%n"/>
        </layout>
    </appender>

    <appender name="console" class="org.apache.log4j.ConsoleAppender">
        <param name="Threshold" value="info"/>
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d %-5p %c{1} - [%t] [%x] %m%n"/>
        </layout>
    </appender>

    <category name="com.opensymphony.xwork2.ognl.OgnlValueStack">
        <priority value="error"/>
        <appender-ref ref="error"/>
        <appender-ref ref="console"/>
    </category>

    <root>
        <priority value="trace"/>
        <appender-ref ref="info"/>
        <appender-ref ref="trace"/>
        <appender-ref ref="debug"/>
        <appender-ref ref="error"/>
        <appender-ref ref="console"/>
    </root>

    <logger name="org.quartz">
        <level value="info" />
    </logger>

</log4j:configuration>

请帮助解决问题。提前谢谢。

1 个答案:

答案 0 :(得分:1)

WARN的日志级别比INFO更严重,因此将日志级别设置为INFO仍会收到警告。最好的解决方案是找出你获得所有这些警告的原因;他们指的是Quartz认为是一个真正的问题(你显然在目标作业类型不理解的某个配置中设置了一堆属性)。如果您无法解决实际问题,则可以将日志级别设置为ERROR