diff --git a/log4j/pom.xml b/log4j/pom.xml new file mode 100644 index 0000000000..5c73dc848d --- /dev/null +++ b/log4j/pom.xml @@ -0,0 +1,61 @@ + + + 4.0.0 + + com.baeldung + log4j + 1.0-SNAPSHOT + + + + + + log4j + log4j + 1.2.17 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/resources/log4j.xml b/log4j/src/main/resources/log4j.xml new file mode 100644 index 0000000000..1de6c62caf --- /dev/null +++ b/log4j/src/main/resources/log4j.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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..0a854b25b7 --- /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..c70bceab16 --- /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} %-5p %m%n + + + + # File appender + + # Name of a log file + baeldung.log + false + + # Pattern of log message for file appender + %d{yyyy-MM-dd HH:mm:ss} %-5p %m%n + + + + # Override log level for specified package + + + + + + + \ No newline at end of file