Skip to content

Commit

Permalink
Merge pull request #17819 from stuartwdouglas/9569
Browse files Browse the repository at this point in the history
Add ability to log to stderr
  • Loading branch information
gsmet authored Jun 10, 2021
2 parents d7ad0a1 + e095c1c commit 1299c12
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 1299c12

Please sign in to comment.