From 9d2d179549fa20c2ea0d96198009a142c0d4fb65 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 --- src/jalview/bin/Cache.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index afabf02..6266b71 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -47,6 +47,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.UserDefinedColours; @@ -303,12 +309,10 @@ public class Cache { // 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 + 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