Skip to content

Commit b4c41c4

Browse files
committed
Merge branch '3.3.x' into 3.4.x
Closes gh-44692
2 parents 0efbd17 + ad9f0a6 commit b4c41c4

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/java/JavaLoggingSystem.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -176,7 +176,7 @@ public void cleanUp() {
176176
/**
177177
* {@link LoggingSystemFactory} that returns {@link JavaLoggingSystem} if possible.
178178
*/
179-
@Order(Ordered.LOWEST_PRECEDENCE)
179+
@Order(Ordered.LOWEST_PRECEDENCE - 1024)
180180
public static class Factory implements LoggingSystemFactory {
181181

182182
private static final boolean PRESENT = ClassUtils.isPresent("java.util.logging.LogManager",

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystem.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
import org.springframework.boot.logging.LoggingSystem;
6666
import org.springframework.boot.logging.LoggingSystemFactory;
6767
import org.springframework.core.Conventions;
68-
import org.springframework.core.Ordered;
6968
import org.springframework.core.annotation.Order;
7069
import org.springframework.core.env.Environment;
7170
import org.springframework.core.io.Resource;
@@ -505,7 +504,7 @@ public static Environment getEnvironment(LoggerContext loggerContext) {
505504
/**
506505
* {@link LoggingSystemFactory} that returns {@link Log4J2LoggingSystem} if possible.
507506
*/
508-
@Order(Ordered.LOWEST_PRECEDENCE)
507+
@Order(0)
509508
public static class Factory implements LoggingSystemFactory {
510509

511510
private static final boolean PRESENT = ClassUtils

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -494,7 +494,7 @@ void setStatusPrinterStream(PrintStream stream) {
494494
/**
495495
* {@link LoggingSystemFactory} that returns {@link LogbackLoggingSystem} if possible.
496496
*/
497-
@Order(Ordered.LOWEST_PRECEDENCE)
497+
@Order(Ordered.HIGHEST_PRECEDENCE + 1024)
498498
public static class Factory implements LoggingSystemFactory {
499499

500500
private static final boolean PRESENT = ClassUtils.isPresent("ch.qos.logback.classic.LoggerContext",

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/LoggingSystemTests.java

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,7 +20,10 @@
2020
import org.junit.jupiter.api.Test;
2121

2222
import org.springframework.boot.logging.LoggingSystem.NoOpLoggingSystem;
23+
import org.springframework.boot.logging.java.JavaLoggingSystem;
24+
import org.springframework.boot.logging.log4j2.Log4J2LoggingSystem;
2325
import org.springframework.boot.logging.logback.LogbackLoggingSystem;
26+
import org.springframework.boot.testsupport.classpath.ClassPathExclusions;
2427

2528
import static org.assertj.core.api.Assertions.assertThat;
2629
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
@@ -42,6 +45,18 @@ void logbackIsTheDefaultLoggingSystem() {
4245
assertThat(LoggingSystem.get(getClass().getClassLoader())).isInstanceOf(LogbackLoggingSystem.class);
4346
}
4447

48+
@Test
49+
@ClassPathExclusions("logback-*.jar")
50+
void log4j2IsUsedInTheAbsenceOfLogback() {
51+
assertThat(LoggingSystem.get(getClass().getClassLoader())).isInstanceOf(Log4J2LoggingSystem.class);
52+
}
53+
54+
@Test
55+
@ClassPathExclusions({ "logback-*.jar", "log4j-*.jar" })
56+
void julIsUsedInTheAbsenceOfLogbackAndLog4j2() {
57+
assertThat(LoggingSystem.get(getClass().getClassLoader())).isInstanceOf(JavaLoggingSystem.class);
58+
}
59+
4560
@Test
4661
void loggingSystemCanBeDisabled() {
4762
System.setProperty(LoggingSystem.SYSTEM_PROPERTY, LoggingSystem.NONE);

0 commit comments

Comments
 (0)