本文介绍了关闭Quartz作业日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,石英作业是在部署应用程序后立即安排的.我有两个日志文件home-log-search.loghome-log-app.log,都用于特定的日志记录.搜索日志文件仅用于记录访问者的IP,其余所有日志记录(异常,调试信息)均记录在App日志文件中.

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.

我面临的问题是,默认的Quartz语句正在登录到不需要的home-log-search.log文件中.

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

如何禁用该日志记录?将级别设置为 OFF 无效.我还遵循了禁用石英测井,但这也无济于事.

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.

下面是我的 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);
}
}

推荐答案

您需要禁用石英java软件包(即org.quartz.*

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

似乎您在此行中错误地配置了log4j

It looks as though you have misconfigured log4j with this line

log4j.logger.searchLogger.quartz=OFF, searchLogger

它应该显示为

log4j.logger.org.quartz=OFF

这篇关于关闭Quartz作业日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 01:19