Skip to content

Commit

Permalink
Fix stderr to also be captured by log4j
Browse files Browse the repository at this point in the history
In elastic#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.
  • Loading branch information
rjernst committed Jan 28, 2020
1 parent 4630c8d commit 93f5dac
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 93f5dac

Please sign in to comment.