Hello,

I've a problem adding a Filter at runtime.
My log4j.properties looks like this:

--- cut
log4j.rootLogger=info, stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
--- cut

During runtime I want to add a new FileAppender for certain paths like this:

--- cut
FileAppender fileAppender =     new FileAppender(
                        new PatternLayout("%d [%t] %-5p %c %x - %m%n"), 
                        fileName, true);
fileAppender.setName("file");
Logger logger = Logger.getLogger("some.package");
logger.addAppender(fileAppender);
--- cut

this works very well.
Now I want to chage the output of my logger during runtime to also print DEBUG 
messages.
I tried this code but failed so far:

--- cut
Logger logger = Logger.getLogger("some.package");
FileAppender appender = (FileAppender)logger.getAppender("file");
                
LevelMatchFilter lmf = new LevelMatchFilter();
lmf.setLevelToMatch("DEBUG");
lmf.setAcceptOnMatch(true);
appender.addFilter(lmf);
// Test settings
logger.debug("TEST");
--- cut

But this don't work. The test-Message isn't printed to the FileLogger. Only 
info, error and fatal messages are printed. How can I change the Logging 
meachnics during runtime that debuging messages are printed?

Regards,
Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-user-h...@logging.apache.org

Reply via email to