diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/logging/AutoConfigurationReportLoggingInitializer.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/logging/AutoConfigurationReportLoggingInitializer.java index 93a5c4af69..5736d6784e 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/logging/AutoConfigurationReportLoggingInitializer.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/logging/AutoConfigurationReportLoggingInitializer.java @@ -16,6 +16,11 @@ package org.springframework.boot.autoconfigure.logging; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import org.apache.commons.logging.Log; @@ -117,7 +122,8 @@ public class AutoConfigurationReportLoggingInitializer implements message.append("=========================\n\n\n"); message.append("Positive matches:\n"); message.append("-----------------\n"); - for (Map.Entry entry : outcomes.entrySet()) { + Map shortOutcomes = orderByName(outcomes); + for (Map.Entry entry : shortOutcomes.entrySet()) { if (entry.getValue().isFullMatch()) { addLogMessage(message, entry.getKey(), entry.getValue()); } @@ -125,7 +131,7 @@ public class AutoConfigurationReportLoggingInitializer implements message.append("\n\n"); message.append("Negative matches:\n"); message.append("-----------------\n"); - for (Map.Entry entry : outcomes.entrySet()) { + for (Map.Entry entry : shortOutcomes.entrySet()) { if (!entry.getValue().isFullMatch()) { addLogMessage(message, entry.getKey(), entry.getValue()); } @@ -134,9 +140,26 @@ public class AutoConfigurationReportLoggingInitializer implements return message; } + private Map orderByName( + Map outcomes) { + Map result = new LinkedHashMap(); + List names = new ArrayList(); + Map classNames = new HashMap(); + for (String name : outcomes.keySet()) { + String shortName = ClassUtils.getShortName(name); + names.add(shortName); + classNames.put(shortName, name); + } + Collections.sort(names); + for (String shortName : names) { + result.put(shortName, outcomes.get(classNames.get(shortName))); + } + return result; + } + private void addLogMessage(StringBuilder message, String source, ConditionAndOutcomes conditionAndOutcomes) { - message.append("\n " + ClassUtils.getShortName(source) + "\n"); + message.append("\n " + source + "\n"); for (ConditionAndOutcome conditionAndOutcome : conditionAndOutcomes) { message.append(" - "); if (StringUtils.hasLength(conditionAndOutcome.getOutcome().getMessage())) {