Suppress debug log output during Logback initialization
Closes gh-11761
This commit is contained in:
		
							parent
							
								
									e954bbbb86
								
							
						
					
					
						commit
						cafe6dbbb1
					
				|  | @ -111,8 +111,8 @@ public class LogbackLoggingSystem extends Slf4JLoggingSystem { | |||
| 		if (isAlreadyInitialized(loggerContext)) { | ||||
| 			return; | ||||
| 		} | ||||
| 		loggerContext.getTurboFilterList().remove(FILTER); | ||||
| 		super.initialize(initializationContext, configLocation, logFile); | ||||
| 		loggerContext.getTurboFilterList().remove(FILTER); | ||||
| 		markAsInitialized(loggerContext); | ||||
| 		if (StringUtils.hasText(System.getProperty(CONFIGURATION_FILE_PROPERTY))) { | ||||
| 			getLogger(LogbackLoggingSystem.class.getName()).warn( | ||||
|  |  | |||
|  | @ -39,6 +39,7 @@ import org.junit.After; | |||
| import org.junit.Before; | ||||
| import org.junit.Rule; | ||||
| import org.junit.Test; | ||||
| import org.junit.runner.RunWith; | ||||
| import org.slf4j.ILoggerFactory; | ||||
| import org.slf4j.bridge.SLF4JBridgeHandler; | ||||
| import org.slf4j.impl.StaticLoggerBinder; | ||||
|  | @ -52,6 +53,8 @@ import org.springframework.boot.logging.LoggingSystem; | |||
| import org.springframework.boot.logging.LoggingSystemProperties; | ||||
| import org.springframework.boot.testsupport.assertj.Matched; | ||||
| import org.springframework.boot.testsupport.rule.OutputCapture; | ||||
| import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions; | ||||
| import org.springframework.boot.testsupport.runner.classpath.ModifiedClassPathRunner; | ||||
| import org.springframework.mock.env.MockEnvironment; | ||||
| import org.springframework.test.util.ReflectionTestUtils; | ||||
| import org.springframework.util.FileCopyUtils; | ||||
|  | @ -74,6 +77,8 @@ import static org.mockito.Mockito.verify; | |||
|  * @author Madhura Bhave | ||||
|  * @author Vedran Pavic | ||||
|  */ | ||||
| @RunWith(ModifiedClassPathRunner.class) | ||||
| @ClassPathExclusions("log4j-*.jar") | ||||
| public class LogbackLoggingSystemTests extends AbstractLoggingSystemTests { | ||||
| 
 | ||||
| 	@Rule | ||||
|  | @ -141,12 +146,14 @@ public class LogbackLoggingSystemTests extends AbstractLoggingSystemTests { | |||
| 
 | ||||
| 	@Test | ||||
| 	public void testNonDefaultConfigLocation() { | ||||
| 		int existingOutputLength = this.output.toString().length(); | ||||
| 		this.loggingSystem.beforeInitialize(); | ||||
| 		this.loggingSystem.initialize(this.initializationContext, | ||||
| 				"classpath:logback-nondefault.xml", | ||||
| 				getLogFile(tmpDir() + "/tmp.log", null)); | ||||
| 		this.logger.info("Hello world"); | ||||
| 		String output = this.output.toString().trim(); | ||||
| 		assertThat(output.substring(existingOutputLength)).doesNotContain("DEBUG"); | ||||
| 		assertThat(output).contains("Hello world").contains(tmpDir() + "/tmp.log"); | ||||
| 		assertThat(output).endsWith("BOOTBOOT"); | ||||
| 		assertThat(new File(tmpDir() + "/tmp.log").exists()).isFalse(); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue