|
29 | 29 | import org.springframework.boot.builder.ParentContextApplicationContextInitializer;
|
30 | 30 | import org.springframework.boot.builder.SpringApplicationBuilder;
|
31 | 31 | import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
|
| 32 | +import org.springframework.boot.logging.LoggingSystem; |
32 | 33 | import org.springframework.cloud.bootstrap.encrypt.EnvironmentDecryptApplicationInitializer;
|
33 | 34 | import org.springframework.context.ApplicationContextInitializer;
|
34 | 35 | import org.springframework.context.ApplicationListener;
|
@@ -84,6 +85,11 @@ public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
|
84 | 85 | ConfigurableApplicationContext context = bootstrapServiceContext(environment,
|
85 | 86 | event.getSpringApplication());
|
86 | 87 | apply(context, event.getSpringApplication(), environment);
|
| 88 | + // Clean up the logging system. Logging will go dark until the |
| 89 | + // ConfigFileApplicationListener fires, but this is the price we pay for that |
| 90 | + // listener being able to adjust the log levels according to what it finds in its |
| 91 | + // own configuration. |
| 92 | + LoggingSystem.get(ClassUtils.getDefaultClassLoader()).cleanUp(); |
87 | 93 | }
|
88 | 94 |
|
89 | 95 | private ConfigurableApplicationContext bootstrapServiceContext(
|
@@ -121,9 +127,7 @@ private ConfigurableApplicationContext bootstrapServiceContext(
|
121 | 127 | .profiles(environment.getActiveProfiles()).bannerMode(Mode.OFF)
|
122 | 128 | .environment(bootstrapEnvironment)
|
123 | 129 | .properties("spring.application.name:" + configName)
|
124 |
| - .registerShutdownHook(false) |
125 |
| - .logStartupInfo(false) |
126 |
| - .web(false); |
| 130 | + .registerShutdownHook(false).logStartupInfo(false).web(false); |
127 | 131 | List<Class<?>> sources = new ArrayList<>();
|
128 | 132 | for (String name : names) {
|
129 | 133 | Class<?> cls = ClassUtils.resolveClassName(name, null);
|
|
0 commit comments