From 0583a06c653a11294886864fe5bc5246a4cbc227 Mon Sep 17 00:00:00 2001 From: Olivier Vielpeau Date: Thu, 20 Aug 2015 15:40:21 -0400 Subject: [PATCH] Log stack traces instead of only printing them Allows to have the stack traces in the logs on top of being output. --- src/main/java/org/datadog/jmxfetch/App.java | 3 +-- src/main/java/org/datadog/jmxfetch/Instance.java | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/datadog/jmxfetch/App.java b/src/main/java/org/datadog/jmxfetch/App.java index 203fc3fca..0627655dd 100644 --- a/src/main/java/org/datadog/jmxfetch/App.java +++ b/src/main/java/org/datadog/jmxfetch/App.java @@ -327,10 +327,9 @@ public void init(boolean forceNewConnection) { instance = new Instance(configInstance, (LinkedHashMap) yamlConfig.getInitConfig(), name, appConfig); } catch (Exception e) { - e.printStackTrace(); String warning = "Unable to create instance. Please check your yaml file"; appConfig.getStatus().addInitFailedCheck(name, warning, Status.STATUS_ERROR); - LOGGER.error(warning); + LOGGER.error(warning, e); continue; } try { diff --git a/src/main/java/org/datadog/jmxfetch/Instance.java b/src/main/java/org/datadog/jmxfetch/Instance.java index 63cacc190..79383cce4 100644 --- a/src/main/java/org/datadog/jmxfetch/Instance.java +++ b/src/main/java/org/datadog/jmxfetch/Instance.java @@ -280,8 +280,7 @@ private void refreshBeansList() throws IOException { } } catch (Exception e) { - e.printStackTrace(); - LOGGER.error("Unable to compute a common bean scope, querying all beans as a fallback"); + LOGGER.error("Unable to compute a common bean scope, querying all beans as a fallback", e); this.beans = connection.queryMBeans(null); } this.lastRefreshTime = System.currentTimeMillis();