Friday, July 6, 2007

Programmatically setting appenders log4j

Here is the code to initialize the appenders programmatically(java)
Logger logger = Logger.getLogger(CURRENT_LOGGER_NAME);
logger.removeAllAppenders();
FileAppender fa = new FileAppender(new SimpleLayout(),filename,true);
fa.activateOptions();
logger.addAppender(fa);