logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r1517427 - /logging/log4j/log4j2/trunk/core/src/main/java/org/apache/logging/log4j/core/lookup/Interpolator.java
Date Mon, 26 Aug 2013 05:31:29 GMT
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);
+        }
     }
 
      /**



Mime
View raw message