Search in sources :

Example 6 with LoggingInitializationContext

use of org.springframework.boot.logging.LoggingInitializationContext in project spring-boot by spring-projects.

the class LogbackLoggingSystemTests method testLevelPatternProperty.

@Test
public void testLevelPatternProperty() {
    MockEnvironment environment = new MockEnvironment();
    environment.setProperty("logging.pattern.level", "X%clr(%p)X");
    LoggingInitializationContext loggingInitializationContext = new LoggingInitializationContext(environment);
    this.loggingSystem.initialize(loggingInitializationContext, null, null);
    this.logger.info("Hello world");
    String output = this.output.toString().trim();
    assertThat(getLineWithText(output, "Hello world")).contains("XINFOX");
}
Also used : LoggingInitializationContext(org.springframework.boot.logging.LoggingInitializationContext) MockEnvironment(org.springframework.mock.env.MockEnvironment) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Aggregations

LoggingInitializationContext (org.springframework.boot.logging.LoggingInitializationContext)6 MockEnvironment (org.springframework.mock.env.MockEnvironment)5 Matchers.containsString (org.hamcrest.Matchers.containsString)3 Test (org.junit.Test)3 Before (org.junit.Before)2 File (java.io.File)1 SLF4JLogFactory (org.apache.commons.logging.impl.SLF4JLogFactory)1 StaticLoggerBinder (org.slf4j.impl.StaticLoggerBinder)1 LogFile (org.springframework.boot.logging.LogFile)1