Hi ,
I am using the following Log4j properties for 2 applications.
The first 'RF' is rootCategory and 'ASW' is rootLogger
I want RF to log into test-log.txt
And ASW to admin-log.txt
But it is logging both in admin-log.txt.
#### Use two appenders, one to log to console, another to log to a file
log4j.rootCategory=info, stdout, RF
log4j.rootLogger= info, stdout, ASW
#### First appender writes to console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=[%d{ISO8601}]%5p%6.6r[%t]%x(%F:%L) - %m%n
#### Second appender writes to a file
log4j.appender.RF=org.apache.log4j.DailyRollingFileAppender
log4j.appender.RF.DatePattern='.'yyyy-MM-dd
log4j.appender.RF.File=C:/jrpapp1/wrk/log/weblog/test/test-log.txt
log4j.appender.RF.layout=org.apache.log4j.PatternLayout
log4j.appender.RF.layout.ConversionPattern=[%d{ISO8601}]%5p%6.6r[%t]%x(%F:%L) - %m%n
#### Third appender writes to a file
log4j.appender.ASW=org.apache.log4j.DailyRollingFileAppender
log4j.appender.ASW.DatePattern='.'yyyy-MM-dd
log4j.appender.ASW.File=C:/jrpapp1/wrk/log/weblog/admin/admin-log.txt
log4j.appender.ASW.layout=org.apache.log4j.PatternLayout
log4j.appender.ASW.layout.ConversionPattern=[%d{ISO8601}]%5p%6.6r[%t]%x(%F:%L) - %m%n
I am trying to
test it the following test program
import org.apache.log4j.Category;
import org.apache.log4j.Logger;
import org.apache.log4j.Priority;
public class TestLog4j {
private static Logger log = Logger.getLogger(TestLog4j.class.getName());
private static Category cat = Category.getInstance(TestLog4j.class.getName());
public void testLog(){
log.info("Just testing ASW INFO");
cat.info("Just testing RF INFO");
}
public static void main(String[] args) {
TestLog4j tLog = new TestLog4j();
tLog.testLog();
}
}
Thanks,
Boon