From 93f5dace86b326dbf514af7867c77c94d2335a54 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Tue, 28 Jan 2020 12:42:17 -0800 Subject: [PATCH] Fix stderr to also be captured by log4j 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 c6b4f0d0427a3..544452259197b 100644 --- a/server/src/main/java/org/elasticsearch/common/logging/LogConfigurator.java +++ b/server/src/main/java/org/elasticsearch/common/logging/LogConfigurator.java @@ -248,7 +248,7 @@ public FileVisitResult visitFile(final Path file, final BasicFileAttributes attr // Redirect stdout/stderr to log4j. While we ensure Elasticsearch code does not write to those streams, // third party libraries may do that System.setOut(new PrintStream(new LoggingOutputStream(LogManager.getLogger("stdout"), Level.INFO), false, StandardCharsets.UTF_8)); - System.setOut(new PrintStream(new LoggingOutputStream(LogManager.getLogger("stderr"), Level.WARN), false, StandardCharsets.UTF_8)); + System.setErr(new PrintStream(new LoggingOutputStream(LogManager.getLogger("stderr"), Level.WARN), false, StandardCharsets.UTF_8)); } private static void configureStatusLogger() {