Hello,
I use the following code to load a default configuration in case no configuration was set
using the log4j.configuration property:
static {
LOGGER = Logger.getLogger(MyClass.class);
Logger root = Logger.getRootLogger();
boolean inited = root.getAllAppenders().hasMoreElements();
if (!inited) {
Layout layout = new PatternLayout("%-5p [%t]: %m%n");
// create Appender to System.err
ConsoleAppender app = new ConsoleAppender(layout, ConsoleAppender.SYSTEM_ERR);
// set the follow option
app.setFollow(true);
app.activateOptions();
root.addAppender(app);
root.setLevel(Level.ERROR);
}
}
If I don't call "app.activateOptions()", the follow-option wouldn't take effect (and I do
need "follow" to be true).
But activateOptions finally calls WriterAppender.reset, which calls ConsoleAppender.close
and closes the previous output stream, in this case System.err - but closing System.err is
not a good idea, as it is still needed - I just want to change the Follow-Option.
Is this a misbehaviour of log4j, or am I incorrectly using the API?
Best regards
Martin Nyolt
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
|