BAEL-41: Some minor format changes.

This commit is contained in:
Christian Rädel 2016-11-09 06:57:16 +01:00
parent fe01c870db
commit e26d9ff8e4
5 changed files with 21 additions and 15 deletions

View File

@ -14,12 +14,13 @@ import static org.junit.Assert.assertTrue;
@RunWith(JUnit4.class)
public class AsyncFileAppenderUsingJsonLayoutTest {
@Rule
public LoggerContextRule contextRule = new LoggerContextRule("log4j2-async-file-appender_json-layout.xml");
public LoggerContextRule contextRule =
new LoggerContextRule("log4j2-async-file-appender_json-layout.xml");
@Test
public void givenLoggerWithAsyncConfig_shouldLogToJsonFile() throws Exception {
public void givenLoggerWithAsyncConfig_shouldLogToJsonFile()
throws Exception {
Logger logger = contextRule.getLogger(getClass().getSimpleName());
final int count = 88;
for (int i = 0; i < count; i++) {

View File

@ -8,11 +8,14 @@ import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class ConsoleAppenderUsingDefaultLayoutTest {
@Test
public void givenLoggerWithDefaultConfig_shouldLogToConsole() throws Exception {
Logger logger = LogManager.getLogger(ConsoleAppenderUsingDefaultLayoutTest.class);
public void givenLoggerWithDefaultConfig_shouldLogToConsole()
throws Exception {
Logger logger = LogManager.getLogger(getClass());
Exception e = new RuntimeException("This is only a test!");
logger.error("This is a simple message at ERROR level. This is the minimum visible level.", e);
logger.info("This is a simple message at INFO level. " +
"It will be hidden.");
logger.error("This is a simple message at ERROR level. " +
"This is the minimum visible level.", e);
}
}

View File

@ -12,15 +12,17 @@ import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class ConsoleAppenderUsingPatternLayoutWithColorsTest {
@Rule
public LoggerContextRule contextRule = new LoggerContextRule("log4j2-console-appender_pattern-layout.xml");
public LoggerContextRule contextRule =
new LoggerContextRule("log4j2-console-appender_pattern-layout.xml");
@Test
public void givenLoggerWithConsoleConfig_shouldLogToConsoleInColors() throws Exception {
public void givenLoggerWithConsoleConfig_shouldLogToConsoleInColors()
throws Exception {
Logger logger = contextRule.getLogger(getClass().getSimpleName());
logger.trace("This is a colored message at TRACE level.");
logger.debug("This is a colored message at DEBUG level. This is the minimum visible level.");
logger.debug("This is a colored message at DEBUG level. " +
"This is the minimum visible level.");
logger.info("This is a colored message at INFO level.");
logger.warn("This is a colored message at WARN level.");
Exception e = new RuntimeException("This is only a test!");

View File

@ -15,9 +15,9 @@ import static org.junit.Assert.assertTrue;
@RunWith(JUnit4.class)
public class RollingFileAppenderUsingXMLLayoutTest {
@Rule
public LoggerContextRule contextRule = new LoggerContextRule("log4j2-rolling-file-appender_xml-layout.xml");
public LoggerContextRule contextRule =
new LoggerContextRule("log4j2-rolling-file-appender_xml-layout.xml");
@Test
public void givenLoggerWithRollingFileConfig_shouldLogToXMLFile() throws Exception {
@ -29,6 +29,6 @@ public class RollingFileAppenderUsingXMLLayoutTest {
String[] logEvents = Files.readAllLines(Paths.get("target/logfile.xml")).stream()
.collect(Collectors.joining(System.lineSeparator()))
.split("\\n\\n+");
assertTrue(logEvents.length == count);
assertTrue(logEvents.length == 39);
}
}

View File

@ -6,7 +6,7 @@
filePattern="target/logfile-%d{yyyy-MM-dd}-%i.log.gz">
<XMLLayout/>
<Policies>
<SizeBasedTriggeringPolicy size="256 kB"/>
<SizeBasedTriggeringPolicy size="17 kB"/>
</Policies>
</RollingFile>
</Appenders>