From e095c1ccbbe25909f294c5087658383e97869970 Mon Sep 17 00:00:00 2001 From: Stuart Douglas Date: Thu, 10 Jun 2021 12:51:48 +1000 Subject: [PATCH] Add ability to log to stderr Fixes #9569 --- .../main/java/io/quarkus/runtime/logging/ConsoleConfig.java | 6 ++++++ .../io/quarkus/runtime/logging/LoggingSetupRecorder.java | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/core/runtime/src/main/java/io/quarkus/runtime/logging/ConsoleConfig.java b/core/runtime/src/main/java/io/quarkus/runtime/logging/ConsoleConfig.java index ba9558590ce3c..d0bd9bb3f7312 100644 --- a/core/runtime/src/main/java/io/quarkus/runtime/logging/ConsoleConfig.java +++ b/core/runtime/src/main/java/io/quarkus/runtime/logging/ConsoleConfig.java @@ -15,6 +15,12 @@ public class ConsoleConfig { @ConfigItem(defaultValue = "true") boolean enable; + /** + * If console logging should go to {@link System#err} instead of {@link System#out}. + */ + @ConfigItem(defaultValue = "false") + boolean stderr; + /** * The log format. Note that this value will be ignored if an extension is present that takes * control of console formatting (e.g. an XML or JSON-format extension). diff --git a/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java b/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java index 0caec179cb378..ab69e93e89cd6 100644 --- a/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java +++ b/core/runtime/src/main/java/io/quarkus/runtime/logging/LoggingSetupRecorder.java @@ -343,7 +343,8 @@ private static Handler configureConsoleHandler(final ConsoleConfig config, final } } } - final ConsoleHandler consoleHandler = new ConsoleHandler(ConsoleHandler.Target.SYSTEM_OUT, formatter); + final ConsoleHandler consoleHandler = new ConsoleHandler( + config.stderr ? ConsoleHandler.Target.SYSTEM_ERR : ConsoleHandler.Target.SYSTEM_OUT, formatter); consoleHandler.setLevel(config.level); consoleHandler.setErrorManager(defaultErrorManager); consoleHandler.setFilter(new LogCleanupFilter(filterElements));