Merge branch '2.3.x'
This commit is contained in:
commit
3587ecb043
|
@ -36,13 +36,20 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
*/
|
||||
class Log4j2FileXmlTests extends Log4j2XmlTests {
|
||||
|
||||
@TempDir
|
||||
File temp;
|
||||
|
||||
@Override
|
||||
@BeforeEach
|
||||
void configureLogFile(@TempDir File temp) {
|
||||
System.setProperty(LoggingSystemProperties.LOG_FILE, new File(temp, "test.log").getAbsolutePath());
|
||||
void prepareConfiguration() {
|
||||
System.setProperty(LoggingSystemProperties.LOG_FILE, new File(this.temp, "test.log").getAbsolutePath());
|
||||
super.prepareConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
@AfterEach
|
||||
void clearLogFile() {
|
||||
void stopConfiguration() {
|
||||
super.stopConfiguration();
|
||||
System.clearProperty(LoggingSystemProperties.LOG_FILE);
|
||||
}
|
||||
|
||||
|
@ -75,8 +82,8 @@ class Log4j2FileXmlTests extends Log4j2XmlTests {
|
|||
|
||||
@Test
|
||||
void whenLogDateformatPatternIsSetThenFileAppenderUsesIt() {
|
||||
withSystemProperty(LoggingSystemProperties.LOG_DATEFORMAT_PATTERN, "custom",
|
||||
() -> assertThat(fileAppenderPattern()).contains("custom"));
|
||||
withSystemProperty(LoggingSystemProperties.LOG_DATEFORMAT_PATTERN, "dd-MM-yyyy",
|
||||
() -> assertThat(fileAppenderPattern()).contains("dd-MM-yyyy"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,6 +24,8 @@ import org.apache.logging.log4j.core.config.Configuration;
|
|||
import org.apache.logging.log4j.core.config.ConfigurationFactory;
|
||||
import org.apache.logging.log4j.core.config.ConfigurationSource;
|
||||
import org.apache.logging.log4j.core.layout.PatternLayout;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.logging.LoggingSystemProperties;
|
||||
|
@ -37,6 +39,18 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
*/
|
||||
class Log4j2XmlTests {
|
||||
|
||||
private Configuration configuration;
|
||||
|
||||
@BeforeEach
|
||||
void prepareConfiguration() {
|
||||
this.configuration = initializeConfiguration();
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void stopConfiguration() {
|
||||
this.configuration.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenLogExceptionConversionWordIsNotConfiguredThenConsoleUsesDefault() {
|
||||
assertThat(consolePattern()).contains("%xwEx");
|
||||
|
@ -66,8 +80,8 @@ class Log4j2XmlTests {
|
|||
|
||||
@Test
|
||||
void whenLogDateformatPatternIsSetThenConsoleUsesIt() {
|
||||
withSystemProperty(LoggingSystemProperties.LOG_DATEFORMAT_PATTERN, "custom",
|
||||
() -> assertThat(consolePattern()).contains("custom"));
|
||||
withSystemProperty(LoggingSystemProperties.LOG_DATEFORMAT_PATTERN, "dd-MM-yyyy",
|
||||
() -> assertThat(consolePattern()).contains("dd-MM-yyyy"));
|
||||
}
|
||||
|
||||
protected void withSystemProperty(String name, String value, Runnable action) {
|
||||
|
|
Loading…
Reference in New Issue