Class Constants

java.lang.Object
org.apache.logging.log4j.util.Constants

public final class Constants extends Object
Log4j API Constants.
Since:
2.6.2
  • Field Details

    • IS_WEB_APP

      public static final boolean IS_WEB_APP
      Specifies whether Log4j is used in a servlet container

      If true Log4j disables the features, which are incompatible with a typical servlet application:

      1. It disables the usage of ThreadLocals for object pooling (unless the user has explicitly provided a ENABLE_THREADLOCALS property)
      2. It uses a web-application safe implementation of ThreadContextMap (see Provider.getThreadContextMap()),
      3. It disables the shutdown hook,
      4. It uses the caller thread to send JMX notifications.

      The value of this constant depends upon the presence of the Servlet API on the classpath and can be overridden using the "log4j2.isWebapp" system property.

    • ENABLE_THREADLOCALS

      public static final boolean ENABLE_THREADLOCALS
      Specifies whether Log4j can bind non-JRE types to ThreadLocals

      The value of this constant is true, unless Log4j is running in a servlet container (cf. IS_WEB_APP). Use the "log4j2.enableThreadlocals system property to override its value.

      In order to enable the garbage-free behavior described in LOG4J2-1270, this constant must be true.

      Warning: This setting does not disable all thread locals. It only disables those thread locals that can cause a classloader memory leak.

    • JAVA_MAJOR_VERSION

      public static final int JAVA_MAJOR_VERSION
      Java major version.
      Since:
      2.8.1
    • 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 "log4j.maxReusableMsgSize".

      Since:
      2.9.0
    • LOG4J2_DEBUG

      public static final String LOG4J2_DEBUG
      Name of the system property that will turn on TRACE level internal log4j2 status logging.

      If system property "log4j2.debug" is either defined empty or its value equals to true (ignoring case), all internal log4j2 logging will be printed to the console. The presence of this system property overrides any value set in the configuration's <Configuration status="<level>" ...> status attribute, as well as any value set for system property org.apache.logging.log4j.simplelog.StatusLogger.level.

      Since:
      2.9.0
      See Also:
    • EMPTY_OBJECT_ARRAY

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

      public static final byte[] EMPTY_BYTE_ARRAY
      The empty array.
      Since:
      2.15.0