From aebe4cc0bfa4c9780bb6010fbd86cfb84fe3d2dd Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Wed, 15 Dec 2021 10:36:18 +0000 Subject: [PATCH] JAL-3933 configure root logger console appender to stderr (2.11.2 version) --- src/jalview/bin/Cache.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index c93d611..aa9c030 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -51,6 +51,12 @@ import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.SimpleLayout; +import org.apache.log4j.builders.appender.ConsoleAppenderBuilder; +import org.apache.logging.log4j.core.config.Configurator; +import org.apache.logging.log4j.core.config.builder.api.AppenderComponentBuilder; +import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilder; +import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilderFactory; +import org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration; import jalview.datamodel.PDBEntry; import jalview.gui.Preferences; @@ -328,14 +334,11 @@ public class Cache } try { - // TODO: redirect stdout and stderr here in order to grab the output of - // the log - - ConsoleAppender ap = new ConsoleAppender(); - ap.setLayout(new SimpleLayout()); - //ap.setTarget("System.err"); - ap.setName("JalviewLogger"); - org.apache.log4j.Logger.getRootLogger().addAppender(ap); // catch all for + // configure the root logger to stderr + ConfigurationBuilder builder = ConfigurationBuilderFactory.newConfigurationBuilder(); + AppenderComponentBuilder consoleApp = builder.newAppender("stderr", "Console"); + builder.add(consoleApp); + Configurator.initialize(builder.build()); // log output Logger laxis = Logger.getLogger("org.apache.axis"); Logger lcastor = Logger.getLogger("org.exolab.castor"); -- 1.7.10.2