logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattsic...@apache.org
Subject svn commit: r1587421 - /logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/web/Log4jWebInitializerImpl.java
Date Tue, 15 Apr 2014 05:20:15 GMT
Author: mattsicker
Date: Tue Apr 15 05:20:14 2014
New Revision: 1587421

URL: http://svn.apache.org/r1587421
Log:
Use Loader.isClassAvailable.

Modified:
    logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/web/Log4jWebInitializerImpl.java

Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/web/Log4jWebInitializerImpl.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/web/Log4jWebInitializerImpl.java?rev=1587421&r1=1587420&r2=1587421&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/web/Log4jWebInitializerImpl.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/web/Log4jWebInitializerImpl.java
Tue Apr 15 05:20:14 2014
@@ -26,6 +26,7 @@ import org.apache.logging.log4j.LogManag
 import org.apache.logging.log4j.core.LoggerContext;
 import org.apache.logging.log4j.core.config.Configurator;
 import org.apache.logging.log4j.core.helpers.FileUtils;
+import org.apache.logging.log4j.core.helpers.Loader;
 import org.apache.logging.log4j.core.helpers.NetUtils;
 import org.apache.logging.log4j.core.impl.ContextAnchor;
 import org.apache.logging.log4j.core.impl.Log4jContextFactory;
@@ -42,13 +43,10 @@ final class Log4jWebInitializerImpl impl
     private static final Object MUTEX = new Object();
 
     static {
-        try {
-            Class.forName("org.apache.logging.log4j.core.web.JNDIContextFilter");
+        if (Loader.isClassAvailable("org.apache.logging.log4j.core.web.JNDIContextFilter"))
{
             throw new IllegalStateException("You are using Log4j 2 in a web application with
the old, extinct " +
                     "log4j-web artifact. This is not supported and could cause serious runtime
problems. Please" +
                     "remove the log4j-web JAR file from your application.");
-        } catch (final ClassNotFoundException ignore) {
-            /* Good. They don't have the old log4j-web artifact loaded. */
         }
     }
 
@@ -121,6 +119,7 @@ final class Log4jWebInitializerImpl impl
                 }
                 ContextAnchor.THREAD_CONTEXT.remove();
             } else {
+                // won't it be amusing if the servlet container uses Log4j as its ServletContext
logger?
                 this.servletContext.log("Potential problem: Selector is not an instance of
NamedContextSelector.");
                 return;
             }



Mime
View raw message