From 185aa361aec65c967d2908f69db4abbe9d3d9b2e Mon Sep 17 00:00:00 2001 From: Florian Reimair Date: Thu, 20 Mar 2014 18:32:14 +0100 Subject: introduced log4j logging system --- .../java/at/gv/egovernment/moa/logging/Logger.java | 67 +++++++++------------- 1 file changed, 27 insertions(+), 40 deletions(-) (limited to 'common/src/main/java/at/gv/egovernment/moa/logging/Logger.java') diff --git a/common/src/main/java/at/gv/egovernment/moa/logging/Logger.java b/common/src/main/java/at/gv/egovernment/moa/logging/Logger.java index 07f9e27af..2e76325a5 100644 --- a/common/src/main/java/at/gv/egovernment/moa/logging/Logger.java +++ b/common/src/main/java/at/gv/egovernment/moa/logging/Logger.java @@ -24,9 +24,6 @@ package at.gv.egovernment.moa.logging; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - /** * A utility class acting as a facade to the logging subsystem. * @@ -39,35 +36,13 @@ import org.apache.commons.logging.LogFactory; */ public class Logger { - /** The default logging hierarchy. */ - private static String defaultHierarchy = ""; - - /** - * Get the Log object for the default hierarchy. - * - * @return The Log object to write log messages to. - */ - private static Log getLog() { - return LogFactory.getLog(defaultHierarchy); - } - - /** - * Get the Log object for a given hierarchy. - * - * @param hierarchy The logging hierarchy for which to return the logger. - * @return The Log object to write log messages to. - */ - private static Log getLog(String hierarchy) { - return LogFactory.getLog(hierarchy); - } - /** * Set the default hierarchy to which the Logger should send its * logging output. * @param hierarchy The logging defaultHierarchy. */ public static void setHierarchy(String hierarchy) { - defaultHierarchy = hierarchy; + // there is no need for that anymore } /** @@ -77,7 +52,8 @@ public class Logger { * false otherwise. */ public static boolean isTraceEnabled() { - return getLog().isTraceEnabled(); + org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Thread.currentThread().getStackTrace()[2].getClassName()); + return logger.isTraceEnabled(); } /** @@ -88,7 +64,8 @@ public class Logger { * false otherwise. */ public static boolean isTraceEnabled(String hierarchy) { - return getLog(hierarchy).isTraceEnabled(); + org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Thread.currentThread().getStackTrace()[2].getClassName()); + return logger.isTraceEnabled(); } /** @@ -97,7 +74,8 @@ public class Logger { * @param message The message to trace. */ public static void trace(Object message) { - getLog().trace(message); + org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Thread.currentThread().getStackTrace()[2].getClassName()); + logger.trace(message); } /** @@ -107,7 +85,8 @@ public class Logger { * false otherwise. */ public static boolean isDebugEnabled() { - return getLog().isDebugEnabled(); + org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Thread.currentThread().getStackTrace()[2].getClassName()); + return logger.isDebugEnabled(); } /** @@ -118,7 +97,8 @@ public class Logger { * false otherwise. */ public static boolean isDebugEnabled(String hierarchy) { - return getLog(hierarchy).isDebugEnabled(); + org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Thread.currentThread().getStackTrace()[2].getClassName()); + return logger.isDebugEnabled(); } /** @@ -127,7 +107,8 @@ public class Logger { * @param message The message to log. */ public static void debug(Object message) { - getLog().debug(message); + org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Thread.currentThread().getStackTrace()[2].getClassName()); + logger.debug(message); } /** @@ -136,7 +117,8 @@ public class Logger { * @param message The message to log. */ public static void info(Object message) { - getLog().info(message); + org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Thread.currentThread().getStackTrace()[2].getClassName()); + logger.info(message); } /** @@ -145,7 +127,8 @@ public class Logger { * @param message The message to log. */ public static void warn(Object message) { - getLog().warn(message); + org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Thread.currentThread().getStackTrace()[2].getClassName()); + logger.warn(message); } /** @@ -155,7 +138,8 @@ public class Logger { * @param t An exception that may be the cause of the warning. */ public static void warn(Object message, Throwable t) { - getLog().warn(message, t); + org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Thread.currentThread().getStackTrace()[2].getClassName()); + logger.warn(message, t); } /** @@ -164,7 +148,8 @@ public class Logger { * @param message The message to log. */ public static void error(Object message) { - getLog().error(message); + org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Thread.currentThread().getStackTrace()[2].getClassName()); + logger.error(message); } /** @@ -174,7 +159,8 @@ public class Logger { * @param t An exception that may be the cause of the error. */ public static void error(Object message, Throwable t) { - getLog().error(message, t); + org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Thread.currentThread().getStackTrace()[2].getClassName()); + logger.error(message, t); } /** @@ -183,7 +169,8 @@ public class Logger { * @param message The message to log. */ public static void fatal(Object message) { - getLog().fatal(message); + org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Thread.currentThread().getStackTrace()[2].getClassName()); + logger.fatal(message); } /** @@ -193,7 +180,7 @@ public class Logger { * @param t An exception that may be the cause of the error. */ public static void fatal(Object message, Throwable t) { - getLog().fatal(message, t); + org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Thread.currentThread().getStackTrace()[2].getClassName()); + logger.fatal(message, t); } - } -- cgit v1.2.3