NutzCN Logo
问答 LoggerFactory.getLogger 如何指定日志输出级别, 无法屏蔽quartz debug日志
发布于 1811天前 作者 git4frank 3701 次浏览 复制 上一个帖子 下一个帖子
标签:

Logger log = LoggerFactory.getLogger(getClass()); 这个方式获取的对象输出日志没办法在log4j.properties 配置输出级别。
后台一直输出quartz日志, 在log4j.properties 中指定log4j.logger.org.quartz.core.QuartzSchedulerThread=INFO 无效。

log4j 配置:
log4j.rootLogger=info,Console,Rolling
log4j.logger.org.quartz.core.QuartzSchedulerThread=INFO
log4j.appender.Console.MaxBackupIndex=3
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=[%-5p] %d{MM/dd HH:mm:ss.SSS} %l %t - %m%n
log4j.appender.Rolling=org.apache.log4j.RollingFileAppender
log4j.appender.Rolling.layout=org.apache.log4j.PatternLayout
log4j.appender.Rolling.layout.ConversionPattern=%d{MM/dd HH:mm:ss.SSS} - %m%n
log4j.appender.Rolling.MaxFileSize=100MB 
log4j.appender.Rolling.MaxBackupIndex=9
log4j.appender.Rolling.File=C:/logs/station.log
16:50:28.655 [NutzbookScheduler_QuartzSchedulerThread] DEBUG org.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers
16:50:53.846 [NutzbookScheduler_QuartzSchedulerThread] DEBUG org.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers
16:51:18.241 [NutzbookScheduler_QuartzSchedulerThread] DEBUG org.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers
16:51:43.079 [NutzbookScheduler_QuartzSchedulerThread] DEBUG org.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers
16:52:12.563 [NutzbookScheduler_QuartzSchedulerThread] DEBUG org.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers
16:52:40.990 [NutzbookScheduler_QuartzSchedulerThread] DEBUG org.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers
16:53:10.400 [NutzbookScheduler_QuartzSchedulerThread] DEBUG org.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers
16:53:38.663 [NutzbookScheduler_QuartzSchedulerThread] DEBUG org.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers
16:54:05.519 [NutzbookScheduler_QuartzSchedulerThread] DEBUG org.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers
16:54:31.402 [NutzbookScheduler_QuartzSchedulerThread] DEBUG org.quartz.core.QuartzSchedulerThread - batch acquisition of 1 triggers
16:55:00.000 [NutzbookScheduler_QuartzSchedulerThread] DEBUG org.quartz.core.QuartzSchedulerThread - batch acquisition of 0 triggers
5 回复

问题补充:Log log = Logs.get();获取日志对象可以在log4j.properties 指定日志级别; LoggerFactory.getLogger 获取对象在log4j.properties 指定日志级别无效。

是不是加了log4j2,logback,或者slf4j-simple

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

pom.xml里就引入了一个log4j和一个slf4j-log4j12, 其他的没有加。

已解决, 我加了个logback 配置文件在配置文件里指定日志级别就可以了。quartz 默认使用的是logback吧。

添加回复
请先登陆
回到顶部