From 9f5b494a063e310c1ed77c3a0b9c999a51aa24b3 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Mon, 17 Feb 2014 10:21:50 +0100 Subject: [PATCH] update to log4j2 2.0-rc1 --- .../main/java/org/apache/log4j/Category.java | 38 +++++++--------- .../apache/log4j/PropertyConfigurator.java | 2 +- .../sockethub/Log4j2SocketHubAppender.java | 43 ++++++++++--------- 3 files changed, 39 insertions(+), 44 deletions(-) diff --git a/log4j-1.2-api-with-sockethubappender/src/main/java/org/apache/log4j/Category.java b/log4j-1.2-api-with-sockethubappender/src/main/java/org/apache/log4j/Category.java index e379029..8b45977 100644 --- a/log4j-1.2-api-with-sockethubappender/src/main/java/org/apache/log4j/Category.java +++ b/log4j-1.2-api-with-sockethubappender/src/main/java/org/apache/log4j/Category.java @@ -153,28 +153,22 @@ public static Enumeration getCurrentCategories() { } public final Level getEffectiveLevel() { - final org.apache.logging.log4j.Level level = logger.getLevel(); - - if (level==org.apache.logging.log4j.Level.TRACE) { - return Level.TRACE; - } - if (level==org.apache.logging.log4j.Level.DEBUG) { - return Level.DEBUG; - } - if (level==org.apache.logging.log4j.Level.INFO) { - return Level.INFO; - } - if (level==org.apache.logging.log4j.Level.WARN) { - return Level.WARN; - } - if (level==org.apache.logging.log4j.Level.ERROR) { - return Level.ERROR; - } - if (level==org.apache.logging.log4j.Level.FATAL) { - return Level.FATAL; - } - // fallback - return Level.ERROR; + switch (logger.getLevel().getStandardLevel()) { + case TRACE: + return Level.TRACE; + case DEBUG: + return Level.DEBUG; + case INFO: + return Level.INFO; + case WARN: + return Level.WARN; + case ERROR: + return Level.ERROR; + case FATAL: + return Level.FATAL; + default: + return Level.OFF; + } } public final Priority getChainedPriority() { diff --git a/log4j-1.2-api-with-sockethubappender/src/main/java/org/apache/log4j/PropertyConfigurator.java b/log4j-1.2-api-with-sockethubappender/src/main/java/org/apache/log4j/PropertyConfigurator.java index 34eaf29..77e813e 100644 --- a/log4j-1.2-api-with-sockethubappender/src/main/java/org/apache/log4j/PropertyConfigurator.java +++ b/log4j-1.2-api-with-sockethubappender/src/main/java/org/apache/log4j/PropertyConfigurator.java @@ -56,7 +56,7 @@ public void doConfigure(final InputStream inputStream, final LoggerRepository hi * @param configURL The configuration URL * @param hierarchy The hierarchy */ - public void doConfigure(final java.net.URL configURL, final LoggerRepository hierarchy) {} + public void doConfigure(final URL configURL, final LoggerRepository hierarchy) {} /** * Read configuration options from configuration file. diff --git a/log4j-1.2-api-with-sockethubappender/src/main/java/org/apache/logging/log4j/sockethub/Log4j2SocketHubAppender.java b/log4j-1.2-api-with-sockethubappender/src/main/java/org/apache/logging/log4j/sockethub/Log4j2SocketHubAppender.java index 5165fbd..ce1822e 100644 --- a/log4j-1.2-api-with-sockethubappender/src/main/java/org/apache/logging/log4j/sockethub/Log4j2SocketHubAppender.java +++ b/log4j-1.2-api-with-sockethubappender/src/main/java/org/apache/logging/log4j/sockethub/Log4j2SocketHubAppender.java @@ -536,27 +536,28 @@ public void run() { @Override public void append(LogEvent pEvent) { org.apache.log4j.Level level = null; - if (pEvent.getLevel()==Level.TRACE) { - level = org.apache.log4j.Level.TRACE; - } - else if (pEvent.getLevel()==Level.DEBUG) { - level = org.apache.log4j.Level.DEBUG; - } - else if (pEvent.getLevel()==Level.INFO) { - level = org.apache.log4j.Level.INFO; - } - else if (pEvent.getLevel()==Level.WARN) { - level = org.apache.log4j.Level.WARN; - } - else if (pEvent.getLevel()==Level.ERROR) { - level = org.apache.log4j.Level.ERROR; - } - else if (pEvent.getLevel()==Level.FATAL) { - level = org.apache.log4j.Level.FATAL; - } - else { - // fallback - level = org.apache.log4j.Level.ERROR; + switch (pEvent.getLevel().getStandardLevel()) { + case TRACE: + level = org.apache.log4j.Level.TRACE; + break; + case DEBUG: + level = org.apache.log4j.Level.DEBUG; + break; + case INFO: + level = org.apache.log4j.Level.INFO; + break; + case WARN: + level = org.apache.log4j.Level.WARN; + break; + case ERROR: + level = org.apache.log4j.Level.ERROR; + break; + case FATAL: + level = org.apache.log4j.Level.FATAL; + break; + default: + level = org.apache.log4j.Level.OFF; + break; } ThrowableInformation throwableInformation = null; if (pEvent.getThrown() != null) {