From cf5a2269a56a98371ebf16005965e1b92141d483 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Wed, 29 Jan 2020 16:36:21 -0800 Subject: [PATCH] Fix stderr to also be captured by log4j (#51569) In #50259 we redirected stdout and stderr to log4j, to capture jdk and external library messages. However, a typo in the method name used to redirect the stream in java means stdout is currently being duplicated twice, and stderr not captured. This commit corrects that mistake. Unfortunately this is at a level that cannot really be tested, thus we are still missing tests for this behavior. --- .../java/org/elasticsearch/common/logging/LogConfigurator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/org/elasticsearch/common/logging/LogConfigurator.java b/server/src/main/java/org/elasticsearch/common/logging/LogConfigurator.java index ddaf9307c2026..2e532d2a9d20f 100644 --- a/server/src/main/java/org/elasticsearch/common/logging/LogConfigurator.java +++ b/server/src/main/java/org/elasticsearch/common/logging/LogConfigurator.java @@ -249,7 +249,7 @@ public FileVisitResult visitFile(final Path file, final BasicFileAttributes attr // third party libraries may do that System.setOut(new PrintStream(new LoggingOutputStream(LogManager.getLogger("stdout"), Level.INFO), false, StandardCharsets.UTF_8.name())); - System.setOut(new PrintStream(new LoggingOutputStream(LogManager.getLogger("stderr"), Level.WARN), + System.setErr(new PrintStream(new LoggingOutputStream(LogManager.getLogger("stderr"), Level.WARN), false, StandardCharsets.UTF_8.name())); }