You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2014/04/15 07:20:15 UTC
svn commit: r1587421 -
/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/web/Log4jWebInitializerImpl.java
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;
}