Turning off Quartz job logging

淺唱寂寞╮ 提交于 2019-12-13 06:26:03

问题


In my application, quartz job is scheduled as soon as the application is deployed. I have two log files home-log-search.log and home-log-app.log, both for specific logging. Search log file is only to log the visitor's IP and rest all logging (exception, debug info) are logged in App log file.

The problem which i am facing is, the default Quartz statements are getting logged in home-log-search.log file which is not required.

How can i disable that logging? Setting level to OFF doesn't worked. I also followed disable quartz logging but that also didn't helped.

Below is my log4j.properties

# properties file for testing logging service
log4j.debug = true
# Set root category priority to DEBUG and its only appender to CONSOLE.
log4j.rootCategory=INFO, searchLogger

log4j.appender.searchLogger=org.apache.log4j.DailyRollingFileAppender
log4j.appender.searchLogger.File=${catalina.home}/logs/home-search-log.log
log4j.appender.searchLogger.DatePattern='.'yyyy-MM-dd
log4j.logger.searchLogger.quartz=OFF, searchLogger

log4j.appender.searchLogger.Append=true
log4j.appender.searchLogger.layout=org.apache.log4j.PatternLayout
log4j.appender.searchLogger.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-4p %m%n

log4j.logger.appLogger=DEBUG, appLogger
log4j.additivity.appLogger = false
log4j.appender.appLogger=org.apache.log4j.RollingFileAppender
log4j.appender.appLogger.maxFileSize=5000KB
log4j.appender.appLogger.layout=org.apache.log4j.PatternLayout
log4j.appender.appLogger.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %c : %m%n
log4j.appender.appLogger.File=${catalina.home}/logs/home-app-log.log

Also below is my job scheduling class

public class SubscriptionNotificationJobScheduler {

/**
 * config bundle
 */
private static ResourceBundle configBundle = ResourceBundle.getBundle("config");


public SubscriptionNotificationJobScheduler(String path) throws ParseException, SchedulerException{

    JobDetail job = new JobDetail();
    job.setName(SubscriptionConstants.JOB_NAME);
    job.setJobClass(SubscriptionNotificationJob.class);

    JobDataMap map = new JobDataMap();
    map.put("contextPath", path);
    job.setJobDataMap(map);

    CronTrigger trigger = new CronTrigger();
    trigger.setName(SubscriptionConstants.TRIGGER_NAME);
    trigger.setCronExpression(configBundle.getString("monday.cron.trigger"));

    //schedule it
    Scheduler scheduler = new StdSchedulerFactory().getScheduler();
    scheduler.start();
    scheduler.scheduleJob(job, trigger);
}
}

回答1:


You need to disable logging for the quartz java package, that is org.quartz.*

It looks as though you have misconfigured log4j with this line

log4j.logger.searchLogger.quartz=OFF, searchLogger

Instead it should read

log4j.logger.org.quartz=OFF



来源:https://stackoverflow.com/questions/17102822/turning-off-quartz-job-logging

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