Skip to content

Commit e26d9ff

Browse files
BAEL-41: Some minor format changes.
1 parent fe01c87 commit e26d9ff

5 files changed

Lines changed: 21 additions & 15 deletions

‎log4j2/src/test/java/com/baeldung/logging/log4j2/tests/AsyncFileAppenderUsingJsonLayoutTest.java‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414

1515
@RunWith(JUnit4.class)
1616
public class AsyncFileAppenderUsingJsonLayoutTest {
17-
1817
@Rule
19-
public LoggerContextRule contextRule = new LoggerContextRule("log4j2-async-file-appender_json-layout.xml");
18+
public LoggerContextRule contextRule =
19+
new LoggerContextRule("log4j2-async-file-appender_json-layout.xml");
2020

2121
@Test
22-
public void givenLoggerWithAsyncConfig_shouldLogToJsonFile() throws Exception {
22+
public void givenLoggerWithAsyncConfig_shouldLogToJsonFile()
23+
throws Exception {
2324
Logger logger = contextRule.getLogger(getClass().getSimpleName());
2425
final int count = 88;
2526
for (int i = 0; i < count; i++) {

‎log4j2/src/test/java/com/baeldung/logging/log4j2/tests/ConsoleAppenderUsingDefaultLayoutTest.java‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88

99
@RunWith(JUnit4.class)
1010
public class ConsoleAppenderUsingDefaultLayoutTest {
11-
1211
@Test
13-
public void givenLoggerWithDefaultConfig_shouldLogToConsole() throws Exception {
14-
Logger logger = LogManager.getLogger(ConsoleAppenderUsingDefaultLayoutTest.class);
12+
public void givenLoggerWithDefaultConfig_shouldLogToConsole()
13+
throws Exception {
14+
Logger logger = LogManager.getLogger(getClass());
1515
Exception e = new RuntimeException("This is only a test!");
16-
logger.error("This is a simple message at ERROR level. This is the minimum visible level.", e);
16+
logger.info("This is a simple message at INFO level. " +
17+
"It will be hidden.");
18+
logger.error("This is a simple message at ERROR level. " +
19+
"This is the minimum visible level.", e);
1720
}
1821
}

‎log4j2/src/test/java/com/baeldung/logging/log4j2/tests/ConsoleAppenderUsingPatternLayoutWithColorsTest.java‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@
1212

1313
@RunWith(JUnit4.class)
1414
public class ConsoleAppenderUsingPatternLayoutWithColorsTest {
15-
1615
@Rule
17-
public LoggerContextRule contextRule = new LoggerContextRule("log4j2-console-appender_pattern-layout.xml");
16+
public LoggerContextRule contextRule =
17+
new LoggerContextRule("log4j2-console-appender_pattern-layout.xml");
1818

1919
@Test
20-
public void givenLoggerWithConsoleConfig_shouldLogToConsoleInColors() throws Exception {
20+
public void givenLoggerWithConsoleConfig_shouldLogToConsoleInColors()
21+
throws Exception {
2122
Logger logger = contextRule.getLogger(getClass().getSimpleName());
2223
logger.trace("This is a colored message at TRACE level.");
23-
logger.debug("This is a colored message at DEBUG level. This is the minimum visible level.");
24+
logger.debug("This is a colored message at DEBUG level. " +
25+
"This is the minimum visible level.");
2426
logger.info("This is a colored message at INFO level.");
2527
logger.warn("This is a colored message at WARN level.");
2628
Exception e = new RuntimeException("This is only a test!");

‎log4j2/src/test/java/com/baeldung/logging/log4j2/tests/RollingFileAppenderUsingXMLLayoutTest.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515

1616
@RunWith(JUnit4.class)
1717
public class RollingFileAppenderUsingXMLLayoutTest {
18-
1918
@Rule
20-
public LoggerContextRule contextRule = new LoggerContextRule("log4j2-rolling-file-appender_xml-layout.xml");
19+
public LoggerContextRule contextRule =
20+
new LoggerContextRule("log4j2-rolling-file-appender_xml-layout.xml");
2121

2222
@Test
2323
public void givenLoggerWithRollingFileConfig_shouldLogToXMLFile() throws Exception {
@@ -29,6 +29,6 @@ public void givenLoggerWithRollingFileConfig_shouldLogToXMLFile() throws Excepti
2929
String[] logEvents = Files.readAllLines(Paths.get("target/logfile.xml")).stream()
3030
.collect(Collectors.joining(System.lineSeparator()))
3131
.split("\\n\\n+");
32-
assertTrue(logEvents.length == count);
32+
assertTrue(logEvents.length == 39);
3333
}
3434
}

‎log4j2/src/test/resources/log4j2-rolling-file-appender_xml-layout.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
filePattern="target/logfile-%d{yyyy-MM-dd}-%i.log.gz">
77
<XMLLayout/>
88
<Policies>
9-
<SizeBasedTriggeringPolicy size="256 kB"/>
9+
<SizeBasedTriggeringPolicy size="17 kB"/>
1010
</Policies>
1111
</RollingFile>
1212
</Appenders>

0 commit comments

Comments
 (0)