From 99dbc3efd11ba5567b6f3e8ab30922506febbf09 Mon Sep 17 00:00:00 2001 From: slavisa-baeldung Date: Mon, 20 Feb 2017 20:03:32 +0100 Subject: [PATCH] BAEL-41 - Log4j 2 appenders, layout, filters --- .../baeldung/logging/log4j2/tests/CustomLoggingTest.java | 7 ++++--- .../logging/log4j2/tests/jdbc/ConnectionFactory.java | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/log4j2/src/test/java/com/baeldung/logging/log4j2/tests/CustomLoggingTest.java b/log4j2/src/test/java/com/baeldung/logging/log4j2/tests/CustomLoggingTest.java index d88a967562..1562b67068 100644 --- a/log4j2/src/test/java/com/baeldung/logging/log4j2/tests/CustomLoggingTest.java +++ b/log4j2/src/test/java/com/baeldung/logging/log4j2/tests/CustomLoggingTest.java @@ -6,6 +6,7 @@ import java.nio.file.Files; import java.nio.file.Paths; import java.sql.Connection; import java.sql.ResultSet; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Marker; @@ -25,7 +26,7 @@ public class CustomLoggingTest { public static void setup() throws Exception { Connection connection = ConnectionFactory.getConnection(); connection.createStatement() - .execute("CREATE TABLE logs(" + "when TIMESTAMP," + "logger VARCHAR(255)," + "level VARCHAR(255)," + "message VARCHAR(4096)," + "throwable TEXT)"); + .execute("CREATE TABLE logs(" + "when TIMESTAMP," + "logger VARCHAR(255)," + "level VARCHAR(255)," + "message VARCHAR(4096)," + "throwable TEXT)"); connection.commit(); } @@ -76,7 +77,7 @@ public class CustomLoggingTest { logger.info("This is async JSON message #{} at INFO level.", count); } long logEventsCount = Files.lines(Paths.get("target/logfile.json")) - .count(); + .count(); assertTrue(logEventsCount > 0 && logEventsCount <= count); } @@ -101,7 +102,7 @@ public class CustomLoggingTest { } Connection connection = ConnectionFactory.getConnection(); ResultSet resultSet = connection.createStatement() - .executeQuery("SELECT COUNT(*) AS ROW_COUNT FROM logs"); + .executeQuery("SELECT COUNT(*) AS ROW_COUNT FROM logs"); int logCount = 0; if (resultSet.next()) { logCount = resultSet.getInt("ROW_COUNT"); diff --git a/log4j2/src/test/java/com/baeldung/logging/log4j2/tests/jdbc/ConnectionFactory.java b/log4j2/src/test/java/com/baeldung/logging/log4j2/tests/jdbc/ConnectionFactory.java index cc594f293c..73b323f335 100644 --- a/log4j2/src/test/java/com/baeldung/logging/log4j2/tests/jdbc/ConnectionFactory.java +++ b/log4j2/src/test/java/com/baeldung/logging/log4j2/tests/jdbc/ConnectionFactory.java @@ -2,6 +2,7 @@ package com.baeldung.logging.log4j2.tests.jdbc; import org.apache.commons.dbcp2.BasicDataSource; import org.h2.Driver; + import java.sql.Connection; import java.sql.SQLException;