diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/SpringBootJoranConfigurator.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/SpringBootJoranConfigurator.java index c16a7d10b63..6eadc9596d6 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/SpringBootJoranConfigurator.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/SpringBootJoranConfigurator.java @@ -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; diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/SpringBootJoranConfiguratorTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/SpringBootJoranConfiguratorTests.java index 2dfb9fe3b59..116c6daab91 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/SpringBootJoranConfiguratorTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/SpringBootJoranConfiguratorTests.java @@ -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", () -> { diff --git a/spring-boot-project/spring-boot/src/test/resources/org/springframework/boot/logging/logback/include-with-profile.xml b/spring-boot-project/spring-boot/src/test/resources/org/springframework/boot/logging/logback/include-with-profile.xml new file mode 100644 index 00000000000..12772f0a3b2 --- /dev/null +++ b/spring-boot-project/spring-boot/src/test/resources/org/springframework/boot/logging/logback/include-with-profile.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/spring-boot-project/spring-boot/src/test/resources/org/springframework/boot/logging/logback/include-with-property.xml b/spring-boot-project/spring-boot/src/test/resources/org/springframework/boot/logging/logback/include-with-property.xml new file mode 100644 index 00000000000..c7e095d1596 --- /dev/null +++ b/spring-boot-project/spring-boot/src/test/resources/org/springframework/boot/logging/logback/include-with-property.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/spring-boot-project/spring-boot/src/test/resources/org/springframework/boot/logging/logback/profile-in-include.xml b/spring-boot-project/spring-boot/src/test/resources/org/springframework/boot/logging/logback/profile-in-include.xml new file mode 100644 index 00000000000..3c4c9ec17f6 --- /dev/null +++ b/spring-boot-project/spring-boot/src/test/resources/org/springframework/boot/logging/logback/profile-in-include.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/spring-boot-project/spring-boot/src/test/resources/org/springframework/boot/logging/logback/property-in-include.xml b/spring-boot-project/spring-boot/src/test/resources/org/springframework/boot/logging/logback/property-in-include.xml new file mode 100644 index 00000000000..ca2c2705b4e --- /dev/null +++ b/spring-boot-project/spring-boot/src/test/resources/org/springframework/boot/logging/logback/property-in-include.xml @@ -0,0 +1,5 @@ + + + + +