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 aim is to have (in my own config file) a parameter allowing the user to change the 
logging level.

So how can the user set the logging level to DEBUG if setting it to DEBUG excludes 
DEBUG messages ?

Have I mis-understood something here ?

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