logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Nyolt <a31bd...@freenet.de>
Subject Log4j closes System.err
Date Fri, 18 Feb 2011 14:01:42 GMT

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

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

View raw message