You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by "Satrasala, Sudhakar" <Su...@adp.com> on 2003/07/23 23:54:45 UTC
Logger question
Hi,
I have 3 loggers in my application. Each logger has it's own FileAppender.
Can I log specific messages to the attached appenders, without setting a
level/priority.
The code looks like this:
Logger log = Logger.getLogger("LogAppTest");
Logger log1 = Logger.getLogger("LogAppTest1");
Logger log2 = Logger.getLogger("LogAppTest2");
FileAppender append = new FileAppender(new
SimpleLayout(),"C:/Logs/output.txt",false);
FileAppender append1 = new FileAppender(new
SimpleLayout(),"C:/Logs/output1.txt",false);
FileAppender append2 = new FileAppender(new
SimpleLayout(),"C:/Logs/output2.txt",false);
log.addAppender(append);
log1.addAppender(append1);
log2.addAppender(append2);
log.setAdditivity(false);
log1.setAdditivity(false);
log2.setAdditivity(false);
log.info("Hello World Info");
log.warn("Warning occurred");
log1.info("Hello World Info 2");
log2.info("Hello World Info 3");
When I run the code, all the log messages show up in all the files. But the
first file should have only 2 messages, the 2nd file should have only 1
message and the 3rd file should have only 1 message. Is it possible to
achieve this result without using the filter/level options?
Sudhakar