Add support for SLF4J API
git-svn-id: https://svn.apache.org/repos/asf/logging/log4j/branches/BRANCH_2_0_EXPERIMENTAL/rgoers@1067833 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/log4j2-api/src/main/java/org/apache/logging/log4j/Logger.java b/log4j2-api/src/main/java/org/apache/logging/log4j/Logger.java
index 78fe09d..adb3c40 100644
--- a/log4j2-api/src/main/java/org/apache/logging/log4j/Logger.java
+++ b/log4j2-api/src/main/java/org/apache/logging/log4j/Logger.java
@@ -26,14 +26,6 @@
*/
public interface Logger {
- static Marker FLOW_MARKER = Marker.getMarker("FLOW");
- static Marker ENTRY_MARKER = Marker.getMarker("ENTRY", FLOW_MARKER);
- static Marker EXIT_MARKER = Marker.getMarker("EXIT", FLOW_MARKER);
-
- static Marker EXCEPTION_MARKER = Marker.getMarker("EXCEPTION");
- static Marker THROWING_MARKER = Marker.getMarker("THROWING", EXCEPTION_MARKER);
- static Marker CATCHING_MARKER = Marker.getMarker("CATCHING", EXCEPTION_MARKER);
-
/**
* Log entry to a method.
*/
@@ -95,6 +87,14 @@
void trace(String message);
/**
+ * Log a message object with the {@link org.apache.logging.log4j.Level#TRACE TRACE} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message object to log.
+ */
+ void trace(Marker marker, String message);
+
+ /**
* Log a message at the <code>TRACE</code> level including the
* stack trace of the {@link Throwable}<code>t</code> passed as parameter.
* <p/>
@@ -108,6 +108,20 @@
void trace(String message, Throwable t);
/**
+ * Log a message at the <code>TRACE</code> level including the
+ * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
+ * <p/>
+ * <p>
+ * See {@link #debug(String)} form for more detailed information.
+ * </p>
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message object to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ void trace(Marker marker, String message, Throwable t);
+
+ /**
* Log a message object with the {@link org.apache.logging.log4j.Level#TRACE TRACE} level.
*
* @param message the message object to log.
@@ -115,6 +129,14 @@
void trace(Object message);
/**
+ * Log a message object with the {@link org.apache.logging.log4j.Level#TRACE TRACE} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message object to log.
+ */
+ void trace(Marker marker, Object message);
+
+ /**
* Log a message at the <code>TRACE</code> level including the
* stack trace of the {@link Throwable}<code>t</code> passed as parameter.
* <p/>
@@ -127,6 +149,20 @@
*/
void trace(Object message, Throwable t);
+ /**
+ * Log a message at the <code>TRACE</code> level including the
+ * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
+ * <p/>
+ * <p>
+ * See {@link #debug(String)} form for more detailed information.
+ * </p>
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message object to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ void trace(Marker marker, Object message, Throwable t);
+
/**
* Log a message with parameters at the <code>TRACE</code> level.
* @param message the message to log.
@@ -135,6 +171,15 @@
void trace(String message, Object... params);
/**
+ * Log a message with parameters at the <code>TRACE</code> level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log.
+ * @param params parameters to the message.
+ */
+ void trace(Marker marker, String message, Object... params);
+
+ /**
* Check whether this Logger is enabled for the TRACE Level.
*
* @return boolean - <code>true</code> if this Logger is enabled for level
@@ -191,6 +236,14 @@
void debug(String message);
/**
+ * Log a message object with the {@link org.apache.logging.log4j.Level#DEBUG DEBUG} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message object to log.
+ */
+ void debug(Marker marker, String message);
+
+ /**
* Log a message at the <code>DEBUG</code> level including the
* stack trace of the {@link Throwable}<code>t</code> passed as parameter.
*
@@ -200,6 +253,16 @@
void debug(String message, Throwable t);
/**
+ * Log a message at the <code>DEBUG</code> level including the
+ * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ void debug(Marker marker, String message, Throwable t);
+
+ /**
* Log a message object with the {@link org.apache.logging.log4j.Level#DEBUG DEBUG} level.
*
* @param message the message object to log.
@@ -207,6 +270,14 @@
void debug(Object message);
/**
+ * Log a message object with the {@link org.apache.logging.log4j.Level#DEBUG DEBUG} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message object to log.
+ */
+ void debug(Marker marker, Object message);
+
+ /**
* Log a message at the <code>DEBUG</code> level including the
* stack trace of the {@link Throwable}<code>t</code> passed as parameter.
*
@@ -216,6 +287,16 @@
void debug(Object message, Throwable t);
/**
+ * Log a message at the <code>DEBUG</code> level including the
+ * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ void debug(Marker marker, Object message, Throwable t);
+
+ /**
* Log a message with parameters at the <code>DEBUG</code> level.
* @param message the message to log.
* @param params parameters to the message.
@@ -223,6 +304,15 @@
void debug(String message, Object... params);
/**
+ * Log a message with parameters at the <code>DEBUG</code> level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log.
+ * @param params parameters to the message.
+ */
+ void debug(Marker marker, String message, Object... params);
+
+ /**
* Check whether this Logger is enabled for the DEBUG Level.
*
* @return boolean - <code>true</code> if this Logger is enabled for level
@@ -279,6 +369,14 @@
void info(String message);
/**
+ * Log a message object with the {@link org.apache.logging.log4j.Level#INFO INFO} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message object to log.
+ */
+ void info(Marker marker, String message);
+
+ /**
* Log a message at the <code>INFO</code> level including the
* stack trace of the {@link Throwable}<code>t</code> passed as parameter.
*
@@ -288,6 +386,16 @@
void info(String message, Throwable t);
/**
+ * Log a message at the <code>INFO</code> level including the
+ * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message object to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ void info(Marker marker, String message, Throwable t);
+
+ /**
* Log a message object with the {@link org.apache.logging.log4j.Level#INFO INFO} level.
*
* @param message the message object to log.
@@ -295,6 +403,14 @@
void info(Object message);
/**
+ * Log a message object with the {@link org.apache.logging.log4j.Level#INFO INFO} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message object to log.
+ */
+ void info(Marker marker, Object message);
+
+ /**
* Log a message at the <code>INFO</code> level including the
* stack trace of the {@link Throwable}<code>t</code> passed as parameter.
*
@@ -304,9 +420,21 @@
void info(Object message, Throwable t);
/**
+ * Log a message at the <code>INFO</code> level including the
+ * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message object to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ void info(Marker marker, Object message, Throwable t);
+
+ /**
* Log a message with parameters at the <code>INFO</code> level.
+ *
* @param message the message to log.
* @param params parameters to the message.
+ *
* @doubt Likely to misinterpret existing log4j client code that intended to call
* info(Object,Throwable). Incurs array creation expense on every call. (RG) It isn't
* possible to be misinterpreted as the previous method is for that signature. Methods
@@ -315,6 +443,19 @@
void info(String message, Object... params);
/**
+ * Log a message with parameters at the <code>INFO</code> level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message to log.
+ * @param params parameters to the message.
+ *
+ * @doubt Likely to misinterpret existing log4j client code that intended to call
+ * info(Object,Throwable). Incurs array creation expense on every call. (RG) It isn't
+ * possible to be misinterpreted as the previous method is for that signature. Methods
+ * should be added to avoid varargs for 1, 2 or 3 parameters.
+ */
+ void info(Marker marker, String message, Object... params);
+ /**
* Check whether this Logger is enabled for the INFO Level.
*
* @return boolean - <code>true</code> if this Logger is enabled for level
@@ -363,7 +504,7 @@
*/
void info(Marker marker, Message msg, Throwable t);
- /**
+ /**
* Log a message object with the {@link org.apache.logging.log4j.Level#WARN WARN} level.
*
* @param message the message object to log.
@@ -371,6 +512,14 @@
void warn(String message);
/**
+ * Log a message object with the {@link org.apache.logging.log4j.Level#WARN WARN} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message object to log.
+ */
+ void warn(Marker marker, String message);
+
+ /**
* Log a message at the <code>WARN</code> level including the
* stack trace of the {@link Throwable}<code>t</code> passed as parameter.
*
@@ -379,6 +528,16 @@
*/
void warn(String message, Throwable t);
+ /**
+ * Log a message at the <code>WARN</code> level including the
+ * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message object to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ void warn(Marker marker, String message, Throwable t);
+
/**
* Log a message object with the {@link org.apache.logging.log4j.Level#WARN WARN} level.
*
@@ -387,6 +546,14 @@
void warn(Object message);
/**
+ * Log a message object with the {@link org.apache.logging.log4j.Level#WARN WARN} level.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message object to log.
+ */
+ void warn(Marker marker, Object message);
+
+ /**
* Log a message at the <code>WARN</code> level including the
* stack trace of the {@link Throwable}<code>t</code> passed as parameter.
*
@@ -396,6 +563,16 @@
void warn(Object message, Throwable t);
/**
+ * Log a message at the <code>WARN</code> level including the
+ * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
+ *
+ * @param marker the marker data specific to this log statement
+ * @param message the message object to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ void warn(Marker marker, Object message, Throwable t);
+
+ /**
* Log a message with parameters at the <code>WARN</code> level.
* @param message the message to log.
* @param params parameters to the message.
@@ -407,6 +584,20 @@
void warn(String message, Object... params);
/**
+ * Log a message with parameters at the <code>WARN</code> level.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message to log.
+ * @param params parameters to the message.
+ *
+ * @doubt Likely to misinterpret existing log4j client code that intended to call
+ * info(Object,Throwable). Incurs array creation expense on every call. (RG) I assume you
+ * meant warn, not info. It isn't possible to be misinterpreted as the previous method
+ * is for that signature.Methods should be added to avoid varargs for 1, 2 or 3 parameters.
+ */
+ void warn(Marker marker, String message, Object... params);
+
+ /**
* Check whether this Logger is enabled for the WARN Level.
*
* @return boolean - <code>true</code> if this Logger is enabled for level
@@ -463,6 +654,14 @@
void error(String message);
/**
+ * Log a message object with the {@link org.apache.logging.log4j.Level#ERROR ERROR} level.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message object to log.
+ */
+ void error(Marker marker, String message);
+
+ /**
* Log a message at the <code>ERROR</code> level including the
* stack trace of the {@link Throwable}<code>t</code> passed as parameter.
*
@@ -472,6 +671,16 @@
void error(String message, Throwable t);
/**
+ * Log a message at the <code>ERROR</code> level including the
+ * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message object to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ void error(Marker marker, String message, Throwable t);
+
+ /**
* Log a message object with the {@link org.apache.logging.log4j.Level#ERROR ERROR} level.
*
* @param message the message object to log.
@@ -479,6 +688,14 @@
void error(Object message);
/**
+ * Log a message object with the {@link org.apache.logging.log4j.Level#ERROR ERROR} level.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message object to log.
+ */
+ void error(Marker marker, Object message);
+
+ /**
* Log a message at the <code>ERROR</code> level including the
* stack trace of the {@link Throwable}<code>t</code> passed as parameter.
*
@@ -488,9 +705,21 @@
void error(Object message, Throwable t);
/**
+ * Log a message at the <code>ERROR</code> level including the
+ * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message object to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ void error(Marker marker, Object message, Throwable t);
+
+ /**
* Log a message with parameters at the <code>ERROR</code> level.
+ *
* @param message the message to log.
* @param params parameters to the message.
+ *
* @doubt Likely to misinterpret existing log4j client code that intended to call
* info(Object,Throwable). Incurs array creation expense on every call. (RG) I assume you
* meant error, not info. It isn't possible to be misinterpreted as the previous method
@@ -499,6 +728,19 @@
void error(String message, Object... params);
/**
+ * Log a message with parameters at the <code>ERROR</code> level.
+ * @param marker the marker data specific to this log statement.
+ * @param message the message to log.
+ * @param params parameters to the message.
+ *
+ * @doubt Likely to misinterpret existing log4j client code that intended to call
+ * info(Object,Throwable). Incurs array creation expense on every call. (RG) I assume you
+ * meant error, not info. It isn't possible to be misinterpreted as the previous method
+ * is for that signature. Methods should be added to avoid varargs for 1, 2 or 3 parameters.
+ */
+ void error(Marker marker, String message, Object... params);
+
+ /**
* Check whether this Logger is enabled for the ERROR Level.
*
* @return boolean - <code>true</code> if this Logger is enabled for level
@@ -555,6 +797,14 @@
void fatal(String message);
/**
+ * Log a message object with the {@link org.apache.logging.log4j.Level#FATAL FATAL} level.
+ *
+ * @param marker The marker data specific to this log statement.
+ * @param message the message object to log.
+ */
+ void fatal(Marker marker, String message);
+
+ /**
* Log a message at the <code>FATAL</code> level including the
* stack trace of the {@link Throwable}<code>t</code> passed as parameter.
*
@@ -563,7 +813,18 @@
*/
void fatal(String message, Throwable t);
- /**
+
+ /**
+ * Log a message at the <code>FATAL</code> level including the
+ * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
+ *
+ * @param marker The marker data specific to this log statement.
+ * @param message the message object to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ void fatal(Marker marker, String message, Throwable t);
+
+ /**
* Log a message object with the {@link org.apache.logging.log4j.Level#FATAL FATAL} level.
*
* @param message the message object to log.
@@ -571,6 +832,14 @@
void fatal(Object message);
/**
+ * Log a message object with the {@link org.apache.logging.log4j.Level#FATAL FATAL} level.
+ *
+ * @param marker The marker data specific to this log statement.
+ * @param message the message object to log.
+ */
+ void fatal(Marker marker, Object message);
+
+ /**
* Log a message at the <code>FATAL</code> level including the
* stack trace of the {@link Throwable}<code>t</code> passed as parameter.
*
@@ -578,10 +847,24 @@
* @param t the exception to log, including its stack trace.
*/
void fatal(Object message, Throwable t);
+
+ /**
+ * Log a message at the <code>FATAL</code> level including the
+ * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
+ *
+ * @param marker The marker data specific to this log statement.
+ * @param message the message object to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ void fatal(Marker marker, Object message, Throwable t);
+
/**
* Log a message with parameters at the <code>FATAL</code> level.
+ *
+ *
* @param message the message to log.
* @param params parameters to the message.
+ *
* @doubt Likely to misinterpret existing log4j client code that intended to call
* info(Object,Throwable). Incurs array creation expense on every call.(RG) I assume you
* meant fatal, not info. It isn't possible to be misinterpreted as the previous method
@@ -590,6 +873,20 @@
void fatal(String message, Object... params);
/**
+ * Log a message with parameters at the <code>FATAL</code> level.
+ *
+ * @param marker The marker data specific to this log statement.
+ * @param message the message to log.
+ * @param params parameters to the message.
+ *
+ * @doubt Likely to misinterpret existing log4j client code that intended to call
+ * info(Object,Throwable). Incurs array creation expense on every call.(RG) I assume you
+ * meant fatal, not info. It isn't possible to be misinterpreted as the previous method
+ * is for that signature. Methods should be added to avoid varargs for 1, 2 or 3 parameters.
+ */
+ void fatal(Marker marker, String message, Object... params);
+
+ /**
* Check whether this Logger is enabled for the FATAL Level.
*
* @return boolean - <code>true</code> if this Logger is enabled for level
diff --git a/log4j2-api/src/main/java/org/apache/logging/log4j/Marker.java b/log4j2-api/src/main/java/org/apache/logging/log4j/Marker.java
index 66e8c0a..b87bc25 100644
--- a/log4j2-api/src/main/java/org/apache/logging/log4j/Marker.java
+++ b/log4j2-api/src/main/java/org/apache/logging/log4j/Marker.java
@@ -17,87 +17,14 @@
package org.apache.logging.log4j;
import java.io.Serializable;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
/**
*/
-public class Marker implements Serializable {
+public interface Marker extends Serializable {
- private static ConcurrentMap<String, Marker> markerMap = new ConcurrentHashMap<String, Marker>();
+ public String getName();
- public static Marker getMarker(String name) {
- markerMap.putIfAbsent(name, new Marker(name));
- return markerMap.get(name);
- }
+ public Marker getParent();
- public static Marker getMarker(String name, String parent) {
- Marker parentMarker = markerMap.get(parent);
- if (parentMarker == null) {
- throw new IllegalArgumentException("Parent Marker " + parent + " has not been defined");
- }
- return getMarker(name, parentMarker);
- }
-
- public static Marker getMarker(String name, Marker parent) {
- markerMap.putIfAbsent(name, new Marker(name, parent));
- return markerMap.get(name);
- }
-
- private String name;
- private Marker parent;
-
- private Marker(String name) {
- this.name = name;
- }
-
- private Marker(String name, Marker parent) {
- this.name = name;
- this.parent = parent;
- }
-
- public String getName() {
- return this.name;
- }
-
- public Marker getParent() {
- return this.parent;
- }
-
- public boolean isInstanceOf(Marker m) {
- if (m == null) {
- throw new IllegalArgumentException("A marker parameter is required");
- }
- Marker test = this;
- do {
- if (test == m) {
- return true;
- }
- test = test.getParent();
- } while (test != null);
- return false;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- Marker marker = (Marker) o;
-
- if (name != null ? !name.equals(marker.name) : marker.name != null) {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode() {
- return name != null ? name.hashCode() : 0;
- }
+ public boolean isInstanceOf(Marker m);
}
diff --git a/log4j2-api/src/main/java/org/apache/logging/log4j/MarkerManager.java b/log4j2-api/src/main/java/org/apache/logging/log4j/MarkerManager.java
new file mode 100644
index 0000000..6a4abfb
--- /dev/null
+++ b/log4j2-api/src/main/java/org/apache/logging/log4j/MarkerManager.java
@@ -0,0 +1,109 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+
+/**
+ *
+ */
+public class MarkerManager {
+
+ private static ConcurrentMap<String, Marker> markerMap = new ConcurrentHashMap<String, Marker>();
+
+ public static Marker getMarker(String name) {
+ markerMap.putIfAbsent(name, new Log4JMarker(name));
+ return markerMap.get(name);
+ }
+
+ public static Marker getMarker(String name, String parent) {
+ Marker parentMarker = markerMap.get(parent);
+ if (parentMarker == null) {
+ throw new IllegalArgumentException("Parent Marker " + parent + " has not been defined");
+ }
+ return getMarker(name, parentMarker);
+ }
+
+ public static Marker getMarker(String name, Marker parent) {
+ markerMap.putIfAbsent(name, new Log4JMarker(name, parent));
+ return markerMap.get(name);
+ }
+
+ private static class Log4JMarker implements Marker {
+
+ private static final long serialVersionUID = 100L;
+
+ private String name;
+ private Marker parent;
+
+ public Log4JMarker(String name) {
+ this.name = name;
+ }
+
+ public Log4JMarker(String name, Marker parent) {
+ this.name = name;
+ this.parent = parent;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public Marker getParent() {
+ return this.parent;
+ }
+
+ public boolean isInstanceOf(Marker m) {
+ if (m == null) {
+ throw new IllegalArgumentException("A marker parameter is required");
+ }
+ Marker test = this;
+ do {
+ if (test == m) {
+ return true;
+ }
+ test = test.getParent();
+ } while (test != null);
+ return false;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ Marker marker = (Marker) o;
+
+ if (name != null ? !name.equals(marker.getName()) : marker.getName() != null) {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ return name != null ? name.hashCode() : 0;
+ }
+ }
+}
diff --git a/log4j2-api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java b/log4j2-api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java
index cc6ad85..920b92d 100644
--- a/log4j2-api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java
+++ b/log4j2-api/src/main/java/org/apache/logging/log4j/spi/AbstractLogger.java
@@ -19,6 +19,7 @@
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
+import org.apache.logging.log4j.MarkerManager;
import org.apache.logging.log4j.message.Message;
import org.apache.logging.log4j.message.ObjectMessage;
import org.apache.logging.log4j.message.ParameterizedMessage;
@@ -29,17 +30,25 @@
*/
public abstract class AbstractLogger implements Logger {
+ static Marker FLOW_MARKER = MarkerManager.getMarker("FLOW");
+ static Marker ENTRY_MARKER = MarkerManager.getMarker("ENTRY", FLOW_MARKER);
+ static Marker EXIT_MARKER = MarkerManager.getMarker("EXIT", FLOW_MARKER);
+
+ static Marker EXCEPTION_MARKER = MarkerManager.getMarker("EXCEPTION");
+ static Marker THROWING_MARKER = MarkerManager.getMarker("THROWING", EXCEPTION_MARKER);
+ static Marker CATCHING_MARKER = MarkerManager.getMarker("CATCHING", EXCEPTION_MARKER);
+
protected String getFQCN() {
return AbstractLogger.class.getName();
}
-
+
/**
* Log entry to a method.
*/
public void entry() {
- if (isEnabled(Level.TRACE, Logger.ENTRY_MARKER, (Object)null, null)) {
- log(Logger.ENTRY_MARKER, getFQCN(), Level.TRACE, new SimpleMessage(" entry"), null);
+ if (isEnabled(Level.TRACE, ENTRY_MARKER, (Object)null, null)) {
+ log(ENTRY_MARKER, getFQCN(), Level.TRACE, new SimpleMessage(" entry"), null);
}
}
@@ -50,8 +59,8 @@
* @param params The parameters to the method.
*/
public void entry(Object... params) {
- if (isEnabled(Level.TRACE, Logger.ENTRY_MARKER, (Object)null, null)) {
- log(Logger.ENTRY_MARKER, getFQCN(), Level.TRACE, entryMsg(params.length, params), null);
+ if (isEnabled(Level.TRACE, ENTRY_MARKER, (Object)null, null)) {
+ log(ENTRY_MARKER, getFQCN(), Level.TRACE, entryMsg(params.length, params), null);
}
}
@@ -59,8 +68,8 @@
* Log exit from a method.
*/
public void exit() {
- if (isEnabled(Level.TRACE, Logger.EXIT_MARKER, (Object)null, null)) {
- log(Logger.EXIT_MARKER, getFQCN(), Level.TRACE, exitMsg(null), null);
+ if (isEnabled(Level.TRACE, EXIT_MARKER, (Object)null, null)) {
+ log(EXIT_MARKER, getFQCN(), Level.TRACE, exitMsg(null), null);
}
}
@@ -70,8 +79,8 @@
* @param result The result being returned from the method call.
*/
public void exit(Object result) {
- if (isEnabled(Level.TRACE, Logger.EXIT_MARKER, (Object)null, null)) {
- log(Logger.EXIT_MARKER, getFQCN(), Level.TRACE, exitMsg(result), null);
+ if (isEnabled(Level.TRACE, EXIT_MARKER, (Object)null, null)) {
+ log(EXIT_MARKER, getFQCN(), Level.TRACE, exitMsg(result), null);
}
}
@@ -81,8 +90,8 @@
* @param t The Throwable.
*/
public void throwing(Throwable t) {
- if (isEnabled(Level.ERROR, Logger.THROWING_MARKER, (Object)null, null)) {
- log(Logger.THROWING_MARKER, getFQCN(), Level.ERROR, new SimpleMessage("throwing"), t);
+ if (isEnabled(Level.ERROR, THROWING_MARKER, (Object)null, null)) {
+ log(THROWING_MARKER, getFQCN(), Level.ERROR, new SimpleMessage("throwing"), t);
}
}
@@ -94,8 +103,8 @@
* @param t The Throwable.
*/
public void throwing(Level level, Throwable t) {
- if (isEnabled(level, Logger.THROWING_MARKER, (Object)null, null)) {
- log(Logger.THROWING_MARKER, getFQCN(), level, new SimpleMessage("throwing"), t);
+ if (isEnabled(level, THROWING_MARKER, (Object)null, null)) {
+ log(THROWING_MARKER, getFQCN(), level, new SimpleMessage("throwing"), t);
}
}
@@ -105,8 +114,8 @@
* @param t The Throwable.
*/
public void catching(Throwable t) {
- if (isEnabled(Level.DEBUG, Logger.THROWING_MARKER, (Object)null, null)) {
- log(Logger.THROWING_MARKER, getFQCN(), Level.DEBUG, new SimpleMessage("catching"), t);
+ if (isEnabled(Level.DEBUG, THROWING_MARKER, (Object)null, null)) {
+ log(THROWING_MARKER, getFQCN(), Level.DEBUG, new SimpleMessage("catching"), t);
}
}
@@ -117,8 +126,8 @@
* @param t The Throwable.
*/
public void catching(Level level, Throwable t) {
- if (isEnabled(level, Logger.THROWING_MARKER, (Object)null, null)) {
- log(Logger.THROWING_MARKER, getFQCN(), level, new SimpleMessage("catching"), t);
+ if (isEnabled(level, THROWING_MARKER, (Object)null, null)) {
+ log(THROWING_MARKER, getFQCN(), level, new SimpleMessage("catching"), t);
}
}
@@ -134,6 +143,18 @@
}
/**
+ * Log a message object with the {@link org.apache.logging.log4j.Level#TRACE TRACE} level.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message object to log.
+ */
+ public void trace(Marker marker, String message) {
+ if (isEnabled(Level.TRACE, marker, message)) {
+ log(marker, getFQCN(), Level.TRACE, new SimpleMessage(message), null);
+ }
+ }
+
+ /**
* Log a message at the <code>TRACE</code> level including the
* stack trace of the {@link Throwable}<code>t</code> passed as parameter.
* <p/>
@@ -150,6 +171,25 @@
}
}
+
+ /**
+ * Log a message at the <code>TRACE</code> level including the
+ * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
+ * <p/>
+ * <p>
+ * See {@link #debug(String)} form for more detailed information.
+ * </p>
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message object to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ public void trace(Marker marker, String message, Throwable t) {
+ if (isEnabled(Level.TRACE, marker, message, t)) {
+ log(marker, getFQCN(), Level.TRACE, new SimpleMessage(message), t);
+ }
+ }
+
/**
* Log a message object with the {@link org.apache.logging.log4j.Level#TRACE TRACE} level.
*
@@ -162,6 +202,18 @@
}
/**
+ * Log a message object with the {@link org.apache.logging.log4j.Level#TRACE TRACE} level.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message object to log.
+ */
+ public void trace(Marker marker, Object message) {
+ if (isEnabled(Level.TRACE, marker, message, null)) {
+ log(marker, getFQCN(), Level.TRACE, new ObjectMessage(message), null);
+ }
+ }
+
+ /**
* Log a message at the <code>TRACE</code> level including the
* stack trace of the {@link Throwable}<code>t</code> passed as parameter.
* <p/>
@@ -179,6 +231,24 @@
}
/**
+ * Log a message at the <code>TRACE</code> level including the
+ * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
+ * <p/>
+ * <p>
+ * See {@link #debug(String)} form for more detailed information.
+ * </p>
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message object to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ public void trace(Marker marker, Object message, Throwable t) {
+ if (isEnabled(Level.TRACE, marker, message, t)) {
+ log(marker, getFQCN(), Level.TRACE, new ObjectMessage(message), t);
+ }
+ }
+
+ /**
* Log a message with parameters at the <code>TRACE</code> level.
*
* @param message the message to log.
@@ -191,6 +261,19 @@
}
/**
+ * Log a message with parameters at the <code>TRACE</code> level.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message to log.
+ * @param params parameters to the message.
+ */
+ public void trace(Marker marker, String message, Object... params) {
+ if (isEnabled(Level.TRACE, marker, message, params)) {
+ log(marker, getFQCN(), Level.TRACE, new ParameterizedMessage(message, params), null);
+ }
+ }
+
+ /**
* Check whether this Logger is enabled for the TRACE Level.
*
* @return boolean - <code>true</code> if this Logger is enabled for level
@@ -236,7 +319,7 @@
/**
* Log a message with the specific Marker at the TRACE level.
*
- * @param marker the marker data specific to this log statement
+ * @param marker the marker data specific to this log statement.
* @param msg the message string to be logged
*/
public void trace(Marker marker, Message msg) {
@@ -248,7 +331,7 @@
/**
* Log a message with the specific Marker at the TRACE level.
*
- * @param marker the marker data specific to this log statement
+ * @param marker the marker data specific to this log statement.
* @param msg the message string to be logged
* @param t A Throwable or null.
*/
@@ -270,6 +353,18 @@
}
/**
+ * Log a message object with the {@link org.apache.logging.log4j.Level#DEBUG DEBUG} level.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message object to log.
+ */
+ public void debug(Marker marker, String message) {
+ if (isEnabled(Level.DEBUG, marker, message)) {
+ log(marker, getFQCN(), Level.DEBUG, new SimpleMessage(message), null);
+ }
+ }
+
+ /**
* Log a message at the <code>DEBUG</code> level including the
* stack trace of the {@link Throwable}<code>t</code> passed as parameter.
*
@@ -283,6 +378,19 @@
}
/**
+ * Log a message at the <code>DEBUG</code> level including the
+ * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ public void debug(Marker marker, String message, Throwable t) {
+ if (isEnabled(Level.DEBUG, marker, message, t)) {
+ log(marker, getFQCN(), Level.DEBUG, new SimpleMessage(message), t);
+ }
+ }
+ /**
* Log a message object with the {@link org.apache.logging.log4j.Level#DEBUG DEBUG} level.
*
* @param message the message object to log.
@@ -294,6 +402,18 @@
}
/**
+ * Log a message object with the {@link org.apache.logging.log4j.Level#DEBUG DEBUG} level.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message object to log.
+ */
+ public void debug(Marker marker, Object message) {
+ if (isEnabled(Level.DEBUG, marker, message, null)) {
+ log(marker, getFQCN(), Level.DEBUG, new ObjectMessage(message), null);
+ }
+ }
+
+ /**
* Log a message at the <code>DEBUG</code> level including the
* stack trace of the {@link Throwable}<code>t</code> passed as parameter.
*
@@ -305,6 +425,21 @@
log(null, getFQCN(), Level.DEBUG, new ObjectMessage(message), t);
}
}
+
+ /**
+ * Log a message at the <code>DEBUG</code> level including the
+ * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ public void debug(Marker marker, Object message, Throwable t) {
+ if (isEnabled(Level.DEBUG, marker, message, t)) {
+ log(marker, getFQCN(), Level.DEBUG, new ObjectMessage(message), t);
+ }
+ }
+
/**
* Log a message with parameters at the <code>DEBUG</code> level.
*
@@ -318,6 +453,19 @@
}
/**
+ * Log a message with parameters at the <code>DEBUG</code> level.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message to log.
+ * @param params parameters to the message.
+ */
+ public void debug(Marker marker, String message, Object... params) {
+ if (isEnabled(Level.DEBUG, marker, message, params)) {
+ log(marker, getFQCN(), Level.DEBUG, new ParameterizedMessage(message, params), null);
+ }
+ }
+
+ /**
* Check whether this Logger is enabled for the DEBUG Level.
*
* @return boolean - <code>true</code> if this Logger is enabled for level
@@ -375,7 +523,7 @@
/**
* Log a message with the specific Marker at the DEBUG level.
*
- * @param marker the marker data specific to this log statement
+ * @param marker the marker data specific to this log statement.
* @param msg the message string to be logged
* @param t A Throwable or null.
*/
@@ -397,6 +545,18 @@
}
/**
+ * Log a message object with the {@link org.apache.logging.log4j.Level#INFO INFO} level.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message object to log.
+ */
+ public void info(Marker marker, String message) {
+ if (isEnabled(Level.INFO, marker, message)) {
+ log(marker, getFQCN(), Level.INFO, new SimpleMessage(message), null);
+ }
+ }
+
+ /**
* Log a message at the <code>INFO</code> level including the
* stack trace of the {@link Throwable}<code>t</code> passed as parameter.
*
@@ -410,6 +570,20 @@
}
/**
+ * Log a message at the <code>INFO</code> level including the
+ * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message object to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ public void info(Marker marker, String message, Throwable t) {
+ if (isEnabled(Level.INFO, marker, message, t)) {
+ log(marker, getFQCN(), Level.INFO, new SimpleMessage(message), t);
+ }
+ }
+
+ /**
* Log a message object with the {@link org.apache.logging.log4j.Level#INFO INFO} level.
*
* @param message the message object to log.
@@ -421,6 +595,18 @@
}
/**
+ * Log a message object with the {@link org.apache.logging.log4j.Level#INFO INFO} level.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message object to log.
+ */
+ public void info(Marker marker, Object message) {
+ if (isEnabled(Level.INFO, marker, message, null)) {
+ log(marker, getFQCN(), Level.INFO, new ObjectMessage(message), null);
+ }
+ }
+
+ /**
* Log a message at the <code>INFO</code> level including the
* stack trace of the {@link Throwable}<code>t</code> passed as parameter.
*
@@ -433,6 +619,21 @@
}
}
+
+ /**
+ * Log a message at the <code>INFO</code> level including the
+ * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message object to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ public void info(Marker marker, Object message, Throwable t) {
+ if (isEnabled(Level.INFO, marker, message, t)) {
+ log(marker, getFQCN(), Level.INFO, new ObjectMessage(message), t);
+ }
+ }
+
/**
* Log a message with parameters at the <code>INFO</code> level.
*
@@ -446,6 +647,19 @@
}
/**
+ * Log a message with parameters at the <code>INFO</code> level.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message to log.
+ * @param params parameters to the message.
+ */
+ public void info(Marker marker, String message, Object... params) {
+ if (isEnabled(Level.INFO, marker, message, params)) {
+ log(marker, getFQCN(), Level.INFO, new ParameterizedMessage(message, params), null);
+ }
+ }
+
+ /**
* Check whether this Logger is enabled for the INFO Level.
*
* @return boolean - <code>true</code> if this Logger is enabled for level
@@ -525,6 +739,18 @@
}
/**
+ * Log a message object with the {@link org.apache.logging.log4j.Level#WARN WARN} level.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message object to log.
+ */
+ public void warn(Marker marker, String message) {
+ if (isEnabled(Level.WARN, marker, message)) {
+ log(marker, getFQCN(), Level.WARN, new SimpleMessage(message), null);
+ }
+ }
+
+ /**
* Log a message at the <code>WARN</code> level including the
* stack trace of the {@link Throwable}<code>t</code> passed as parameter.
*
@@ -538,6 +764,32 @@
}
/**
+ * Log a message at the <code>WARN</code> level including the
+ * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message object to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ public void warn(Marker marker, String message, Throwable t) {
+ if (isEnabled(Level.WARN, marker, message, t)) {
+ log(marker, getFQCN(), Level.DEBUG, new SimpleMessage(message), t);
+ }
+ }
+
+ /**
+ * Log a message object with the {@link org.apache.logging.log4j.Level#WARN WARN} level.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message object to log.
+ */
+ public void warn(Marker marker, Object message) {
+ if (isEnabled(Level.WARN, marker, message, null)) {
+ log(marker, getFQCN(), Level.WARN, new ObjectMessage(message), null);
+ }
+ }
+
+ /**
* Log a message object with the {@link org.apache.logging.log4j.Level#WARN WARN} level.
*
* @param message the message object to log.
@@ -562,6 +814,20 @@
}
/**
+ * Log a message at the <code>WARN</code> level including the
+ * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message object to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ public void warn(Marker marker, Object message, Throwable t) {
+ if (isEnabled(Level.WARN, marker, message, t)) {
+ log(marker, getFQCN(), Level.DEBUG, new ObjectMessage(message), t);
+ }
+ }
+
+ /**
* Log a message with parameters at the <code>WARN</code> level.
*
* @param message the message to log.
@@ -574,6 +840,19 @@
}
/**
+ * Log a message with parameters at the <code>WARN</code> level.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message to log.
+ * @param params parameters to the message.
+ */
+ public void warn(Marker marker, String message, Object... params) {
+ if (isEnabled(Level.WARN, marker, message, params)) {
+ log(marker, getFQCN(), Level.WARN, new ParameterizedMessage(message, params), null);
+ }
+ }
+
+ /**
* Check whether this Logger is enabled for the WARN Level.
*
* @return boolean - <code>true</code> if this Logger is enabled for level
@@ -653,6 +932,18 @@
}
/**
+ * Log a message object with the {@link org.apache.logging.log4j.Level#ERROR ERROR} level.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message object to log.
+ */
+ public void error(Marker marker, String message) {
+ if (isEnabled(Level.ERROR, marker, message)) {
+ log(marker, getFQCN(), Level.ERROR, new SimpleMessage(message), null);
+ }
+ }
+
+ /**
* Log a message at the <code>ERROR</code> level including the
* stack trace of the {@link Throwable}<code>t</code> passed as parameter.
*
@@ -666,6 +957,20 @@
}
/**
+ * Log a message at the <code>ERROR</code> level including the
+ * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message object to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ public void error(Marker marker, String message, Throwable t) {
+ if (isEnabled(Level.ERROR, marker, message, t)) {
+ log(marker, getFQCN(), Level.ERROR, new SimpleMessage(message), t);
+ }
+ }
+
+ /**
* Log a message object with the {@link org.apache.logging.log4j.Level#ERROR ERROR} level.
*
* @param message the message object to log.
@@ -677,6 +982,18 @@
}
/**
+ * Log a message object with the {@link org.apache.logging.log4j.Level#ERROR ERROR} level.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message object to log.
+ */
+ public void error(Marker marker, Object message) {
+ if (isEnabled(Level.ERROR, marker, message, null)) {
+ log(marker, getFQCN(), Level.ERROR, new ObjectMessage(message), null);
+ }
+ }
+
+ /**
* Log a message at the <code>ERROR</code> level including the
* stack trace of the {@link Throwable}<code>t</code> passed as parameter.
*
@@ -690,6 +1007,20 @@
}
/**
+ * Log a message at the <code>ERROR</code> level including the
+ * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message object to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ public void error(Marker marker, Object message, Throwable t) {
+ if (isEnabled(Level.ERROR, marker, message, t)) {
+ log(marker, getFQCN(), Level.ERROR, new ObjectMessage(message), t);
+ }
+ }
+
+ /**
* Log a message with parameters at the <code>ERROR</code> level.
*
* @param message the message to log.
@@ -702,6 +1033,20 @@
}
/**
+ * Log a message with parameters at the <code>ERROR</code> level.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message to log.
+ * @param params parameters to the message.
+ */
+ public void error(Marker marker, String message, Object... params) {
+ if (isEnabled(Level.ERROR, marker, message, params)) {
+ log(marker, getFQCN(), Level.ERROR, new ParameterizedMessage(message, params), null);
+ }
+ }
+
+
+ /**
* Check whether this Logger is enabled for the ERROR Level.
*
* @return boolean - <code>true</code> if this Logger is enabled for level
@@ -780,6 +1125,19 @@
}
}
+
+ /**
+ * Log a message object with the {@link org.apache.logging.log4j.Level#FATAL FATAL} level.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message object to log.
+ */
+ public void fatal(Marker marker, String message) {
+ if (isEnabled(Level.FATAL, marker, message)) {
+ log(marker, getFQCN(), Level.FATAL, new SimpleMessage(message), null);
+ }
+ }
+
/**
* Log a message at the <code>FATAL</code> level including the
* stack trace of the {@link Throwable}<code>t</code> passed as parameter.
@@ -794,6 +1152,20 @@
}
/**
+ * Log a message at the <code>FATAL</code> level including the
+ * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message object to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ public void fatal(Marker marker, String message, Throwable t) {
+ if (isEnabled(Level.FATAL, marker, message, t)) {
+ log(marker, getFQCN(), Level.FATAL, new SimpleMessage(message), t);
+ }
+ }
+
+ /**
* Log a message object with the {@link org.apache.logging.log4j.Level#FATAL FATAL} level.
*
* @param message the message object to log.
@@ -805,6 +1177,18 @@
}
/**
+ * Log a message object with the {@link org.apache.logging.log4j.Level#FATAL FATAL} level.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message object to log.
+ */
+ public void fatal(Marker marker, Object message) {
+ if (isEnabled(Level.FATAL, marker, message, null)) {
+ log(marker, getFQCN(), Level.FATAL, new ObjectMessage(message), null);
+ }
+ }
+
+ /**
* Log a message at the <code>FATAL</code> level including the
* stack trace of the {@link Throwable}<code>t</code> passed as parameter.
*
@@ -816,6 +1200,21 @@
log(null, getFQCN(), Level.FATAL, new ObjectMessage(message), t);
}
}
+
+ /**
+ * Log a message at the <code>FATAL</code> level including the
+ * stack trace of the {@link Throwable}<code>t</code> passed as parameter.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message object to log.
+ * @param t the exception to log, including its stack trace.
+ */
+ public void fatal(Marker marker, Object message, Throwable t) {
+ if (isEnabled(Level.FATAL, marker, message, t)) {
+ log(marker, getFQCN(), Level.FATAL, new ObjectMessage(message), t);
+ }
+ }
+
/**
* Log a message with parameters at the <code>FATAL</code> level.
*
@@ -829,6 +1228,19 @@
}
/**
+ * Log a message with parameters at the <code>FATAL</code> level.
+ *
+ * @param marker the marker data specific to this log statement.
+ * @param message the message to log.
+ * @param params parameters to the message.
+ */
+ public void fatal(Marker marker, String message, Object... params) {
+ if (isEnabled(Level.FATAL, marker, message, params)) {
+ log(marker, getFQCN(), Level.FATAL, new ParameterizedMessage(message, params), null);
+ }
+ }
+
+ /**
* Check whether this Logger is enabled for the FATAL Level.
*
* @return boolean - <code>true</code> if this Logger is enabled for level
diff --git a/log4j2-api/src/test/java/org/apache/logging/log4j/LoggerTest.java b/log4j2-api/src/test/java/org/apache/logging/log4j/LoggerTest.java
index 8e2215b..40333c4 100644
--- a/log4j2-api/src/test/java/org/apache/logging/log4j/LoggerTest.java
+++ b/log4j2-api/src/test/java/org/apache/logging/log4j/LoggerTest.java
@@ -81,7 +81,7 @@
msg.put("ToAccount", "123456");
msg.put("FromAccount", "123457");
msg.put("Amount", "200.00");
- logger.info(Marker.getMarker("EVENT"), msg);
+ logger.info(MarkerManager.getMarker("EVENT"), msg);
ThreadContext.clear();
}
}
diff --git a/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/RollingFileAppender.java b/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/RollingFileAppender.java
new file mode 100644
index 0000000..b18fa16
--- /dev/null
+++ b/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/RollingFileAppender.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.appender;
+
+import org.apache.logging.log4j.core.Layout;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAttr;
+import org.apache.logging.log4j.core.config.plugins.PluginElement;
+import org.apache.logging.log4j.core.config.plugins.PluginFactory;
+import org.apache.logging.log4j.core.filter.Filters;
+
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+
+/**
+ *
+ */
+@Plugin(name="RollingFile",type="Core",elementType="appender",printObject=true)
+public class RollingFileAppender extends OutputStreamAppender {
+
+ public static final String FILE_NAME = "fileName";
+ public static final String APPEND = "append";
+ public final String fileName;
+
+ public RollingFileAppender(String name, Layout layout, Filters filters, OutputStream os, String filename) {
+ super(name, layout, filters, os);
+ this.fileName = filename;
+ }
+
+ /**
+ * Actual writing occurs here.
+ * <p/>
+ * <p>Most subclasses of <code>OutputStreamAppender</code> will need to
+ * override this method.
+ * @param event The LogEvent.
+ */
+ @Override
+ protected void subAppend(LogEvent event) {
+
+ super.subAppend(event);
+ }
+
+
+ @PluginFactory
+ public static RollingFileAppender createAppender(@PluginAttr("fileName") String fileName,
+ @PluginAttr("append") String append,
+ @PluginAttr("name") String name,
+ @PluginElement("layout") Layout layout,
+ @PluginElement("filters") Filters filters) {
+
+ boolean isAppend = append == null ? true : Boolean.valueOf(append);
+
+ if (name == null) {
+ logger.error("No name provided for FileAppender");
+ return null;
+ }
+
+ if (fileName == null) {
+ logger.error("No filename provided for FileAppender with name " + name);
+ return null;
+ }
+
+ try {
+ OutputStream os = new FileOutputStream(fileName, isAppend);
+ return new RollingFileAppender(name, layout, filters, os, fileName);
+ } catch (FileNotFoundException ex) {
+ logger.error("Unable to open file " + fileName, ex);
+ return null;
+ }
+ }
+}
diff --git a/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/RolloverStrategy.java b/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/RolloverStrategy.java
new file mode 100644
index 0000000..86f81db
--- /dev/null
+++ b/log4j2-core/src/main/java/org/apache/logging/log4j/core/appender/RolloverStrategy.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core.appender;
+
+/**
+ *
+ */
+public interface RolloverStrategy
+{
+}
diff --git a/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/MarkerFilter.java b/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/MarkerFilter.java
index 023c79b..d78c6a2 100644
--- a/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/MarkerFilter.java
+++ b/log4j2-core/src/main/java/org/apache/logging/log4j/core/filter/MarkerFilter.java
@@ -18,6 +18,7 @@
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Marker;
+import org.apache.logging.log4j.MarkerManager;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.Logger;
import org.apache.logging.log4j.core.config.plugins.Plugin;
@@ -72,7 +73,7 @@
logger.error("A marker must be provided for MarkerFilter");
return null;
}
- Marker m = Marker.getMarker(marker);
+ Marker m = MarkerManager.getMarker(marker);
Result onMatch = match == null ? null : Result.valueOf(match);
Result onMismatch = mismatch == null ? null : Result.valueOf(mismatch);
diff --git a/log4j2-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java b/log4j2-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java
new file mode 100644
index 0000000..8f34699
--- /dev/null
+++ b/log4j2-core/src/test/java/org/apache/logging/log4j/core/LoggerTest.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.core;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.MarkerManager;
+import org.apache.logging.log4j.ThreadContext;
+import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
+import org.apache.logging.log4j.internal.StatusLogger;
+import org.apache.logging.log4j.message.StructuredDataMessage;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.util.Date;
+import java.util.Locale;
+
+/**
+ *
+ */
+public class LoggerTest {
+
+ private static final String CONFIG = "log4j-test2.xml";
+
+ @BeforeClass
+ public static void setupClass() {
+ System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
+ LoggerContext ctx = (LoggerContext) LogManager.getContext();
+ Configuration config = ctx.getConfiguration();
+ }
+
+ @AfterClass
+ public static void cleanupClass() {
+ System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
+ LoggerContext ctx = (LoggerContext) LogManager.getContext();
+ ctx.reconfigure();
+ StatusLogger.getLogger().reset();
+ }
+
+ org.apache.logging.log4j.Logger logger = LogManager.getLogger("LoggerTest");
+
+ @Test
+ public void basicFlow() {
+ logger.entry();
+ logger.exit();
+ }
+
+ @Test
+ public void simpleFlow() {
+ logger.entry(CONFIG);
+ logger.exit(0);
+ }
+
+ @Test
+ public void throwing() {
+ logger.throwing(new IllegalArgumentException("Test Exception"));
+ }
+
+ @Test
+ public void catching() {
+ try {
+ throw new NullPointerException();
+ } catch (Exception e) {
+ logger.catching(e);
+ }
+ }
+
+ @Test
+ public void debug() {
+ logger.debug("Debug message");
+ }
+
+ @Test
+ public void debugObject() {
+ logger.debug(new Date());
+ }
+
+ @Test
+ public void debugWithParms() {
+ logger.debug("Hello, {}", "World");
+ }
+
+ @Test
+ public void mdc() {
+
+ ThreadContext.put("TestYear", new Integer(2010));
+ logger.debug("Debug message");
+ ThreadContext.clear();
+ logger.debug("Debug message");
+ }
+
+ @Test
+ public void structuredData() {
+ ThreadContext.put("loginId", "JohnDoe");
+ ThreadContext.put("ipAddress", "192.168.0.120");
+ ThreadContext.put("locale", Locale.US.getDisplayName());
+ StructuredDataMessage msg = new StructuredDataMessage("Audit@18060", "Transfer Complete", "Transfer");
+ msg.put("ToAccount", "123456");
+ msg.put("FromAccount", "123457");
+ msg.put("Amount", "200.00");
+ logger.info(MarkerManager.getMarker("EVENT"), msg);
+ ThreadContext.clear();
+ }
+}
+
diff --git a/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/MarkerFilterTest.java b/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/MarkerFilterTest.java
index 153eb53..9075ed9 100644
--- a/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/MarkerFilterTest.java
+++ b/log4j2-core/src/test/java/org/apache/logging/log4j/core/filter/MarkerFilterTest.java
@@ -18,6 +18,7 @@
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Marker;
+import org.apache.logging.log4j.MarkerManager;
import org.apache.logging.log4j.core.Filter;
import org.apache.logging.log4j.core.Log4jLogEvent;
import org.apache.logging.log4j.core.LogEvent;
@@ -33,11 +34,11 @@
@Test
public void testMarkers() {
- Marker parent = Marker.getMarker("Parent");
- Marker child = Marker.getMarker("Child", parent);
- Marker grandChild = Marker.getMarker("GrandChild", child);
- Marker sibling = Marker.getMarker("Sibling", parent);
- Marker stranger = Marker.getMarker("Stranger");
+ Marker parent = MarkerManager.getMarker("Parent");
+ Marker child = MarkerManager.getMarker("Child", parent);
+ Marker grandChild = MarkerManager.getMarker("GrandChild", child);
+ Marker sibling = MarkerManager.getMarker("Sibling", parent);
+ Marker stranger = MarkerManager.getMarker("Stranger");
MarkerFilter filter = MarkerFilter.createFilter("Parent", null, null);
filter.start();
assertTrue(filter.isStarted());
diff --git a/log4j2-core/src/test/resources/log4j-test2.xml b/log4j2-core/src/test/resources/log4j-test2.xml
new file mode 100644
index 0000000..f7b5872
--- /dev/null
+++ b/log4j2-core/src/test/resources/log4j-test2.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration packages="" status="debug" name="XMLConfigTest">
+ <properties>
+ <property name="filename">target/test.log</property>
+ </properties>
+ <filters>
+ <Threshold level="trace"/>
+ </filters>
+
+ <appenders>
+ <Console name="STDOUT">
+ <PatternLayout pattern="%m MDC%X%n"/>
+ <filters>
+ <Marker marker="FLOW" onMatch="DENY" onMismatch="NEUTRAL"/>
+ <Marker marker="EXCEPTION" onMatch="DENY" onMismatch="ACCEPT"/>
+ </filters>
+ </Console>
+ <Console name="FLOW">
+ <PatternLayout pattern="%C{1}.%M %m %ex%n"/>
+ <filters>
+ <Marker marker="FLOW" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
+ <Marker marker="EXCEPTION" onMatch="ACCEPT" onMismatch="DENY"/>
+ </filters>
+ </Console>
+ <File name="File" fileName="${filename}">
+ <PatternLayout>
+ <pattern>%d %p %C{1.} [%t] %m%n</pattern>
+ </PatternLayout>
+ </File>
+ <List name="List">
+ <filters>
+ <Threshold level="error"/>
+ </filters>
+ </List>
+ </appenders>
+
+ <loggers>
+ <logger name="org.apache.logging.log4j.test1" level="debug" additivity="false">
+ <filters>
+ <ThreadContextMap>
+ <KeyValuePair key="test" value="123"/>
+ </ThreadContextMap>
+ </filters>
+ <appender-ref ref="STDOUT"/>
+ </logger>>
+
+ <logger name="org.apache.logging.log4j.test2" level="debug" additivity="false">
+ <appender-ref ref="File"/>
+ </logger>>
+
+ <root level="trace">
+ <appender-ref ref="STDOUT"/>
+ <appender-ref ref="FLOW"/>
+ </root>
+ </loggers>
+
+</configuration>
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 77db6d9..3295c64 100644
--- a/pom.xml
+++ b/pom.xml
@@ -75,6 +75,39 @@
<name>Apache Software Foundation</name>
<url>http://www.apache.org</url>
</organization>
+ <properties>
+ <slf4j.version>1.6.1</slf4j.version>
+ </properties>
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-ext</artifactId>
+ <version>${slf4j.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging</groupId>
+ <artifactId>log4j2-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging</groupId>
+ <artifactId>log4j2-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.3.1</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
<build>
<plugins>
<plugin>
@@ -159,5 +192,6 @@
<module>log4j2-api</module>
<module>log4j12-api</module>
<module>log4j2-core</module>
+ <module>slf4j-impl</module>
</modules>
</project>
diff --git a/slf4j-impl/pom.xml b/slf4j-impl/pom.xml
new file mode 100644
index 0000000..65fc59a
--- /dev/null
+++ b/slf4j-impl/pom.xml
@@ -0,0 +1,90 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.logging</groupId>
+ <artifactId>log4j2-rgoers</artifactId>
+ <version>1.99.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.apache.logging</groupId>
+ <artifactId>slf4j-impl</artifactId>
+ <packaging>jar</packaging>
+ <name>SLF4J Binding</name>
+ <description>Binding between SLF4J API and Log4J2 Core</description>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.7</version>
+ <configuration>
+ <tags>
+ <tag>
+ <name>issue</name>
+ <placement>a</placement>
+ <head>JIRA issue:</head>
+ </tag>
+ <tag>
+ <name>doubt</name>
+ <placement>a</placement>
+ <head>Troublesome:</head>
+ </tag>
+ <tag>
+ <name>compare</name>
+ <placement>a</placement>
+ <head>Compare with:</head>
+ </tag>
+ </tags>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-ext</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging</groupId>
+ <artifactId>log4j2-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.logging</groupId>
+ <artifactId>log4j2-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <distributionManagement>
+ <site>
+ <id>apache.website</id>
+ <url>scp://people.apache.org/home/carnold/public_html/log4j/companions/pattern-layout</url>
+ </site>
+ </distributionManagement>
+
+</project>
+
diff --git a/slf4j-impl/src/main/java/org/slf4j/helpers/Log4JLoggerFactory.java b/slf4j-impl/src/main/java/org/slf4j/helpers/Log4JLoggerFactory.java
new file mode 100644
index 0000000..6e5239d
--- /dev/null
+++ b/slf4j-impl/src/main/java/org/slf4j/helpers/Log4JLoggerFactory.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.slf4j.helpers;
+
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.LoggerFactory;
+import org.slf4j.ILoggerFactory;
+import org.slf4j.Logger;
+import org.slf4j.impl.Log4JLogger;
+
+/**
+ *
+ */
+public class Log4JLoggerFactory implements ILoggerFactory {
+
+ private static LoggerContext ctx = new Log4JContext();
+
+ public Logger getLogger(String s) {
+ return (Logger) ctx.getLogger(s);
+ }
+
+ public static LoggerContext getContext() {
+ return ctx;
+ }
+
+ private static class Log4JContext extends LoggerContext {
+
+ private static LoggerFactory loggerFactory = new Factory();
+
+ @Override
+ public org.apache.logging.log4j.core.Logger getLogger(String name) {
+ return getLogger(loggerFactory, name);
+ }
+
+ }
+
+ private static class Factory implements LoggerFactory {
+
+ public org.apache.logging.log4j.core.Logger newInstance(LoggerContext ctx, String name) {
+ return new Log4JLogger(ctx, name);
+ }
+ }
+}
diff --git a/slf4j-impl/src/main/java/org/slf4j/helpers/Log4JMDCAdapter.java b/slf4j-impl/src/main/java/org/slf4j/helpers/Log4JMDCAdapter.java
new file mode 100644
index 0000000..3ea0325
--- /dev/null
+++ b/slf4j-impl/src/main/java/org/slf4j/helpers/Log4JMDCAdapter.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.slf4j.helpers;
+
+import org.apache.logging.log4j.ThreadContext;
+import org.slf4j.spi.MDCAdapter;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ *
+ */
+public class Log4JMDCAdapter implements MDCAdapter {
+
+ public void put(String key, String val) {
+ ThreadContext.put(key, val);
+ }
+
+ public String get(String key) {
+ return ThreadContext.get(key).toString();
+ }
+
+ public void remove(String key) {
+ ThreadContext.remove(key);
+ }
+
+ public void clear() {
+ ThreadContext.clear();
+ }
+
+ public Map getCopyOfContextMap() {
+ Map<String, Object> ctx = ThreadContext.getContext();
+ Map<String, String> map = new HashMap<String, String>();
+
+ for (Map.Entry<String, Object>entry : ctx.entrySet()) {
+ map.put(entry.getKey(), entry.getValue().toString());
+ }
+ return map;
+ }
+
+ public void setContextMap(Map map) {
+ ThreadContext.clear();
+ for (Map.Entry<String, String> entry : ((Map<String, String>) map).entrySet()) {
+ ThreadContext.put(entry.getKey(), entry.getValue());
+ }
+ }
+}
diff --git a/slf4j-impl/src/main/java/org/slf4j/helpers/Log4JMarkerFactory.java b/slf4j-impl/src/main/java/org/slf4j/helpers/Log4JMarkerFactory.java
new file mode 100644
index 0000000..b71c3d5
--- /dev/null
+++ b/slf4j-impl/src/main/java/org/slf4j/helpers/Log4JMarkerFactory.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.slf4j.helpers;
+
+import org.slf4j.IMarkerFactory;
+import org.slf4j.Marker;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+/**
+ *
+ */
+public class Log4JMarkerFactory implements IMarkerFactory {
+
+ private ConcurrentMap<String, Marker> markerMap = new ConcurrentHashMap<String, Marker>();
+
+ public Marker getMarker(String name) {
+ if (name == null) {
+ throw new IllegalArgumentException("Marker name must not be null");
+ }
+ Marker marker = markerMap.get(name);
+ if (marker == null) {
+ marker = new MarkerWrapper(name);
+ }
+ return marker;
+ }
+
+ public boolean exists(String name) {
+ return markerMap.containsKey(name);
+ }
+
+ public boolean detachMarker(String name) {
+ return false;
+ }
+
+ public Marker getDetachedMarker(String name) {
+ return new MarkerWrapper(name);
+ }
+}
diff --git a/slf4j-impl/src/main/java/org/slf4j/helpers/MarkerWrapper.java b/slf4j-impl/src/main/java/org/slf4j/helpers/MarkerWrapper.java
new file mode 100644
index 0000000..9b078e1
--- /dev/null
+++ b/slf4j-impl/src/main/java/org/slf4j/helpers/MarkerWrapper.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.slf4j.helpers;
+
+import org.apache.logging.log4j.Marker;
+
+/**
+ *
+ */
+public class MarkerWrapper extends BasicMarker implements Marker {
+ private static final long serialVersionUID = 1903952589649545191L;
+
+ private MarkerWrapper parent;
+
+ MarkerWrapper(String name) {
+ super(name);
+ }
+
+ @Override
+ public void add(org.slf4j.Marker reference) {
+ super.add(reference);
+ ((MarkerWrapper)reference).setParent(this);
+ }
+
+ private void setParent(MarkerWrapper marker) {
+ parent = marker;
+ }
+
+ public org.apache.logging.log4j.Marker getParent() {
+ return this.parent;
+ }
+
+ public boolean isInstanceOf(org.apache.logging.log4j.Marker marker) {
+ if (marker == null) {
+ throw new IllegalArgumentException("A marker parameter is required");
+ }
+
+ return contains((MarkerWrapper) marker);
+ }
+}
diff --git a/slf4j-impl/src/main/java/org/slf4j/impl/Log4JLogger.java b/slf4j-impl/src/main/java/org/slf4j/impl/Log4JLogger.java
new file mode 100644
index 0000000..ffd00b7
--- /dev/null
+++ b/slf4j-impl/src/main/java/org/slf4j/impl/Log4JLogger.java
@@ -0,0 +1,252 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.slf4j.impl;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.core.Logger;
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.message.Message;
+import org.apache.logging.log4j.message.ParameterizedMessage;
+import org.apache.logging.log4j.message.StructuredDataMessage;
+import org.slf4j.Marker;
+import org.slf4j.MarkerFactory;
+import org.slf4j.ext.EventData;
+import org.slf4j.spi.LocationAwareLogger;
+
+import java.util.Map;
+
+/**
+ *
+ */
+public class Log4JLogger extends Logger implements LocationAwareLogger {
+
+ private static final String FQCN = Log4JLogger.class.getName();
+ private static Marker EVENT_MARKER = MarkerFactory.getMarker("EVENT");
+ private final boolean eventLogger;
+
+ public Log4JLogger(LoggerContext context, String name) {
+ super(context, name);
+ eventLogger = "EventLogger".equals(name);
+ }
+
+ public void log(Marker marker, String fqcn, int i, String s1, Object[] objects, Throwable throwable) {
+ Message msg;
+ if (eventLogger && marker != null && marker.contains(EVENT_MARKER)) {
+ try {
+ EventData data = (objects != null && objects[0] instanceof EventData) ? (EventData) objects[0] :
+ new EventData(s1);
+ msg = new StructuredDataMessage(data.getEventId(), data.getMessage(), data.getEventType());
+ for (Map.Entry entry : data.getEventMap().entrySet()) {
+ String key = entry.getKey().toString();
+ if (EventData.EVENT_TYPE.equals(key) || EventData.EVENT_ID.equals(key) ||
+ EventData.EVENT_MESSAGE.equals(key)) {
+ continue;
+ }
+ ((StructuredDataMessage) msg).put(entry.getKey().toString(), entry.getValue().toString());
+ }
+ } catch (Exception ex) {
+ msg = new ParameterizedMessage(s1, objects, throwable);
+ }
+
+ } else {
+ msg = new ParameterizedMessage(s1, objects, throwable);
+ }
+ super.log((org.apache.logging.log4j.Marker) marker, fqcn, getLevel(i), msg, throwable);
+ }
+
+ public void trace(String format, Object o) {
+ super.trace(format, o);
+ }
+
+ public void trace(String format, Object arg1, Object arg2) {
+ super.trace(format, arg1, arg2);
+ }
+
+ public boolean isTraceEnabled(Marker marker) {
+ return super.isTraceEnabled((org.apache.logging.log4j.Marker) marker);
+ }
+
+ public void trace(Marker marker, String s) {
+ super.trace((org.apache.logging.log4j.Marker) marker, s);
+ }
+
+ public void trace(Marker marker, String s, Object o) {
+ super.trace((org.apache.logging.log4j.Marker) marker, s, o);
+ }
+
+ public void trace(Marker marker, String s, Object o, Object o1) {
+ super.trace((org.apache.logging.log4j.Marker) marker, s, o, o1);
+ }
+
+ public void trace(Marker marker, String s, Object[] objects) {
+ super.trace((org.apache.logging.log4j.Marker) marker, s , objects);
+ }
+
+ public void trace(Marker marker, String s, Throwable throwable) {
+ super.trace((org.apache.logging.log4j.Marker) marker, s, throwable);
+ }
+
+ public void debug(String format, Object o) {
+ super.debug(format, o);
+ }
+
+ public void debug(String format, Object o, Object o1) {
+ super.debug(format, o, o1);
+ }
+
+ public boolean isDebugEnabled(Marker marker) {
+ return super.isDebugEnabled((org.apache.logging.log4j.Marker) marker);
+ }
+
+ public void debug(Marker marker, String s) {
+ super.debug((org.apache.logging.log4j.Marker) marker, s);
+ }
+
+ public void debug(Marker marker, String s, Object o) {
+ super.debug((org.apache.logging.log4j.Marker) marker, s, o);
+ }
+
+ public void debug(Marker marker, String s, Object o, Object o1) {
+ super.debug((org.apache.logging.log4j.Marker) marker, s, o, o1);
+ }
+
+ public void debug(Marker marker, String s, Object[] objects) {
+ super.debug((org.apache.logging.log4j.Marker) marker, s, objects);
+ }
+
+ public void debug(Marker marker, String s, Throwable throwable) {
+ super.debug((org.apache.logging.log4j.Marker) marker, s, throwable);
+ }
+
+ public void info(String s, Object o) {
+ super.info(s, o);
+ }
+
+ public void info(String s, Object o, Object o1) {
+ super.info(s, o, o1);
+ }
+
+ public boolean isInfoEnabled(Marker marker) {
+ return super.isInfoEnabled((org.apache.logging.log4j.Marker) marker);
+ }
+
+ public void info(Marker marker, String s) {
+ super.info((org.apache.logging.log4j.Marker) marker, s);
+ }
+
+ public void info(Marker marker, String s, Object o) {
+ super.info((org.apache.logging.log4j.Marker) marker, s, o);
+ }
+
+ public void info(Marker marker, String s, Object o, Object o1) {
+ super.info((org.apache.logging.log4j.Marker) marker, s, o, o1);
+ }
+
+ public void info(Marker marker, String s, Object[] objects) {
+ super.info((org.apache.logging.log4j.Marker) marker, s, objects);
+ }
+
+ public void info(Marker marker, String s, Throwable throwable) {
+ super.info((org.apache.logging.log4j.Marker) marker, s, throwable);
+ }
+
+ public void warn(String s, Object o) {
+ super.warn(s, o);
+ }
+
+ public void warn(String s, Object o, Object o1) {
+ super.warn(s, o, o1);
+ }
+
+ public boolean isWarnEnabled(Marker marker) {
+ return super.isWarnEnabled((org.apache.logging.log4j.Marker) marker);
+ }
+
+ public void warn(Marker marker, String s) {
+ super.warn((org.apache.logging.log4j.Marker) marker, s);
+ }
+
+ public void warn(Marker marker, String s, Object o) {
+ super.warn((org.apache.logging.log4j.Marker) marker, s, o);
+ }
+
+ public void warn(Marker marker, String s, Object o, Object o1) {
+ super.warn((org.apache.logging.log4j.Marker) marker, s, o, o1);
+ }
+
+ public void warn(Marker marker, String s, Object[] objects) {
+ super.warn((org.apache.logging.log4j.Marker) marker, s, objects);
+ }
+
+ public void warn(Marker marker, String s, Throwable throwable) {
+ super.warn((org.apache.logging.log4j.Marker) marker, s, throwable);
+ }
+
+ public void error(String s, Object o) {
+ super.error(s, o);
+ }
+
+ public void error(String s, Object o, Object o1) {
+ super.error(s, o, o1);
+ }
+
+ public boolean isErrorEnabled(Marker marker) {
+ return super.isErrorEnabled((org.apache.logging.log4j.Marker) marker);
+ }
+
+ public void error(Marker marker, String s) {
+ super.error((org.apache.logging.log4j.Marker) marker, s);
+ }
+
+ public void error(Marker marker, String s, Object o) {
+ super.error((org.apache.logging.log4j.Marker) marker, s, o);
+ }
+
+ public void error(Marker marker, String s, Object o, Object o1) {
+ super.error((org.apache.logging.log4j.Marker) marker, s, o, o1);
+ }
+
+ public void error(Marker marker, String s, Object[] objects) {
+ super.error((org.apache.logging.log4j.Marker) marker, s, objects);
+ }
+
+ public void error(Marker marker, String s, Throwable throwable) {
+ super.error((org.apache.logging.log4j.Marker) marker, s, throwable);
+ }
+
+ @Override
+ protected String getFQCN() {
+ return FQCN;
+ }
+
+ private Level getLevel(int i) {
+
+ switch (i) {
+ case TRACE_INT :
+ return Level.TRACE;
+ case DEBUG_INT :
+ return Level.DEBUG;
+ case INFO_INT :
+ return Level.INFO;
+ case WARN_INT :
+ return Level.WARN;
+ case ERROR_INT :
+ return Level.ERROR;
+ }
+ return Level.ERROR;
+ }
+}
diff --git a/slf4j-impl/src/main/java/org/slf4j/impl/StaticLoggerBinder.java b/slf4j-impl/src/main/java/org/slf4j/impl/StaticLoggerBinder.java
new file mode 100644
index 0000000..d2d53d6
--- /dev/null
+++ b/slf4j-impl/src/main/java/org/slf4j/impl/StaticLoggerBinder.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.slf4j.impl;
+
+import org.slf4j.ILoggerFactory;
+import org.slf4j.helpers.Log4JLoggerFactory;
+import org.slf4j.spi.LoggerFactoryBinder;
+
+/**
+ *
+ */
+public class StaticLoggerBinder implements LoggerFactoryBinder {
+
+ /**
+ * The unique instance of this class.
+ */
+ private static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();
+
+ /**
+ * Return the singleton of this class.
+ *
+ * @return the StaticLoggerBinder singleton
+ */
+ public static final StaticLoggerBinder getSingleton() {
+ return SINGLETON;
+ }
+
+ /**
+ * Declare the version of the SLF4J API this implementation is compiled
+ * against. The value of this field is usually modified with each release.
+ */
+ // to avoid constant folding by the compiler, this field must *not* be final
+ public static String REQUESTED_API_VERSION = "1.6"; // !final
+
+ private static final String loggerFactoryClassStr = Log4JLoggerFactory.class.getName();
+ /**
+ * The ILoggerFactory instance returned by the {@link #getLoggerFactory}
+ * method should always be the same object
+ */
+ private final ILoggerFactory loggerFactory;
+
+ private StaticLoggerBinder() {
+ loggerFactory = new Log4JLoggerFactory();
+ }
+
+ public ILoggerFactory getLoggerFactory() {
+ return loggerFactory;
+ }
+
+ public String getLoggerFactoryClassStr() {
+ return loggerFactoryClassStr;
+ }
+}
diff --git a/slf4j-impl/src/main/java/org/slf4j/impl/StaticMDCBinder.java b/slf4j-impl/src/main/java/org/slf4j/impl/StaticMDCBinder.java
new file mode 100644
index 0000000..991a8da
--- /dev/null
+++ b/slf4j-impl/src/main/java/org/slf4j/impl/StaticMDCBinder.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.slf4j.impl;
+
+import org.slf4j.helpers.Log4JMDCAdapter;
+import org.slf4j.spi.MDCAdapter;
+
+/**
+ *
+ */
+public class StaticMDCBinder {
+
+ /**
+ * The unique instance of this class.
+ */
+ public static final StaticMDCBinder SINGLETON = new StaticMDCBinder();
+
+ private StaticMDCBinder() {
+ }
+
+ /**
+ * Currently this method always returns an instance of {@link StaticMDCBinder}.
+ */
+ public MDCAdapter getMDCA() {
+ return new Log4JMDCAdapter();
+ }
+
+ public String getMDCAdapterClassStr() {
+ return Log4JMDCAdapter.class.getName();
+ }
+}
diff --git a/slf4j-impl/src/main/java/org/slf4j/impl/StaticMarkerBinder.java b/slf4j-impl/src/main/java/org/slf4j/impl/StaticMarkerBinder.java
new file mode 100644
index 0000000..10290e8
--- /dev/null
+++ b/slf4j-impl/src/main/java/org/slf4j/impl/StaticMarkerBinder.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.slf4j.impl;
+
+import org.slf4j.IMarkerFactory;
+import org.slf4j.helpers.Log4JMarkerFactory;
+import org.slf4j.spi.MarkerFactoryBinder;
+
+/**
+ *
+ */
+public class StaticMarkerBinder implements MarkerFactoryBinder
+{
+
+ /**
+ * The unique instance of this class.
+ */
+ public static final StaticMarkerBinder SINGLETON = new StaticMarkerBinder();
+
+ final IMarkerFactory markerFactory = new Log4JMarkerFactory();
+
+ public IMarkerFactory getMarkerFactory()
+ {
+ return markerFactory;
+ }
+
+ public String getMarkerFactoryClassStr()
+ {
+ return Log4JMarkerFactory.class.getName();
+ }
+}
diff --git a/slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java b/slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java
new file mode 100644
index 0000000..15e294c
--- /dev/null
+++ b/slf4j-impl/src/test/java/org/apache/logging/slf4j/LoggerTest.java
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.slf4j;
+
+import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.config.XMLConfigurationFactory;
+import org.apache.logging.log4j.internal.StatusLogger;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.MDC;
+import org.slf4j.ext.EventData;
+import org.slf4j.ext.EventLogger;
+import org.slf4j.ext.XLogger;
+import org.slf4j.ext.XLoggerFactory;
+import org.slf4j.helpers.Log4JLoggerFactory;
+
+import java.util.Locale;
+
+
+/**
+ *
+ */
+public class LoggerTest {
+
+ private static final String CONFIG = "log4j-test1.xml";
+
+ @BeforeClass
+ public static void setupClass() {
+ System.setProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY, CONFIG);
+ LoggerContext ctx = Log4JLoggerFactory.getContext();
+ Configuration config = ctx.getConfiguration();
+ }
+
+ @AfterClass
+ public static void cleanupClass() {
+ System.clearProperty(XMLConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
+ LoggerContext ctx = Log4JLoggerFactory.getContext();
+ ctx.reconfigure();
+ StatusLogger.getLogger().reset();
+ }
+
+ Logger logger = LoggerFactory.getLogger("LoggerTest");
+ XLogger xlogger = XLoggerFactory.getXLogger("LoggerTest");
+
+ @Test
+ public void basicFlow() {
+ xlogger.entry();
+ xlogger.exit();
+ }
+
+ @Test
+ public void simpleFlow() {
+ xlogger.entry(CONFIG);
+ xlogger.exit(0);
+ }
+
+ @Test
+ public void throwing() {
+ xlogger.throwing(new IllegalArgumentException("Test Exception"));
+ }
+
+ @Test
+ public void catching() {
+ try {
+ throw new NullPointerException();
+ } catch (Exception e) {
+ xlogger.catching(e);
+ }
+ }
+
+ @Test
+ public void debug() {
+ logger.debug("Debug message");
+ }
+
+
+ @Test
+ public void debugWithParms() {
+ logger.debug("Hello, {}", "World");
+ }
+
+ @Test
+ public void mdc() {
+
+ MDC.put("TestYear", "2010");
+ logger.debug("Debug message");
+ MDC.clear();
+ logger.debug("Debug message");
+ }
+
+ @Test
+ public void testEventLogger() {
+ MDC.put("loginId", "JohnDoe");
+ MDC.put("ipAddress", "192.168.0.120");
+ MDC.put("locale", Locale.US.getDisplayName());
+ EventData data = new EventData();
+ data.setEventType("Transfer");
+ data.setEventId("Audit@18060");
+ data.setMessage("Transfer Complete");
+ data.put("ToAccount", "123456");
+ data.put("FromAccount", "123457");
+ data.put("Amount", "200.00");
+ EventLogger.logEvent(data);
+ MDC.clear();
+ }
+}
diff --git a/slf4j-impl/src/test/resources/log4j-test1.xml b/slf4j-impl/src/test/resources/log4j-test1.xml
new file mode 100644
index 0000000..42bfe43
--- /dev/null
+++ b/slf4j-impl/src/test/resources/log4j-test1.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration packages="" status="debug" name="LoggerTest">
+ <properties>
+ <property name="filename">target/test.log</property>
+ </properties>
+ <filters>
+ <Threshold level="trace"/>
+ </filters>
+
+ <appenders>
+ <Console name="EventLogger">
+ <PatternLayout pattern="%m%n"/>
+ </Console>
+ <Console name="STDOUT">
+ <PatternLayout pattern="%m MDC%X%n"/>
+ </Console>
+ <File name="File" fileName="${filename}">
+ <PatternLayout>
+ <pattern>%d %p %C{1.} [%t] %m%n</pattern>
+ </PatternLayout>
+ </File>
+ <List name="List">
+ <filters>
+ <Threshold level="error"/>
+ </filters>
+ </List>
+ </appenders>
+
+ <loggers>
+ <logger name="EventLogger" level="info" additivity="false">
+ <appender-ref ref="EventLogger"/>
+ </logger>>
+
+ <logger name="org.apache.logging.log4j.test2" level="debug" additivity="false">
+ <appender-ref ref="File"/>
+ </logger>>
+
+ <root level="trace">
+ <appender-ref ref="STDOUT"/>
+ </root>
+ </loggers>
+
+</configuration>
\ No newline at end of file