ppkarwasz commented on code in PR #1964:
URL: https://github.com/apache/logging-log4j2/pull/1964#discussion_r1401860900


##########
log4j-api/src/main/java/org/apache/logging/log4j/util/Constants.java:
##########
@@ -120,4 +115,44 @@ static int getMajorVersion(final String version) {
             return 0;
         }
     }
+
+    /**
+     * {@code true} if we think we are running in a web container, based 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 boolean isWebApp() {
+        return WEB_APP.getAsBoolean();
+    }
+
+    @InternalApi
+    public static void setWebApp(final boolean webApp) {
+        WEB_APP.setAsBoolean(webApp);
+    }
+
+    @InternalApi
+    public static void resetWebApp() {
+        WEB_APP.reset();
+    }

Review Comment:
   I am a little bit sensitive about adding public methods in `log4j-api`. Even 
if the `o.a.l.l.util` package is marked as internal, it **isn't** (it contains 
`Supplier` for example).
   
   Is this something we are willing to support in `3.x`? It seems to me that 
methods like `Constants#isWebApp()` and `Constants#isUseThreadLocals()` should 
be caller sensitive or at least depend on the classloader where the 
`ThreadLocal`s will be.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to