At 09:38 27.07.2001 +0100, Gordon Ross wrote:
>If I have a config file which says:
>
>log4j.rootCategory=DEBUG, file
>log4j.appender.file=org.apache.log4j.RollingFileAppender
>log4j.appender.file.MaxBackupIndex=2
>log4j.appender.file.MaxFileSize=100KB
>log4j.appender.file.layout=org.apache.log4j.PatternLayout
>log4j.appender.file.layout.ConversionPattern=%d{dd MMM HH:mm} %-5p %c %x - %m%n
>log4j.appender.file.File=log4j.log
>log4j.appender.file.Threshold=DEBUG
>
>Then the file appender logs at log level DEBUG.
>
>I converted this to code:-
>
>RollingFileAppender fa;
>                        
>Category root = Category.getRoot();
>root.setPriority(Priority.DEBUG);
>PatternLayout pl=new PatternLayout("%d{dd MMM HH:mm} %-5p %c %x - %m%n");
>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);
>
>In a previous message, Ceki Gülcü said that doing the fa.setThreshold actually 
>excludes the DEBUG messages.

My previous comment about the threshold was wrong. Setting 
the threshold in an appender to priority DEBUG will include debug messages. 
Sorry about the confusion. 

The problem with your code is that you are forgetting to call activateOptions . As in:

fa.activateOptions();

Invoke activateOptions after you have set all options. This should do it. Regards, Ceki



--
Ceki Gülcü - http://qos.ch


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

Reply via email to