diff --git a/logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/Log4j2ComparisonSysout.java b/logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/Log4j2ComparisonSysout.java
new file mode 100644
index 0000000000..53592082b6
--- /dev/null
+++ b/logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/Log4j2ComparisonSysout.java
@@ -0,0 +1,18 @@
+package com.baeldung.logging.log4j2;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.PrintStream;
+
+public class Log4j2ComparisonSysout {
+
+ public static void main(String[] args) throws FileNotFoundException {
+ PrintStream outStream = new PrintStream(new File("outFile.txt"));
+ System.setOut(outStream);
+ System.out.println("This is a baeldung article");
+
+ PrintStream errStream = new PrintStream(new File("errFile.txt"));
+ System.setErr(errStream);
+ System.err.println("This is a baeldung article error");
+ }
+}
diff --git a/logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/Log4j2Example.java b/logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/Log4j2Example.java
new file mode 100644
index 0000000000..b870924cf3
--- /dev/null
+++ b/logging-modules/log4j2/src/main/java/com/baeldung/logging/log4j2/Log4j2Example.java
@@ -0,0 +1,19 @@
+package com.baeldung.logging.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");
+ logger.warn("Warn log message");
+ logger.fatal("Fatal log message");
+ logger.trace("Trace log message");
+ }
+
+}
diff --git a/logging-modules/log4j2/src/test/resources/log4j2.xml b/logging-modules/log4j2/src/test/resources/log4j2.xml
index 246ffb0707..ee26bcecf2 100644
--- a/logging-modules/log4j2/src/test/resources/log4j2.xml
+++ b/logging-modules/log4j2/src/test/resources/log4j2.xml
@@ -5,8 +5,7 @@
-
+