Class Constants
- java.lang.Object
-
- org.apache.logging.log4j.util.Constants
-
public final class Constants extends java.lang.ObjectLog4j API Constants.- Since:
- 2.6.2
-
-
Field Summary
Fields Modifier and Type Field Description static byte[]EMPTY_BYTE_ARRAYThe empty array.static java.lang.Object[]EMPTY_OBJECT_ARRAYThe empty array.static booleanENABLE_THREADLOCALSSpecifies whether Log4j can bind non-JRE types toThreadLocalsstatic booleanIS_WEB_APPSpecifies whether Log4j is used in a servlet containerstatic intJAVA_MAJOR_VERSIONJava major version.static java.lang.StringLOG4J2_DEBUGName of the system property that will turn on TRACE level internal log4j2 status logging.static intMAX_REUSABLE_MESSAGE_SIZEMaximum size of the StringBuilders used in RingBuffer LogEvents to store the contents of reusable Messages.
-
Constructor Summary
Constructors Modifier Constructor Description privateConstants()Prevent class instantiation.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static intgetMajorVersion()(package private) static intgetMajorVersion(java.lang.String version)private static booleanisClassAvailable(java.lang.String className)Determines if a named Class can be loaded or not.private static intsize(java.lang.String property, int defaultValue)
-
-
-
Field Detail
-
IS_WEB_APP
public static final boolean IS_WEB_APP
Specifies whether Log4j is used in a servlet containerIf
trueLog4j disables the features, which are incompatible with a typical servlet application:- It disables the usage of
ThreadLocals for object pooling (unless the user has explicitly provided aENABLE_THREADLOCALSproperty) - It uses a web-application safe implementation of
ThreadContextMap(seeProvider.getThreadContextMap()), - It disables the shutdown hook,
- 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. - It disables the usage of
-
ENABLE_THREADLOCALS
public static final boolean ENABLE_THREADLOCALS
Specifies whether Log4j can bind non-JRE types toThreadLocalsThe value of this constant is
true, unless Log4j is running in a servlet container (cf.IS_WEB_APP). Use the"log4j2.enableThreadlocalssystem 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 java.lang.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 propertyorg.apache.logging.log4j.simplelog.StatusLogger.level.- Since:
- 2.9.0
- See Also:
- Constant Field Values
-
EMPTY_OBJECT_ARRAY
public static final java.lang.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
-
-
Method Detail
-
size
private static int size(java.lang.String property, int defaultValue)
-
isClassAvailable
private static boolean isClassAvailable(java.lang.String className)
Determines if a named Class can be loaded or not.- Parameters:
className- The class name.- Returns:
trueif the class could be found orfalseotherwise.
-
getMajorVersion
private static int getMajorVersion()
-
getMajorVersion
static int getMajorVersion(java.lang.String version)
-
-