You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rg...@apache.org on 2013/08/26 07:31:29 UTC
svn commit: r1517427 -
/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java
Author: rgoers
Date: Mon Aug 26 05:31:29 2013
New Revision: 1517427
URL: http://svn.apache.org/r1517427
Log:
Only add WebLookup to default if ServletContext class is present
Modified:
logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java
Modified: logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java?rev=1517427&r1=1517426&r2=1517427&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java (original)
+++ logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java Mon Aug 26 05:31:29 2013
@@ -64,7 +64,15 @@ public class Interpolator implements Str
lookups.put("sys", new SystemPropertiesLookup());
lookups.put("env", new EnvironmentLookup());
lookups.put("jndi", new JndiLookup());
- lookups.put("web", new WebLookup());
+ try {
+ if (Class.forName("javax.servlet.ServletContext") != null) {
+ lookups.put("web", new WebLookup());
+ }
+ } catch (ClassNotFoundException ex) {
+ LOGGER.debug("ServletContext not present - WebLookup not added");
+ } catch (Exception ex) {
+ LOGGER.error("Unable to locate ServletContext", ex);
+ }
}
/**