From f7f7fecafbf98eea1d8d5e0fa860552e2e0f0036 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Tue, 18 Aug 2015 22:27:39 -0400 Subject: [PATCH] Improve console logging on startup exception Today we show the exception twice: once by the logger and then again by the JVM. This is too noisy, and easy to avoid. --- .../main/java/org/elasticsearch/bootstrap/Bootstrap.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java b/core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java index d1143a54542..74baa320d43 100644 --- a/core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java +++ b/core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java @@ -277,11 +277,19 @@ public class Bootstrap { closeSysError(); } } catch (Throwable e) { + // disable console logging, so user does not see the exception twice (jvm will show it already) + if (foreground) { + Loggers.disableConsoleLogging(); + } ESLogger logger = Loggers.getLogger(Bootstrap.class); if (INSTANCE.node != null) { logger = Loggers.getLogger(Bootstrap.class, INSTANCE.node.settings().get("name")); } logger.error("Exception", e); + // re-enable it if appropriate, so they can see any logging during the shutdown process + if (foreground) { + Loggers.enableConsoleLogging(); + } throw e; }