From 9c259aca413f904fcc31d959ab54a6ea8432404a Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Fri, 26 Feb 2016 14:52:53 -0800 Subject: [PATCH] Core: Remove log4j exception hiding At some time in the distant past, Bootstrap could be used by those embedding elasticsearch. However, it is no longer allowed (now package private), and so any errors (for example, log4j missing, or any other exception while initializing) should be exposed directly and cause elasticsearch to fail to start. This change removes hiding of logging initialization exceptions. --- .../org/elasticsearch/bootstrap/Bootstrap.java | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java b/core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java index ec4e5ba2421..7ba959415c0 100644 --- a/core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java +++ b/core/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java @@ -193,21 +193,6 @@ final class Bootstrap { node = new Node(nodeSettings); } - @SuppressForbidden(reason = "Exception#printStackTrace()") - private static void setupLogging(Settings settings) { - try { - Class.forName("org.apache.log4j.Logger"); - LogConfigurator.configure(settings, true); - } catch (ClassNotFoundException e) { - // no log4j - } catch (NoClassDefFoundError e) { - // no log4j - } catch (Exception e) { - sysError("Failed to configure logging...", false); - e.printStackTrace(); - } - } - private static Environment initialSettings(boolean foreground) { Terminal terminal = foreground ? Terminal.DEFAULT : null; return InternalSettingsPreparer.prepareEnvironment(EMPTY_SETTINGS, terminal); @@ -254,7 +239,7 @@ final class Bootstrap { Environment environment = initialSettings(foreground); Settings settings = environment.settings(); - setupLogging(settings); + LogConfigurator.configure(settings, true); checkForCustomConfFile(); if (environment.pidFile() != null) {