|
|
|
|
@ -28,6 +28,7 @@ import java.util.List;
@@ -28,6 +28,7 @@ import java.util.List;
|
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.Properties; |
|
|
|
|
import java.util.Set; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
import org.apache.commons.logging.Log; |
|
|
|
|
import org.apache.commons.logging.LogFactory; |
|
|
|
|
@ -631,19 +632,26 @@ public class SpringApplication {
@@ -631,19 +632,26 @@ public class SpringApplication {
|
|
|
|
|
protected void logStartupProfileInfo(ConfigurableApplicationContext context) { |
|
|
|
|
Log log = getApplicationLog(); |
|
|
|
|
if (log.isInfoEnabled()) { |
|
|
|
|
String[] activeProfiles = context.getEnvironment().getActiveProfiles(); |
|
|
|
|
List<String> activeProfiles = quoteProfiles(context.getEnvironment().getActiveProfiles()); |
|
|
|
|
if (ObjectUtils.isEmpty(activeProfiles)) { |
|
|
|
|
String[] defaultProfiles = context.getEnvironment().getDefaultProfiles(); |
|
|
|
|
log.info("No active profile set, falling back to default profiles: " |
|
|
|
|
+ StringUtils.arrayToCommaDelimitedString(defaultProfiles)); |
|
|
|
|
List<String> defaultProfiles = quoteProfiles(context.getEnvironment().getDefaultProfiles()); |
|
|
|
|
String message = String.format("%s default %s: ", defaultProfiles.size(), |
|
|
|
|
(defaultProfiles.size() <= 1) ? "profile" : "profiles"); |
|
|
|
|
log.info("No active profile set, falling back to " + message |
|
|
|
|
+ StringUtils.collectionToDelimitedString(defaultProfiles, ", ")); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
log.info("The following profiles are active: " |
|
|
|
|
+ StringUtils.arrayToCommaDelimitedString(activeProfiles)); |
|
|
|
|
String message = (activeProfiles.size() == 1) ? "1 profile is active: " |
|
|
|
|
: activeProfiles.size() + " profiles are active: "; |
|
|
|
|
log.info("The following " + message + StringUtils.collectionToDelimitedString(activeProfiles, ", ")); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private List<String> quoteProfiles(String[] profiles) { |
|
|
|
|
return Arrays.stream(profiles).map((profile) -> "\"" + profile + "\"").collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Returns the {@link Log} for the application. By default will be deduced. |
|
|
|
|
* @return the application log |
|
|
|
|
|