diff --git a/config/checkstyle/checkstyle-suppressions.xml b/config/checkstyle/checkstyle-suppressions.xml
index 04d9c02a94e..0eda6ac3fe3 100644
--- a/config/checkstyle/checkstyle-suppressions.xml
+++ b/config/checkstyle/checkstyle-suppressions.xml
@@ -46,6 +46,7 @@
+
diff --git a/settings.gradle b/settings.gradle
index 28efb8dfb4f..d74abd51330 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -425,6 +425,7 @@ include ":smoke-test:spring-boot-smoke-test-jetty-jsp"
include ":smoke-test:spring-boot-smoke-test-jetty-ssl"
include ":smoke-test:spring-boot-smoke-test-kafka"
include ":smoke-test:spring-boot-smoke-test-liquibase"
+include ":smoke-test:spring-boot-smoke-test-log4j2"
include ":smoke-test:spring-boot-smoke-test-logback"
include ":smoke-test:spring-boot-smoke-test-oauth2-authorization-server"
include ":smoke-test:spring-boot-smoke-test-oauth2-client"
diff --git a/smoke-test/spring-boot-smoke-test-log4j2/build.gradle b/smoke-test/spring-boot-smoke-test-log4j2/build.gradle
new file mode 100644
index 00000000000..2e55d223266
--- /dev/null
+++ b/smoke-test/spring-boot-smoke-test-log4j2/build.gradle
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2012-present the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+plugins {
+ id "java"
+}
+
+description = "Spring Boot Log4j2 smoke test"
+
+dependencies {
+ modules {
+ module("org.springframework.boot:spring-boot-starter-logging") {
+ replacedBy("org.springframework.boot:spring-boot-starter-log4j2", "Use Log4j2 instead of Logback")
+ }
+ }
+
+ implementation(project(":starter:spring-boot-starter"))
+ implementation(project(":starter:spring-boot-starter-log4j2"))
+
+ testImplementation(project(":starter:spring-boot-starter-test"))
+}
diff --git a/smoke-test/spring-boot-smoke-test-log4j2/src/main/java/smoketest/log4j2/SampleLog4j2Application.java b/smoke-test/spring-boot-smoke-test-log4j2/src/main/java/smoketest/log4j2/SampleLog4j2Application.java
new file mode 100644
index 00000000000..c05007d50c5
--- /dev/null
+++ b/smoke-test/spring-boot-smoke-test-log4j2/src/main/java/smoketest/log4j2/SampleLog4j2Application.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2012-present the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package smoketest.log4j2;
+
+import jakarta.annotation.PostConstruct;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class SampleLog4j2Application {
+
+ private static final Logger logger = LoggerFactory.getLogger(SampleLog4j2Application.class);
+
+ @PostConstruct
+ public void logSomething() {
+ logger.debug("Sample Debug Message");
+ logger.trace("Sample Trace Message");
+ }
+
+ public static void main(String[] args) {
+ SpringApplication.run(SampleLog4j2Application.class, args).close();
+ }
+
+}
diff --git a/smoke-test/spring-boot-smoke-test-log4j2/src/main/java/smoketest/log4j2/package-info.java b/smoke-test/spring-boot-smoke-test-log4j2/src/main/java/smoketest/log4j2/package-info.java
new file mode 100644
index 00000000000..6bc21179deb
--- /dev/null
+++ b/smoke-test/spring-boot-smoke-test-log4j2/src/main/java/smoketest/log4j2/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2012-present the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+@NullMarked
+package smoketest.log4j2;
+
+import org.jspecify.annotations.NullMarked;
diff --git a/smoke-test/spring-boot-smoke-test-log4j2/src/main/resources/application.properties b/smoke-test/spring-boot-smoke-test-log4j2/src/main/resources/application.properties
new file mode 100644
index 00000000000..5841dea27d1
--- /dev/null
+++ b/smoke-test/spring-boot-smoke-test-log4j2/src/main/resources/application.properties
@@ -0,0 +1 @@
+logging.log4j2.config.override=classpath:org/springframework/boot/logging/log4j2/log4j2.xml
\ No newline at end of file
diff --git a/smoke-test/spring-boot-smoke-test-log4j2/src/main/resources/log4j2-spring.xml b/smoke-test/spring-boot-smoke-test-log4j2/src/main/resources/log4j2-spring.xml
new file mode 100644
index 00000000000..f4151d57b2b
--- /dev/null
+++ b/smoke-test/spring-boot-smoke-test-log4j2/src/main/resources/log4j2-spring.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/smoke-test/spring-boot-smoke-test-log4j2/src/test/java/smoketest/log4j2/SampleLog4j2ApplicationTests.java b/smoke-test/spring-boot-smoke-test-log4j2/src/test/java/smoketest/log4j2/SampleLog4j2ApplicationTests.java
new file mode 100644
index 00000000000..4a4757a57ac
--- /dev/null
+++ b/smoke-test/spring-boot-smoke-test-log4j2/src/test/java/smoketest/log4j2/SampleLog4j2ApplicationTests.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2012-present the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package smoketest.log4j2;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+import org.springframework.boot.test.system.CapturedOutput;
+import org.springframework.boot.test.system.OutputCaptureExtension;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+@ExtendWith(OutputCaptureExtension.class)
+class SampleLog4j2ApplicationTests {
+
+ @Test
+ void testLoadedCustomLogbackConfig(CapturedOutput output) {
+ SampleLog4j2Application.main(new String[0]);
+ assertThat(output).contains("Sample Debug Message").doesNotContain("Sample Trace Message");
+ }
+
+ @Test
+ void testProfile(CapturedOutput output) {
+ SampleLog4j2Application.main(new String[] { "--spring.profiles.active=staging" });
+ assertThat(output).contains("Sample Debug Message").contains("Sample Trace Message");
+ }
+
+}