LOG4J2-1291 enable overriding Constants.IS_WEB_APP with system property

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/ccedadfd
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/ccedadfd
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/ccedadfd

Branch: refs/heads/LOG4J2-1278-gc-free-logger
Commit: ccedadfdb8506b7b6bd7c6ffde101c24189b4b41
Parents: 2ff6b1a
Author: rpopma <[email protected]>
Authored: Mon Feb 22 01:25:08 2016 +0900
Committer: rpopma <[email protected]>
Committed: Mon Feb 22 01:25:08 2016 +0900

----------------------------------------------------------------------
 .../java/org/apache/logging/log4j/core/util/Constants.java   | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/ccedadfd/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Constants.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Constants.java 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Constants.java
index 07b2457..6cd0e8a 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Constants.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Constants.java
@@ -72,10 +72,12 @@ public final class Constants {
             "log4j.format.msg.async", false);
 
     /**
-     * Returns {@code true} if we think we are running in a web container, 
based on the presence of the
-     * {@code javax.servlet.Servlet} class in the classpath.
+     * {@code true} if we think we are running in a web container, base on the 
boolean value of system property
+     * "log4j2.is.webapp", or (if this system property is not set) whether the 
 {@code javax.servlet.Servlet} class
+     * is present in the classpath.
      */
-    public static final boolean IS_WEB_APP = 
Loader.isClassAvailable("javax.servlet.Servlet");
+    public static final boolean IS_WEB_APP = 
PropertiesUtil.getProperties().getBooleanProperty(
+            "log4j2.is.webapp", 
Loader.isClassAvailable("javax.servlet.Servlet"));
 
     /**
      * Kill switch for object pooling in ThreadLocals that enables much of the 
LOG4J2-1270 no-GC behaviour.

Reply via email to