Repository: cxf Updated Branches: refs/heads/2.6.x-fixes 83e2376b4 -> 258cd0914
[CXF-5586] Let custom strategies ovverride the default log level Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/258cd091 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/258cd091 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/258cd091 Branch: refs/heads/2.6.x-fixes Commit: 258cd09143805e882a92d0a217bea70296ec0899 Parents: 83e2376 Author: Sergey Beryozkin <[email protected]> Authored: Fri Feb 28 17:06:43 2014 +0000 Committer: Sergey Beryozkin <[email protected]> Committed: Fri Feb 28 17:14:15 2014 +0000 ---------------------------------------------------------------------- .../AbstractStaticFailoverStrategy.java | 36 ++++++++++++++------ 1 file changed, 25 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/258cd091/rt/features/clustering/src/main/java/org/apache/cxf/clustering/AbstractStaticFailoverStrategy.java ---------------------------------------------------------------------- diff --git a/rt/features/clustering/src/main/java/org/apache/cxf/clustering/AbstractStaticFailoverStrategy.java b/rt/features/clustering/src/main/java/org/apache/cxf/clustering/AbstractStaticFailoverStrategy.java index 6d8b044..5b2ade9 100644 --- a/rt/features/clustering/src/main/java/org/apache/cxf/clustering/AbstractStaticFailoverStrategy.java +++ b/rt/features/clustering/src/main/java/org/apache/cxf/clustering/AbstractStaticFailoverStrategy.java @@ -78,9 +78,12 @@ public abstract class AbstractStaticFailoverStrategy implements FailoverStrategy String selected = null; if (alternates != null && alternates.size() > 0) { selected = getNextAlternate(alternates); - LOG.log(Level.WARNING, - "FAILING_OVER_TO_ADDRESS_OVERRIDE", - selected); + Level level = getLogLevel(); + if (LOG.isLoggable(level)) { + LOG.log(level, + "FAILING_OVER_TO_ADDRESS_OVERRIDE", + selected); + } } else { LOG.warning("NO_ALTERNATE_TARGETS_REMAIN"); } @@ -107,10 +110,13 @@ public abstract class AbstractStaticFailoverStrategy implements FailoverStrategy Endpoint selected = null; if (alternates != null && alternates.size() > 0) { selected = getNextAlternate(alternates); - LOG.log(Level.WARNING, - "FAILING_OVER_TO_ALTERNATE_ENDPOINT", - new Object[] {selected.getEndpointInfo().getName(), - selected.getEndpointInfo().getAddress()}); + Level level = getLogLevel(); + if (LOG.isLoggable(level)) { + LOG.log(level, + "FAILING_OVER_TO_ALTERNATE_ENDPOINT", + new Object[] {selected.getEndpointInfo().getName(), + selected.getEndpointInfo().getAddress()}); + } } else { LOG.warning("NO_ALTERNATE_TARGETS_REMAIN"); } @@ -138,15 +144,15 @@ public abstract class AbstractStaticFailoverStrategy implements FailoverStrategy endpoint.getEndpointInfo().getAddress())) { Endpoint alternate = endpoint.getService().getEndpoints().get(candidate.getName()); - if (alternate != null) { - LOG.log(Level.INFO, + if (alternate != null && LOG.isLoggable(Level.FINE)) { + LOG.log(Level.FINE, "FAILOVER_CANDIDATE_ACCEPTED", candidate.getName()); alternates.add(alternate); } } - } else { - LOG.log(Level.INFO, + } else if (LOG.isLoggable(Level.FINE)) { + LOG.log(Level.FINE, "FAILOVER_CANDIDATE_REJECTED", new Object[] {candidate.getName(), candidateBinding}); } @@ -162,4 +168,12 @@ public abstract class AbstractStaticFailoverStrategy implements FailoverStrategy * @return */ protected abstract <T> T getNextAlternate(List<T> alternates); + + /** + * Get the log level for reporting the selection of the new alternative address or endpoint + * @return the log level + */ + protected Level getLogLevel() { + return Level.WARNING; + } }
