Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -620,13 +620,19 @@ protected void logStartupProfileInfo(ConfigurableApplicationContext context) {
Log log = getApplicationLog();
if (log.isInfoEnabled()) {
String[] activeProfiles = context.getEnvironment().getActiveProfiles();
for (int i = 0; i < activeProfiles.length; i++) {
activeProfiles[i] = "\"" + activeProfiles[i] + "\"";
}
if (ObjectUtils.isEmpty(activeProfiles)) {
String[] defaultProfiles = context.getEnvironment().getDefaultProfiles();
log.info("No active profile set, falling back to default profiles: "
for (int i = 0; i < defaultProfiles.length; i++) {
defaultProfiles[i] = "\"" + defaultProfiles[i] + "\"";
}
log.info("No active profile set, falling back to " + defaultProfiles.length + " default profile(s): "
+ StringUtils.arrayToCommaDelimitedString(defaultProfiles));
}
else {
log.info("The following profiles are active: "
log.info("The following " + activeProfiles.length + " profile(s) are active: "
+ StringUtils.arrayToCommaDelimitedString(activeProfiles));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,15 @@ void logsNoActiveProfiles(CapturedOutput output) {
SpringApplication application = new SpringApplication(ExampleConfig.class);
application.setWebApplicationType(WebApplicationType.NONE);
this.context = application.run();
assertThat(output).contains("No active profile set, falling back to default profiles: default");
assertThat(output).contains("No active profile set, falling back to 1 default profile(s): \"default\"");
}

@Test
void logsActiveProfiles(CapturedOutput output) {
SpringApplication application = new SpringApplication(ExampleConfig.class);
application.setWebApplicationType(WebApplicationType.NONE);
this.context = application.run("--spring.profiles.active=myprofiles");
assertThat(output).contains("The following profiles are active: myprofile");
assertThat(output).contains("The following 1 profile(s) are active: \"myprofiles\"");
}

@Test
Expand All @@ -252,6 +252,15 @@ void enableBannerInLogViaProperty(CapturedOutput output) {
assertThat(output).contains("o.s.b.SpringApplication");
}

@Test
void logsMultipleActiveProfilesWithComma(CapturedOutput output) {
SpringApplication application = new SpringApplication(ExampleConfig.class);
application.setWebApplicationType(WebApplicationType.NONE);
application.setAdditionalProfiles("p1,p2", "p3");
application.run();
assertThat(output).contains("The following 2 profile(s) are active: \"p1,p2\",\"p3\"");
}

@Test
void setIgnoreBeanInfoPropertyByDefault(CapturedOutput output) {
SpringApplication application = new SpringApplication(ExampleConfig.class);
Expand Down