Author: rpopma
Date: Wed May  1 15:21:20 2013
New Revision: 1478048

URL: http://svn.apache.org/r1478048
Log:
LOG4J2-230, LOG4J2-204 (added check in constructor to improve error reporting 
when misconfigured)

Modified:
    
logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContext.java

Modified: 
logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContext.java
URL: 
http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContext.java?rev=1478048&r1=1478047&r2=1478048&view=diff
==============================================================================
--- 
logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContext.java
 (original)
+++ 
logging/log4j/log4j2/trunk/log4j-to-slf4j/src/main/java/org/apache/logging/slf4j/SLF4JLoggerContext.java
 Wed May  1 15:21:20 2013
@@ -30,6 +30,17 @@ import java.util.concurrent.ConcurrentMa
 public class SLF4JLoggerContext implements LoggerContext {
     private final ConcurrentMap<String, SLF4JLogger> loggers = new 
ConcurrentHashMap<String, SLF4JLogger>();
 
+    public SLF4JLoggerContext() {
+        // LOG4J2-230, LOG4J2-204 (improve error reporting when misconfigured)
+        try {
+            Class.forName("org.slf4j.helpers.Log4JLoggerFactory");
+            throw new IllegalStateException("slf4j-impl jar is mutually 
exclusive with log4j-to-slf4j jar "
+                + "(the first routes calls from SLF4J to Log4j, the second 
from Log4j to SLF4J)");
+        } catch (Throwable classNotFoundIsGood) {
+            // org.slf4j.helpers.Log4JLoggerFactory is not on classpath. Good!
+        }
+    }
+
     public Object getExternalContext() {
         return null;
     }


Reply via email to