aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorAlexander Marsalek <amarsalek@iaik.tugraz.at>2015-03-17 08:31:52 +0100
committerAlexander Marsalek <amarsalek@iaik.tugraz.at>2015-03-17 08:31:52 +0100
commit0fed62d7df1d29190b7a88233ab77abcbb3349d6 (patch)
treea46d8a1d8c0c4a270398ed1c1c9a1e23c26624dc /common
parent6b6c98ae7af48c15e86b189e0db9e39bc1d14edb (diff)
parentc0613b08431899c6d97affc570a237b81dfcda80 (diff)
downloadmoa-id-spss-0fed62d7df1d29190b7a88233ab77abcbb3349d6.tar.gz
moa-id-spss-0fed62d7df1d29190b7a88233ab77abcbb3349d6.tar.bz2
moa-id-spss-0fed62d7df1d29190b7a88233ab77abcbb3349d6.zip
Merge branch 'merge' into 2.2.x-STORK-Snapshot
Diffstat (limited to 'common')
-rw-r--r--common/pom.xml27
-rw-r--r--common/src/main/java/at/gv/egovernment/moa/logging/Logger.java68
2 files changed, 52 insertions, 43 deletions
diff --git a/common/pom.xml b/common/pom.xml
index e702c5e66..72cf702bc 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -74,11 +74,6 @@
<artifactId>slf4j-api</artifactId>
<version>1.7.10</version>
</dependency>
-<!-- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <version>1.7.6</version>
- </dependency> -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
@@ -86,28 +81,18 @@
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
+ <artifactId>jul-to-slf4j</artifactId>
<version>1.7.10</version>
</dependency>
-<!-- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>log4j-over-slf4j</artifactId>
- <version>1.7.6</version>
- </dependency> -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.7.10</version>
+ </dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <version>1.7.10</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jul-to-slf4j</artifactId>
- <version>1.7.10</version>
- </dependency>
</dependencies>
<build>
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 2e76325a5..6999656ab 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,6 +24,9 @@
package at.gv.egovernment.moa.logging;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* A utility class acting as a facade to the logging subsystem.
*
@@ -45,6 +48,29 @@ public class Logger {
// there is no need for that anymore
}
+
+ /** The Constant instances. */
+ private static final Map<String, org.slf4j.Logger> instances = new HashMap<String, org.slf4j.Logger>();
+
+ /**
+ * Gets the logger.
+ *
+ * @return the logger
+ */
+ private static synchronized org.slf4j.Logger getLogger() {
+ String className = Thread.currentThread().getStackTrace()[3].getClassName();
+
+ org.slf4j.Logger logger = instances.get(className);
+ if (logger != null) {
+ return logger;
+ }
+
+ logger = org.slf4j.LoggerFactory.getLogger(className);
+ instances.put(className, logger);
+
+ return logger;
+ }
+
/**
* Test, if the trace log level is enabled.
*
@@ -52,7 +78,7 @@ public class Logger {
* <code>false</code> otherwise.
*/
public static boolean isTraceEnabled() {
- org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Thread.currentThread().getStackTrace()[2].getClassName());
+ org.slf4j.Logger logger = getLogger();
return logger.isTraceEnabled();
}
@@ -64,7 +90,7 @@ public class Logger {
* <code>false</code> otherwise.
*/
public static boolean isTraceEnabled(String hierarchy) {
- org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Thread.currentThread().getStackTrace()[2].getClassName());
+ org.slf4j.Logger logger = getLogger();
return logger.isTraceEnabled();
}
@@ -74,8 +100,8 @@ public class Logger {
* @param message The message to trace.
*/
public static void trace(Object message) {
- org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Thread.currentThread().getStackTrace()[2].getClassName());
- logger.trace(message);
+ org.slf4j.Logger logger = getLogger();
+ logger.trace(message.toString());
}
/**
@@ -85,7 +111,7 @@ public class Logger {
* <code>false</code> otherwise.
*/
public static boolean isDebugEnabled() {
- org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Thread.currentThread().getStackTrace()[2].getClassName());
+ org.slf4j.Logger logger = getLogger();
return logger.isDebugEnabled();
}
@@ -97,7 +123,7 @@ public class Logger {
* <code>false</code> otherwise.
*/
public static boolean isDebugEnabled(String hierarchy) {
- org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Thread.currentThread().getStackTrace()[2].getClassName());
+ org.slf4j.Logger logger = getLogger();
return logger.isDebugEnabled();
}
@@ -107,8 +133,8 @@ public class Logger {
* @param message The message to log.
*/
public static void debug(Object message) {
- org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Thread.currentThread().getStackTrace()[2].getClassName());
- logger.debug(message);
+ org.slf4j.Logger logger = getLogger();
+ logger.debug(message.toString());
}
/**
@@ -117,8 +143,8 @@ public class Logger {
* @param message The message to log.
*/
public static void info(Object message) {
- org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Thread.currentThread().getStackTrace()[2].getClassName());
- logger.info(message);
+ org.slf4j.Logger logger = getLogger();
+ logger.info(message.toString());
}
/**
@@ -127,8 +153,8 @@ public class Logger {
* @param message The message to log.
*/
public static void warn(Object message) {
- org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Thread.currentThread().getStackTrace()[2].getClassName());
- logger.warn(message);
+ org.slf4j.Logger logger = getLogger();
+ logger.warn(message.toString());
}
/**
@@ -138,8 +164,8 @@ public class Logger {
* @param t An exception that may be the cause of the warning.
*/
public static void warn(Object message, Throwable t) {
- org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Thread.currentThread().getStackTrace()[2].getClassName());
- logger.warn(message, t);
+ org.slf4j.Logger logger = getLogger();
+ logger.warn(message.toString(), t);
}
/**
@@ -148,8 +174,8 @@ public class Logger {
* @param message The message to log.
*/
public static void error(Object message) {
- org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Thread.currentThread().getStackTrace()[2].getClassName());
- logger.error(message);
+ org.slf4j.Logger logger = getLogger();
+ logger.error(message.toString());
}
/**
@@ -159,8 +185,8 @@ public class Logger {
* @param t An exception that may be the cause of the error.
*/
public static void error(Object message, Throwable t) {
- org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Thread.currentThread().getStackTrace()[2].getClassName());
- logger.error(message, t);
+ org.slf4j.Logger logger = getLogger();
+ logger.error(message.toString(), t);
}
/**
@@ -169,8 +195,7 @@ public class Logger {
* @param message The message to log.
*/
public static void fatal(Object message) {
- org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Thread.currentThread().getStackTrace()[2].getClassName());
- logger.fatal(message);
+ error(message);
}
/**
@@ -180,7 +205,6 @@ public class Logger {
* @param t An exception that may be the cause of the error.
*/
public static void fatal(Object message, Throwable t) {
- org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(Thread.currentThread().getStackTrace()[2].getClassName());
- logger.fatal(message, t);
+ error(message, t);
}
}