Class Constants


  • @InternalApi
    public final class Constants
    extends Object
    Log4j API Constants.
    Since:
    2.6.2
    • Field Detail

      • IS_WEB_APP

        @Deprecated(since="3.0.0",
                    forRemoval=true)
        public static final boolean IS_WEB_APP
        Deprecated, for removal: This API element is subject to removal in a future version.
      • JAVA_MAJOR_VERSION

        public static final int JAVA_MAJOR_VERSION
      • MAX_REUSABLE_MESSAGE_SIZE

        public static final int MAX_REUSABLE_MESSAGE_SIZE
        Maximum size of the StringBuilders used in RingBuffer LogEvents to store the contents of reusable Messages. After a large message has been delivered to the appenders, the StringBuilder is trimmed to this size.

        The default value is 518, which allows the StringBuilder to resize three times from its initial size. Users can override with system property .

        Since:
        2.9
      • EMPTY_OBJECT_ARRAY

        public static final Object[] EMPTY_OBJECT_ARRAY
        The empty array.
      • EMPTY_BYTE_ARRAY

        public static final byte[] EMPTY_BYTE_ARRAY
        The empty array.
    • Method Detail

      • isWebApp

        public static boolean isWebApp()
        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 javax.servlet.Servlet class is present in the classpath.
      • setWebApp

        public static void setWebApp​(boolean webApp)
      • resetWebApp

        public static void resetWebApp()
      • isThreadLocalsEnabled

        public static boolean isThreadLocalsEnabled()
        Kill switch for object pooling in ThreadLocals that enables much of the LOG4J2-1270 no-GC behaviour.

        True for non-isWebApp() web apps}, disable by setting system property "log4j2.enable.threadlocals" to "false".

      • setThreadLocalsEnabled

        public static void setThreadLocalsEnabled​(boolean enabled)
      • resetThreadLocalsEnabled

        public static void resetThreadLocalsEnabled()