You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4cxx-user@logging.apache.org by Greg Flex <gr...@gmail.com> on 2009/04/21 19:10:59 UTC

Apenders

Hi All,
I have my log4j logger configured via XML file that simply prints everything
to a console.
I also have a "configure()" method that takes a new XMl file as an argument
and re-configures my existing logger at run time
so the log messages instead of console go to the local file once this method
is called.
The problem is that when I call my "configure" method which simply calls:
DOMConfigurator.configure(configFile); all of my log messages go to the file
- those that should only go to the console and those that should go to the
file.
I can't figure this out.
Is there a way to somehow "clear" previous configuration of the "console"
logger and reconfigure it with a new XML file
on the fly?
I'm guessing that since the "console-only" messages along with "file-only"
messages appear in the file,
log4j uses some kind of buffer to store them all before written/printed.
This, of course, make sense and I'm sure it helps speed things up but in my
case when switching (or re-reading) appenders
while the program's running it's not what I want.
How can I flush the buffer before the switch occurs?
Thanks for suggestions....
Greg.