Log4JHelper.flgUseJobSchedulerLog4JAppender = true;
objLogger = new Log4JHelper("./" + strJobName + "-log4j.properties"); //$NON-NLS-1$
logger = Logger.getRootLogger();
JobSchedulerLog4JAppender objJSAppender = null;
/**
* the JobSchedulerLog4JAppender is used as the stdout-appender
* Therefore the code-snippet below asked log4j what the stdout-appender
* is and if it is the JobSchedulerLog4JAppender, the Instance of the
* sosJobSchedulerLogger is set.
*
* All Log4J-Messages are redirected to the sosLogger.
*/
Appender objStdoutAppender = logger.getAppender("stdout"); //$NON-NLS-1$
if (objStdoutAppender instanceof JobSchedulerLog4JAppender) {
objJSAppender = (JobSchedulerLog4JAppender) objStdoutAppender;
objJSAppender.setSchedulerLogger(sosLogger);
logger.info("LOG-I-0020: JobSchedulerLog4JAppender is configured as log4j-appender");
if (spooler_log.level() < 0) {
logger.setLevel(Level.DEBUG);
}
}
if (objJSAppender == null) {
SimpleLayout layout = new SimpleLayout();
objJSAppender = new JobSchedulerLog4JAppender(layout);
Appender consoleAppender = objJSAppender ; // JobSchedulerLog4JAppender(layout);
logger.addAppender(consoleAppender);
// ALL | DEBUG | INFO | WARN | ERROR | FATAL | OFF:
logger.setLevel(Level.DEBUG);
logger.debug("LOG-I-0010: Log4j configured programmatically");
}
objJSAppender.setSchedulerLogger(sosLogger);
logger.info("User-Dir : " + System.getProperty("user.dir")); //$NON-NLS-1$
}
catch (JobSchedulerException e) {
return false;
}