mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Merge branch '2.7.x'
Closes gh-31409
This commit is contained in:
commit
657fa3e64e
@ -23,6 +23,7 @@ import org.junit.jupiter.api.Test;
|
|||||||
import org.springframework.boot.actuate.autoconfigure.metrics.test.MetricsRun;
|
import org.springframework.boot.actuate.autoconfigure.metrics.test.MetricsRun;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||||
|
import org.springframework.boot.testsupport.classpath.ClassPathExclusions;
|
||||||
import org.springframework.boot.testsupport.classpath.ClassPathOverrides;
|
import org.springframework.boot.testsupport.classpath.ClassPathOverrides;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@ -34,6 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
*
|
*
|
||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
*/
|
*/
|
||||||
|
@ClassPathExclusions("log4j-to-slf4j-*.jar")
|
||||||
@ClassPathOverrides("org.apache.logging.log4j:log4j-core:2.11.1")
|
@ClassPathOverrides("org.apache.logging.log4j:log4j-core:2.11.1")
|
||||||
class Log4J2MetricsWithLog4jLoggerContextAutoConfigurationTests {
|
class Log4J2MetricsWithLog4jLoggerContextAutoConfigurationTests {
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ import org.junit.jupiter.api.Test;
|
|||||||
|
|
||||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||||
|
import org.springframework.boot.testsupport.classpath.ClassPathExclusions;
|
||||||
import org.springframework.boot.testsupport.classpath.ClassPathOverrides;
|
import org.springframework.boot.testsupport.classpath.ClassPathOverrides;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
@ -31,6 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
*
|
*
|
||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
*/
|
*/
|
||||||
|
@ClassPathExclusions("log4j-to-slf4j-*.jar")
|
||||||
@ClassPathOverrides({ "org.apache.logging.log4j:log4j-core:2.9.0", "org.apache.logging.log4j:log4j-slf4j-impl:2.9.0" })
|
@ClassPathOverrides({ "org.apache.logging.log4j:log4j-core:2.9.0", "org.apache.logging.log4j:log4j-slf4j-impl:2.9.0" })
|
||||||
class MetricsAutoConfigurationWithLog4j2AndLogbackTests {
|
class MetricsAutoConfigurationWithLog4j2AndLogbackTests {
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2021 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -242,11 +242,8 @@ final class ModifiedClassPathClassLoader extends URLClassLoader {
|
|||||||
private final AntPathMatcher matcher = new AntPathMatcher();
|
private final AntPathMatcher matcher = new AntPathMatcher();
|
||||||
|
|
||||||
private ClassPathEntryFilter(MergedAnnotation<ClassPathExclusions> annotation) {
|
private ClassPathEntryFilter(MergedAnnotation<ClassPathExclusions> annotation) {
|
||||||
this.exclusions = new ArrayList<>();
|
this.exclusions = annotation.getValue(MergedAnnotation.VALUE, String[].class).map(Arrays::asList)
|
||||||
this.exclusions.add("log4j-*.jar");
|
.orElse(Collections.emptyList());
|
||||||
if (annotation.isPresent()) {
|
|
||||||
this.exclusions.addAll(Arrays.asList(annotation.getStringArray(MergedAnnotation.VALUE)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isExcluded(URL url) {
|
private boolean isExcluded(URL url) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2020 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -28,8 +28,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
*
|
*
|
||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
*/
|
*/
|
||||||
// Log4j2 is implicitly excluded due to LOG4J-2030
|
@ClassPathExclusions({ "log4j-*.jar", "logback-*.jar" })
|
||||||
@ClassPathExclusions("logback-*.jar")
|
|
||||||
class LogbackAndLog4J2ExcludedLoggingSystemTests {
|
class LogbackAndLog4J2ExcludedLoggingSystemTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -52,6 +52,8 @@ import org.springframework.boot.logging.LoggerConfiguration;
|
|||||||
import org.springframework.boot.logging.LoggingInitializationContext;
|
import org.springframework.boot.logging.LoggingInitializationContext;
|
||||||
import org.springframework.boot.logging.LoggingSystem;
|
import org.springframework.boot.logging.LoggingSystem;
|
||||||
import org.springframework.boot.logging.LoggingSystemProperties;
|
import org.springframework.boot.logging.LoggingSystemProperties;
|
||||||
|
import org.springframework.boot.testsupport.classpath.ClassPathExclusions;
|
||||||
|
import org.springframework.boot.testsupport.classpath.ClassPathOverrides;
|
||||||
import org.springframework.boot.testsupport.system.CapturedOutput;
|
import org.springframework.boot.testsupport.system.CapturedOutput;
|
||||||
import org.springframework.boot.testsupport.system.OutputCaptureExtension;
|
import org.springframework.boot.testsupport.system.OutputCaptureExtension;
|
||||||
import org.springframework.mock.env.MockEnvironment;
|
import org.springframework.mock.env.MockEnvironment;
|
||||||
@ -76,6 +78,8 @@ import static org.mockito.Mockito.times;
|
|||||||
* @author Madhura Bhave
|
* @author Madhura Bhave
|
||||||
*/
|
*/
|
||||||
@ExtendWith(OutputCaptureExtension.class)
|
@ExtendWith(OutputCaptureExtension.class)
|
||||||
|
@ClassPathExclusions("logback-*.jar")
|
||||||
|
@ClassPathOverrides("org.apache.logging.log4j:log4j-slf4j-impl:2.17.2")
|
||||||
class Log4J2LoggingSystemTests extends AbstractLoggingSystemTests {
|
class Log4J2LoggingSystemTests extends AbstractLoggingSystemTests {
|
||||||
|
|
||||||
private final TestLog4J2LoggingSystem loggingSystem = new TestLog4J2LoggingSystem();
|
private final TestLog4J2LoggingSystem loggingSystem = new TestLog4J2LoggingSystem();
|
||||||
@ -250,9 +254,11 @@ class Log4J2LoggingSystemTests extends AbstractLoggingSystemTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void loggingThatUsesJulIsCaptured(CapturedOutput output) {
|
void loggingThatUsesJulIsCaptured(CapturedOutput output) {
|
||||||
|
String name = getClass().getName();
|
||||||
this.loggingSystem.beforeInitialize();
|
this.loggingSystem.beforeInitialize();
|
||||||
this.loggingSystem.initialize(this.initializationContext, null, null);
|
this.loggingSystem.initialize(this.initializationContext, null, null);
|
||||||
java.util.logging.Logger julLogger = java.util.logging.Logger.getLogger(getClass().getName());
|
this.loggingSystem.setLogLevel(name, LogLevel.TRACE);
|
||||||
|
java.util.logging.Logger julLogger = java.util.logging.Logger.getLogger(name);
|
||||||
julLogger.setLevel(java.util.logging.Level.INFO);
|
julLogger.setLevel(java.util.logging.Level.INFO);
|
||||||
julLogger.severe("Hello world");
|
julLogger.severe("Hello world");
|
||||||
assertThat(output).contains("Hello world");
|
assertThat(output).contains("Hello world");
|
||||||
|
Loading…
Reference in New Issue
Block a user