Removing the fa.setThreshold(Priority.DEBUG) doesn't work. Also, often (although not
always), I get INFO messages written to the Console, although they shouldn't be...
GTG
>>> Ceki Gülcü <[EMAIL PROTECTED]> 26/07/2001 18:25:21 >>>
At 15:02 26.07.2001 +0100, you wrote:
>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);
Appender thresholds are inclusive. Remove the call fa.setThreshold(Priority.DEBUG);
This causes your DEBUG messages to be filtered out.
Regards, Ceki
--
Ceki Gülcü - http://qos.ch
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]