stop quartz debug logging log4j

大兔子大兔子 提交于 2019-12-04 11:04:27

Quartz uses SLF4J as the logging API. Therefore you should be able to configure the level in your Log4j config file.

Please verify the following:

1. You have no version conflict.

The easiest way to assure this is to let maven choose the versions.

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
    <version>1.7.5</version>
</dependency>

slf4j-log4j12 will include both, Log4J and SLF4J.

2. Make sure your config file known to Log4J.

It should be in the classpath (e.g. src/main/resources for maven projects) and it should be called log4j.xml.

If you are using Logback(intended as a successor to the popular log4j project), you can turn off the debug log by adding a logger to the <configuration /> as below:

<logger name="org.quartz.core.QuartzSchedulerThread" level="WARN" />

quartz-2.2.2 uses slf4j which supports logback. so adding logback.xml to the classpath and setting appropriate log level will resolve the issue. In case you are using another version of quartz and if it supports log4j. please ignore this.

<?xml version="1.0" encoding="UTF-8" ?>
<configuration>

    <logger name="org.quartz" level="ERROR"/>

    <root level="ALL">
        <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
            <encoder>
                <pattern>%d{HH:mm:ss.SSS} | %-5level | %X{username} | %thread | %logger{1} | %m%n%rEx</pattern>
            </encoder>
        </appender>
    </root>
</configuration>

Quartz is not using log4j, but it's using java.util.logging.Logger.

I reset my log4j.xml to

 <root> 
    <priority value ="info" /> 
    <appender-ref ref="console" /> 
  </root>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!