Java 停止石英调试日志记录 log4j
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21091536/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
stop quartz debug logging log4j
提问by Medioman92
i'm stuck trying to turn off the annoying DEBUG logging of quartz. i'm using log4j as logging framework and i've already tried to add this line to the lg4j proprieties file
我一直试图关闭烦人的石英调试日志记录。我正在使用 log4j 作为日志框架,并且我已经尝试将此行添加到 lg4j 属性文件中
"log4j.logger.org.quartz=ERROR"
i'm still getting tons of these debugging logging messages
我仍然收到大量这些调试日志消息
13:35:44.680 [MyScheduler_QuartzSchedulerThread] DEBUG o.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers
how can i turn this function off ?
我怎样才能关闭这个功能?
EDIT. i've moved my configuration to xml file...but still getting the same annoying problem
编辑。我已将我的配置移至 xml 文件...但仍然遇到同样烦人的问题
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration>
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{ABSOLUTE} %5p %c{1}:%L - %m%n" />
</layout>
</appender>
<logger name="org.quartz" >
<level value="ERROR" />
<appender-ref ref="console" />
</logger>
<logger name="org.hibernate">
<level value="ERROR" />
<appender-ref ref="console" />
</logger>
<logger name="com.mchange.v2.c3p0" additivity="false">
<level value="ERROR" />
<appender-ref ref="console" />
</logger>
<root>
<priority value="ERROR" />
<appender-ref ref="console" />
</root>
</log4j:configuration>
EDIT2...here's my pom.xml file (interesting part)
EDIT2...这是我的 pom.xml 文件(有趣的部分)
<!-- slf4j-log4j -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.9</version>
</dependency>
<!-- QUARTZ -->
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.1.7</version>
</dependency>
EDIT3 jar in classpath
类路径中的 EDIT3 jar
activation-1.1.jar
ant-1.8.2.jar
ant-launcher-1.8.2.jar
antlr-2.7.7.jar
asm-1.5.3.jar
asm-attrs-1.5.3.jar
asm-commons-3.3.jar
asm-tree-3.3.jar
bcmail-jdk14-1.38.jar
bcmail-jdk14-138.jar
bcprov-jdk14-1.38.jar
bcprov-jdk14-138.jar
bctsp-jdk14-1.38.jar
c3p0-0.9.1.1.jar
castor-1.2.jar
cglib-2.1_3.jar
commons-beanutils-1.8.3.jar
commons-codec-1.5.jar
commons-collections-3.2.1.jar
commons-digester-2.1.jar
commons-fileupload-1.2.2.jar
commons-io-2.0.1.jar
commons-lang-2.5.jar
commons-logging-1.1.1.jar
dom4j-1.6.1.jar
ehcache-1.2.3.jar
filename.txt
freemarker-2.3.18.jar
groovy-all-2.1.3.jar
hibernate-3.2.7.ga.jar
hibernate-annotations-3.3.0.ga.jar
hibernate-c3p0-4.1.10.Final.jar
hibernate-commons-annotations-3.3.0.ga.jar
hibernate-commons-annotations-4.0.1.Final.jar
hibernate-core-4.1.10.Final.jar
hibernate-jpa-2.0-api-1.0.1.Final.jar
itext-2.1.7.jar
Hymanson-annotations-2.0.5.jar
Hymanson-core-2.0.5.jar
Hymanson-databind-2.0.5.jar
jasperreports-5.1.0.jar
javassist-3.11.0.GA.jar
javassist-3.15.0-GA.jar
jboss-logging-3.1.0.GA.jar
jboss-transaction-api_1.1_spec-1.0.0.Final.jar
jcommon-1.0.15.jar
jdbc-mysql.jar
jdtcore-3.1.0.jar
jfreechart-1.0.12.jar
jta-1.1.jar
log4j-1.2.9.jar
logback-classic-1.0.10.jar
logback-core-1.0.11.jar
mail-1.4.jar
mysql-connector-java-5.1.6.jar
ognl-3.0.4.jar
ooxml-schemas-1.1.jar
openxml4j-1.0-beta.jar
poi-3.9.jar
poi-contrib-3.7-beta3.jar
poi-examples-3.9.jar
poi-excelant-3.9.jar
poi-ooxml-3.9.jar
poi-ooxml-schemas-3.9.jar
poi-scratchpad-3.9.jar
quartz-2.1.7.jar
servlet-api-2.5.jar
slf4j-api-1.7.2.jar
slf4j-log4j12-1.6.1.jar
stax-api-1.0.1.jar
struts2-core-2.3.1.2.jar
struts2-json-plugin-2.3.1.2.jar
xml-apis-1.0.b2.jar
xmlbeans-2.3.0.jar
xwork-core-2.3.1.2.jar
采纳答案by Michi Gysel
Quartz uses SLF4J as the logging API. Therefore you should be able to configure the level in your Log4j config file.
Quartz 使用 SLF4J 作为日志 API。因此,您应该能够在 Log4j 配置文件中配置级别。
Please verify the following:
请验证以下内容:
1. You have no version conflict.
1. 你没有版本冲突。
The easiest way to assure this is to let maven choose the versions.
确保这一点的最简单方法是让 maven 选择版本。
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.5</version>
</dependency>
slf4j-log4j12
will include both, Log4J and SLF4J.
slf4j-log4j12
将包括 Log4J 和 SLF4J。
2. Make sure your config file known to Log4J.
2. 确保 Log4J 知道您的配置文件。
It should be in the classpath (e.g. src/main/resources for maven projects) and it should be called log4j.xml
.
它应该在类路径中(例如 maven 项目的 src/main/resources)并且它应该被称为log4j.xml
.
回答by Hans Beemsterboer
Quartz is not using log4j, but it's using java.util.logging.Logger.
Quartz 没有使用 log4j,而是使用 java.util.logging.Logger。
回答by jobinbasani
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:
如果您正在使用Logback(打算作为流行的 log4j 项目的继承者),您可以通过向<configuration />
下面添加记录器来关闭调试日志:
<logger name="org.quartz.core.QuartzSchedulerThread" level="WARN" />
回答by Purushothaman
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.
quartz-2.2.2 使用支持 logback 的 slf4j。因此将 logback.xml 添加到类路径并设置适当的日志级别将解决该问题。如果您使用的是其他版本的石英并且它支持 log4j。请忽略这一点。
<?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>
回答by Anton KONG
I reset my log4j.xml to
我将 log4j.xml 重置为
<root>
<priority value ="info" />
<appender-ref ref="console" />
</root>