|
|
|
@ -82,6 +82,7 @@ import static org.mockito.Mockito.times; |
|
|
|
* @author Vedran Pavic |
|
|
|
* @author Vedran Pavic |
|
|
|
* @author Robert Thornton |
|
|
|
* @author Robert Thornton |
|
|
|
* @author Eddú Meléndez |
|
|
|
* @author Eddú Meléndez |
|
|
|
|
|
|
|
* @author Scott Frederick |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ExtendWith(OutputCaptureExtension.class) |
|
|
|
@ExtendWith(OutputCaptureExtension.class) |
|
|
|
class LogbackLoggingSystemTests extends AbstractLoggingSystemTests { |
|
|
|
class LogbackLoggingSystemTests extends AbstractLoggingSystemTests { |
|
|
|
@ -547,27 +548,34 @@ class LogbackLoggingSystemTests extends AbstractLoggingSystemTests { |
|
|
|
then(listener).should(times(2)).onReset(loggerContext); |
|
|
|
then(listener).should(times(2)).onReset(loggerContext); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
void testDateformatPatternDefault(CapturedOutput output) { |
|
|
|
|
|
|
|
LoggingInitializationContext loggingInitializationContext = new LoggingInitializationContext(this.environment); |
|
|
|
|
|
|
|
initialize(loggingInitializationContext, null, null); |
|
|
|
|
|
|
|
this.logger.info("Hello world"); |
|
|
|
|
|
|
|
assertThat(getLineWithText(output, "Hello world")) |
|
|
|
|
|
|
|
.containsPattern("\\d{4}-\\d{2}\\-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}[-+]\\d{2}:\\d{2}"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
void testDateformatPatternProperty(CapturedOutput output) { |
|
|
|
void testDateformatPatternProperty(CapturedOutput output) { |
|
|
|
this.environment.setProperty("logging.pattern.dateformat", "yyyy-MM-dd'T'hh:mm:ss.SSSZ"); |
|
|
|
this.environment.setProperty("logging.pattern.dateformat", "dd-MM-yyyy"); |
|
|
|
new LoggingSystemProperties(this.environment).apply(); |
|
|
|
new LoggingSystemProperties(this.environment).apply(); |
|
|
|
LoggingInitializationContext loggingInitializationContext = new LoggingInitializationContext(this.environment); |
|
|
|
LoggingInitializationContext loggingInitializationContext = new LoggingInitializationContext(this.environment); |
|
|
|
initialize(loggingInitializationContext, null, null); |
|
|
|
initialize(loggingInitializationContext, null, null); |
|
|
|
this.logger.info("Hello world"); |
|
|
|
this.logger.info("Hello world"); |
|
|
|
assertThat(getLineWithText(output, "Hello world")) |
|
|
|
assertThat(getLineWithText(output, "Hello world")).containsPattern("\\d{2}-\\d{2}-\\d{4}\\s"); |
|
|
|
.containsPattern("\\d{4}-\\d{2}\\-\\d{2}T\\d{2}:\\d{2}:\\d{2}"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test // gh-24835
|
|
|
|
@Test // gh-24835
|
|
|
|
void testDateformatPatternPropertyDirect(CapturedOutput output) { |
|
|
|
void testDateformatPatternPropertyDirect(CapturedOutput output) { |
|
|
|
this.environment.setProperty("logging.pattern.dateformat", "yyyy'T'hh:mm:ss.SSSZ"); |
|
|
|
this.environment.setProperty("logging.pattern.dateformat", "yyyy"); |
|
|
|
new LoggingSystemProperties(this.environment).apply(); |
|
|
|
new LoggingSystemProperties(this.environment).apply(); |
|
|
|
this.environment.setProperty("logging.pattern.dateformat", "yyyy-MM-dd'T'hh:mm:ss.SSSZ"); |
|
|
|
this.environment.setProperty("logging.pattern.dateformat", "dd-MM-yyyy"); |
|
|
|
LoggingInitializationContext loggingInitializationContext = new LoggingInitializationContext(this.environment); |
|
|
|
LoggingInitializationContext loggingInitializationContext = new LoggingInitializationContext(this.environment); |
|
|
|
initialize(loggingInitializationContext, null, null); |
|
|
|
initialize(loggingInitializationContext, null, null); |
|
|
|
this.logger.info("Hello world"); |
|
|
|
this.logger.info("Hello world"); |
|
|
|
assertThat(getLineWithText(output, "Hello world")) |
|
|
|
assertThat(getLineWithText(output, "Hello world")).containsPattern("\\d{2}-\\d{2}-\\d{4}\\s"); |
|
|
|
.containsPattern("\\d{4}-\\d{2}\\-\\d{2}T\\d{2}:\\d{2}:\\d{2}"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
|