From 00823d41a99b0f490bc27ab038c1eb1e80b350af Mon Sep 17 00:00:00 2001 From: Gytis Trikleris Date: Wed, 10 May 2017 13:23:06 +0200 Subject: [PATCH] Log a warning if a health indicator throws an exception Closes gh-9110 --- .../boot/actuate/health/AbstractHealthIndicator.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/AbstractHealthIndicator.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/AbstractHealthIndicator.java index 6085bb5d49..81145fc302 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/AbstractHealthIndicator.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/AbstractHealthIndicator.java @@ -16,6 +16,9 @@ package org.springframework.boot.actuate.health; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import org.springframework.boot.actuate.health.Health.Builder; /** @@ -31,6 +34,8 @@ import org.springframework.boot.actuate.health.Health.Builder; */ public abstract class AbstractHealthIndicator implements HealthIndicator { + private final Log logger = LogFactory.getLog(getClass()); + @Override public final Health health() { Health.Builder builder = new Health.Builder(); @@ -38,6 +43,7 @@ public abstract class AbstractHealthIndicator implements HealthIndicator { doHealthCheck(builder); } catch (Exception ex) { + this.logger.warn("Health check failed", ex); builder.down(ex); } return builder.build();