diff --git a/server/src/main/java/org/elasticsearch/cluster/coordination/JoinHelper.java b/server/src/main/java/org/elasticsearch/cluster/coordination/JoinHelper.java index bf5c0101d22c0..c615cb9a3fcf6 100644 --- a/server/src/main/java/org/elasticsearch/cluster/coordination/JoinHelper.java +++ b/server/src/main/java/org/elasticsearch/cluster/coordination/JoinHelper.java @@ -18,6 +18,7 @@ */ package org.elasticsearch.cluster.coordination; +import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; @@ -190,24 +191,22 @@ private static class FailedJoinAttempt { } void maybeLogNow() { - if (isSuspiciousTransportException(exception)) { - logger.info(() -> new ParameterizedMessage("failed to join {} with {}", destination, joinRequest), exception); - } else { - logger.debug(() -> new ParameterizedMessage("failed to join {} with {}", destination, joinRequest), exception); - } + logger.log(getLogLevel(exception), + () -> new ParameterizedMessage("failed to join {} with {}", destination, joinRequest), + exception); } - boolean isSuspiciousTransportException(TransportException e) { + static Level getLogLevel(TransportException e) { if (e instanceof RemoteTransportException) { Throwable cause = e.getCause(); if (cause != null && cause instanceof CoordinationStateRejectedException || cause instanceof FailedToCommitClusterStateException || cause instanceof NotMasterException) { - return false; + return Level.DEBUG; } } - return true; + return Level.INFO; } void logWarnWithTimestamp() {