I've got a really strange problem...

I have a small block of code which configures up log4j (see below). If the code is 
placed in one class, log4j works a treat. If I place the code in a method in another 
class, and call that method to execute the code, log4j doesn't seem to play ball (e.g. 
DEBUGs are not written to the file as they should be)


ConsoleAppender ca;
RollingFileAppender fa;
                        
Category root = Category.getRoot();
root.setPriority(Priority.DEBUG);
PatternLayout pl=new PatternLayout("%d{dd MMM HH:mm} %-5p %c %x - %m%n");
ca = new ConsoleAppender(pl);
ca.setThreshold(Priority.WARN);
root.addAppender(ca);
try
{
     fa = new RollingFileAppender(pl, "log4j.log", true);
}
catch(java.io.IOException e)
{       
     System.err.println("Unable to create logfile");
     return;
}
fa.setMaxFileSize("100KB");
fa.setMaxBackupIndex(2);
fa.setThreshold(Priority.DEBUG);
root.addAppender(fa);



Can anyone shed some light on this ?

Thanks,

GTG


Gordon Ross
Network Manager/Rheolwr Rhydwaith
Countryside Council for Wales/Cyngor Cefn Gwlad Cymru


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to