mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-15 01:07:30 +08:00
Adapt to changes in Logback include processing
Fixes gh-40491
This commit is contained in:
parent
86a3099782
commit
3c00bf367d
@ -107,6 +107,16 @@ class SpringBootJoranConfigurator extends JoranConfigurator {
|
||||
ruleStore.addTransparentPathPart("springProfile");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildModelInterpretationContext() {
|
||||
super.buildModelInterpretationContext();
|
||||
this.modelInterpretationContext.setConfiguratorSupplier(() -> {
|
||||
SpringBootJoranConfigurator configurator = new SpringBootJoranConfigurator(this.initializationContext);
|
||||
configurator.setContext(this.context);
|
||||
return configurator;
|
||||
});
|
||||
}
|
||||
|
||||
boolean configureUsingAotGeneratedArtifacts() {
|
||||
if (!new PatternRules(getContext()).load()) {
|
||||
return false;
|
||||
|
@ -83,6 +83,14 @@ class SpringBootJoranConfiguratorTests {
|
||||
assertThat(this.output).contains("Hello");
|
||||
}
|
||||
|
||||
@Test
|
||||
void profileInIncludeActive() throws Exception {
|
||||
this.environment.setActiveProfiles("production");
|
||||
initialize("profile-in-include.xml");
|
||||
this.logger.trace("Hello");
|
||||
assertThat(this.output).contains("Hello");
|
||||
}
|
||||
|
||||
@Test
|
||||
void multipleNamesFirstProfileActive() throws Exception {
|
||||
this.environment.setActiveProfiles("production");
|
||||
@ -203,6 +211,13 @@ class SpringBootJoranConfiguratorTests {
|
||||
assertThat(this.context.getProperty("MYCHECK")).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
void springPropertyInInclude() throws Exception {
|
||||
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.environment, "my.example-property=test");
|
||||
initialize("property-in-include.xml");
|
||||
assertThat(this.context.getProperty("MINE")).isEqualTo("test");
|
||||
}
|
||||
|
||||
@Test
|
||||
void addsAotContributionToContextDuringAotProcessing() throws Exception {
|
||||
withSystemProperty("spring.aot.processing", "true", () -> {
|
||||
|
@ -0,0 +1,5 @@
|
||||
<included>
|
||||
<springProfile name="production">
|
||||
<logger name="org.springframework.boot.logging.logback" level="TRACE" />
|
||||
</springProfile>
|
||||
</included>
|
@ -0,0 +1,3 @@
|
||||
<included>
|
||||
<springProperty scope="context" name="MINE" source="my.example-property" defaultValue="default-test" />
|
||||
</included>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<include resource="org/springframework/boot/logging/logback/base.xml" />
|
||||
<include resource="org/springframework/boot/logging/logback/include-with-profile.xml" />
|
||||
</configuration>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<include resource="org/springframework/boot/logging/logback/base.xml" />
|
||||
<include resource="org/springframework/boot/logging/logback/include-with-property.xml" />
|
||||
</configuration>
|
Loading…
Reference in New Issue
Block a user