BAEL-41: Some minor format changes.
This commit is contained in:
parent
fe01c870db
commit
e26d9ff8e4
|
@ -14,12 +14,13 @@ import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
@RunWith(JUnit4.class)
|
@RunWith(JUnit4.class)
|
||||||
public class AsyncFileAppenderUsingJsonLayoutTest {
|
public class AsyncFileAppenderUsingJsonLayoutTest {
|
||||||
|
|
||||||
@Rule
|
@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
|
@Test
|
||||||
public void givenLoggerWithAsyncConfig_shouldLogToJsonFile() throws Exception {
|
public void givenLoggerWithAsyncConfig_shouldLogToJsonFile()
|
||||||
|
throws Exception {
|
||||||
Logger logger = contextRule.getLogger(getClass().getSimpleName());
|
Logger logger = contextRule.getLogger(getClass().getSimpleName());
|
||||||
final int count = 88;
|
final int count = 88;
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
|
|
|
@ -8,11 +8,14 @@ import org.junit.runners.JUnit4;
|
||||||
|
|
||||||
@RunWith(JUnit4.class)
|
@RunWith(JUnit4.class)
|
||||||
public class ConsoleAppenderUsingDefaultLayoutTest {
|
public class ConsoleAppenderUsingDefaultLayoutTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenLoggerWithDefaultConfig_shouldLogToConsole() throws Exception {
|
public void givenLoggerWithDefaultConfig_shouldLogToConsole()
|
||||||
Logger logger = LogManager.getLogger(ConsoleAppenderUsingDefaultLayoutTest.class);
|
throws Exception {
|
||||||
|
Logger logger = LogManager.getLogger(getClass());
|
||||||
Exception e = new RuntimeException("This is only a test!");
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,15 +12,17 @@ import org.junit.runners.JUnit4;
|
||||||
|
|
||||||
@RunWith(JUnit4.class)
|
@RunWith(JUnit4.class)
|
||||||
public class ConsoleAppenderUsingPatternLayoutWithColorsTest {
|
public class ConsoleAppenderUsingPatternLayoutWithColorsTest {
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public LoggerContextRule contextRule = new LoggerContextRule("log4j2-console-appender_pattern-layout.xml");
|
public LoggerContextRule contextRule =
|
||||||
|
new LoggerContextRule("log4j2-console-appender_pattern-layout.xml");
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenLoggerWithConsoleConfig_shouldLogToConsoleInColors() throws Exception {
|
public void givenLoggerWithConsoleConfig_shouldLogToConsoleInColors()
|
||||||
|
throws Exception {
|
||||||
Logger logger = contextRule.getLogger(getClass().getSimpleName());
|
Logger logger = contextRule.getLogger(getClass().getSimpleName());
|
||||||
logger.trace("This is a colored message at TRACE level.");
|
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.info("This is a colored message at INFO level.");
|
||||||
logger.warn("This is a colored message at WARN level.");
|
logger.warn("This is a colored message at WARN level.");
|
||||||
Exception e = new RuntimeException("This is only a test!");
|
Exception e = new RuntimeException("This is only a test!");
|
||||||
|
|
|
@ -15,9 +15,9 @@ import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
@RunWith(JUnit4.class)
|
@RunWith(JUnit4.class)
|
||||||
public class RollingFileAppenderUsingXMLLayoutTest {
|
public class RollingFileAppenderUsingXMLLayoutTest {
|
||||||
|
|
||||||
@Rule
|
@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
|
@Test
|
||||||
public void givenLoggerWithRollingFileConfig_shouldLogToXMLFile() throws Exception {
|
public void givenLoggerWithRollingFileConfig_shouldLogToXMLFile() throws Exception {
|
||||||
|
@ -29,6 +29,6 @@ public class RollingFileAppenderUsingXMLLayoutTest {
|
||||||
String[] logEvents = Files.readAllLines(Paths.get("target/logfile.xml")).stream()
|
String[] logEvents = Files.readAllLines(Paths.get("target/logfile.xml")).stream()
|
||||||
.collect(Collectors.joining(System.lineSeparator()))
|
.collect(Collectors.joining(System.lineSeparator()))
|
||||||
.split("\\n\\n+");
|
.split("\\n\\n+");
|
||||||
assertTrue(logEvents.length == count);
|
assertTrue(logEvents.length == 39);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
filePattern="target/logfile-%d{yyyy-MM-dd}-%i.log.gz">
|
filePattern="target/logfile-%d{yyyy-MM-dd}-%i.log.gz">
|
||||||
<XMLLayout/>
|
<XMLLayout/>
|
||||||
<Policies>
|
<Policies>
|
||||||
<SizeBasedTriggeringPolicy size="256 kB"/>
|
<SizeBasedTriggeringPolicy size="17 kB"/>
|
||||||
</Policies>
|
</Policies>
|
||||||
</RollingFile>
|
</RollingFile>
|
||||||
</Appenders>
|
</Appenders>
|
||||||
|
|
Loading…
Reference in New Issue