diff --git a/assertj/src/test/java/com/baeldung/assertj/introduction/AssertJGuavaTest.java b/assertj/src/test/java/com/baeldung/assertj/introduction/AssertJGuavaTest.java index 9c51af3ee9..558ce87d70 100644 --- a/assertj/src/test/java/com/baeldung/assertj/introduction/AssertJGuavaTest.java +++ b/assertj/src/test/java/com/baeldung/assertj/introduction/AssertJGuavaTest.java @@ -6,6 +6,7 @@ import com.google.common.collect.Multimap; import com.google.common.collect.Multimaps; import com.google.common.collect.Range; import com.google.common.collect.Sets; +import com.google.common.collect.Table; import com.google.common.collect.TreeRangeMap; import com.google.common.io.Files; import org.assertj.guava.data.MapEntry; @@ -78,7 +79,7 @@ public class AssertJGuavaTest { @Test public void givenTable_whenVerifying_thenShouldBeCorrect() throws Exception { - final HashBasedTable table = HashBasedTable.create(2, 2); + final Table table = HashBasedTable.create(2, 2); table.put(1, "A", "PRESENT"); table.put(1, "B", "ABSENT"); diff --git a/log4j/pom.xml b/log4j/pom.xml new file mode 100644 index 0000000000..76c05b36c1 --- /dev/null +++ b/log4j/pom.xml @@ -0,0 +1,66 @@ + + + 4.0.0 + + com.baeldung + log4j + 1.0-SNAPSHOT + + + + + log4j + log4j + 1.2.17 + + + + + + org.apache.logging.log4j + log4j-api + 2.6 + + + org.apache.logging.log4j + log4j-core + 2.6 + + + + + com.lmax + disruptor + 3.3.4 + + + + + + + ch.qos.logback + logback-classic + 1.1.7 + + + + + + maven-compiler-plugin + 3.3 + + true + true + 1.8 + 1.8 + UTF-8 + true + true + + + + + + \ No newline at end of file diff --git a/log4j/src/main/java/com/baeldung/log4j/Log4jExample.java b/log4j/src/main/java/com/baeldung/log4j/Log4jExample.java new file mode 100644 index 0000000000..e53fdd4881 --- /dev/null +++ b/log4j/src/main/java/com/baeldung/log4j/Log4jExample.java @@ -0,0 +1,17 @@ +package com.baeldung.log4j; + + +import org.apache.log4j.Logger; + +public class Log4jExample { + + private final static Logger logger = Logger.getLogger(Log4jExample.class); + + public static void main(String[] args) { + logger.trace("Trace log message"); + logger.debug("Debug log message"); + logger.info("Info log message"); + logger.error("Error log message"); + } + +} diff --git a/log4j/src/main/java/com/baeldung/log4j2/Log4j2Example.java b/log4j/src/main/java/com/baeldung/log4j2/Log4j2Example.java new file mode 100644 index 0000000000..60acc3a774 --- /dev/null +++ b/log4j/src/main/java/com/baeldung/log4j2/Log4j2Example.java @@ -0,0 +1,16 @@ +package com.baeldung.log4j2; + +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.LogManager; + +public class Log4j2Example { + + private static final Logger logger = LogManager.getLogger(Log4j2Example.class); + + public static void main(String[] args) { + logger.debug("Debug log message"); + logger.info("Info log message"); + logger.error("Error log message"); + } + +} diff --git a/log4j/src/main/java/com/baeldung/logback/LogbackExample.java b/log4j/src/main/java/com/baeldung/logback/LogbackExample.java new file mode 100644 index 0000000000..536aa78ec9 --- /dev/null +++ b/log4j/src/main/java/com/baeldung/logback/LogbackExample.java @@ -0,0 +1,16 @@ +package com.baeldung.logback; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class LogbackExample { + + private static final Logger logger = LoggerFactory.getLogger(LogbackExample.class); + + public static void main(String[] args) { + logger.debug("Debug log message"); + logger.info("Info log message"); + logger.error("Error log message"); + } + +} diff --git a/log4j/src/main/resources/log4j.xml b/log4j/src/main/resources/log4j.xml new file mode 100644 index 0000000000..58a924f970 --- /dev/null +++ b/log4j/src/main/resources/log4j.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/log4j/src/main/resources/log4j2.xml b/log4j/src/main/resources/log4j2.xml new file mode 100644 index 0000000000..76a20bcd61 --- /dev/null +++ b/log4j/src/main/resources/log4j2.xml @@ -0,0 +1,26 @@ + + + + # Console appender + + # Pattern of log message for console appender + + + + # File appender + + # Pattern of log message for file appender + + + + + + # Override log level for specified package + + + + + + + + \ No newline at end of file diff --git a/log4j/src/main/resources/logback.xml b/log4j/src/main/resources/logback.xml new file mode 100644 index 0000000000..fc66d560aa --- /dev/null +++ b/log4j/src/main/resources/logback.xml @@ -0,0 +1,28 @@ + + # Console appender + + + # Pattern of log message for console appender + %d{yyyy-MM-dd HH:mm:ss} %p %m%n + + + + # File appender + + # Name of a log file + log4j/target/baeldung-logback.log + false + + # Pattern of log message for file appender + %d{yyyy-MM-dd HH:mm:ss} %p %m%n + + + + # Override log level for specified package + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 7ad9e76ce9..69f2af98f2 100644 --- a/pom.xml +++ b/pom.xml @@ -36,6 +36,7 @@ rest-testing resteasy + log4j spring-all spring-apache-camel