Quartz Scheduler Does Not Display Log4j Messages

I am trying to configure the Quartz Scheduler to support logging. I tried to do the following:

Added log4j.xml to the class folder of my application. Code for it:

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=
    %d{ABSOLUTE} %5p %c{1}:%L - %m%n
log4j.rootLogger=debug, stdout

The following statements have been added in my scheduler class:

static Logger logger = Logger.getLogger("QuartzReport.class");
logger.info("Info");

However, the console displays the following message at startup:

log4j:WARN No appenders could be found for logger 
    (org.quartz.simpl.SimpleThreadPool).
log4j:WARN Please initialize the log4j system properly.

Please tell me that I am missing something.

Regards, Ib

+3
source share
3 answers

You are missing two essential points:

  • Your configuration file is a properties file, not an XML. Therefore, you should save it as "log4j.properties";
  • , , 1, ( , log4j).

,

+2

log4j

log4j.logger.org.quartz = debug, stdout

0

( QuartzReport), ( ).

Log4j log4j.properties .

In your case, the call BasicConfigurator.configure()will override any definitions in your property file (i.e. the property file is ignored). And the output displayed by the log matches the template provided in the constructor PatternLayout. More information on how to define such a template can be found in the documentation PatternLayout.

0
source

Source: https://habr.com/ru/post/1706035/


All Articles