Configuration properties
- Configuration properties
- Meta configuration properties
- Log4j API properties
- Log4j Core properties
- Async components
- Full asynchronous logger
- Mixed asynchronous logger
- Context selector
- Configuration factory
- Garbage Collection
- JMX
- JNDI
- Thread context
- Transport security
- log4j2.configurationAllowedProtocols
- log4j2.configurationAuthorizationProvider
- log4j2.configurationAuthorizationEncoding
- log4j2.configurationPassword
- log4j2.configurationPasswordDecryptor
- log4j2.configurationUsername
- log4j2.trustStoreLocation
- log4j2.trustStorePassword
- log4j2.trustStorePasswordFile
- log4j2.trustStorePasswordEnvironmentVariable
- log4j2.trustStoreType
- log4j2.trustStoreKeyManagerFactoryAlgorithm
- log4j2.sslVerifyHostName
- log4j2.keyStoreLocation
- log4j2.keyStorePassword
- log4j2.keyStorePasswordFile
- log4j2.keyStorePasswordEnvironmentVariable
- log4j2.keyStoreType
- log4j2.keyStoreKeyManagerFactoryAlgorithm
- Miscellaneous properties
Log4j contains a simple configuration properties sub-system that aggregates data from multiple property sources, such as Java System Properties and Environment Variables. See Property sources for a complete list of supported sources
Global configuration properties are used by Log4j in the following situations:
- to finely tune global Log4j API and Log4j Core services that are independent of the configuration file,
- to change the default values of attributes used in a configuration file.
Since Log4j 2.10 all the property names follow a common naming scheme:
log4j2.camelCasePropertyName
except the environment variables, which follow the:
LOG4J_CAMEL_CASE_PROPERTY_NAME
convention.
If a log4j2.system.properties file is available on the classpath its contents are sourced into Java system properties at Log4j startup. |
To provide backward compatibility with versions older than 2.10.0 a certain number of additional property names are also supported using a fuzzy matching algorithm. In case of problems with the properties sub-system, make sure that your application does not use property names with the following case-insensitive prefixes: - asyncLogger, - disableThreadContext, - isThreadContext, - org.apache.logging.log4j and that all the properties names that start with log4j use the normalized form provided by the tables below. |
Meta configuration properties
In order to rapidly optimize Log4j Core for a particular usage, you can use the following properties:
log4j2.isWebapp
| Env. variable | LOG4J_IS_WEBAPP |
| Type | boolean |
| Default value | true if the Servlet class on classpath, false otherwise |
Setting this property to true switches Log4j Core into “Web application mode” (“Web-app mode”).
In this mode Log4j is optimized to work in a Servlet container.
This mode is incompatible with log4j2.enableThreadlocals.
log4j2.enableThreadlocals
| Env. variable | LOG4J_ENABLE_THREADLOCALS |
| Type | boolean |
| Default value | false if Web-app mode is enabled, true otherwise |
Setting this property to true switches Log4j Core into “garbage-free mode” (“GC-free mode”).
In this mode Log4j uses ThreadLocals for object pooling to prevent object allocations.
ThreadLocal
fields holding non-JDK classes can cause memory leaks in web applications when the application server’s thread pool continues to reference these fields after the web application is undeployed.
Hence, to avoid causing memory leaks, log4j2.enableThreadlocals by default reflects the opposite of log4j2.isWebapp.
Log4j API properties
The services included in the log4j-api module can be configured exclusively through configuration properties.
LoaderUtil
The LoaderUtil class is used to load classes specified by the user using a fully qualified class name.
Therefore, its configuration influences all other services.
It has only one configuration property:
log4j2.ignoreTcl
| Env. variable | LOG4J_IGNORE_TCL |
| Type | boolean |
| Default value | false |
If true, classes are only loaded using the same classloader that loaded Log4j.
Otherwise, an attempt is made to load classes with the current thread’s context class loader before falling back to the default class loader.
Provider
The runtime classpath of an application should contain only a single implementation of the Log4j API. In the particular case, when multiple implementations are present, you can select a specific implementation using these properties:
log4j2.provider
| Env. variable | LOG4J_PROVIDER |
| Type | Class<? extends Provider> |
| Default value | automatically detected |
| Since | 2.24.0 |
Fully qualified class name of the Log4j API
Provider
to use.
By default, Log4j uses
ServiceLoader
to select the provider to use.
In case multiple providers are found on the classpath the provider with the highest priority is selected and a WARN message is logger by Status Logger.
log4j2.loggerContextFactory
| Env. variable | LOG4J_LOGGER_CONTEXT_FACTORY |
| Type | Class<? extends LoggerContextFactory> |
| Default value | automatically detected |
Since version 2.24.0 this property is deprecated, use log4j2.provider instead. |
Fully qualified class name of the
LoggerContextFactory
to use to create Loggers.
By default, Log4j uses Provider.getLoggerContextFactory() to get a logger context factory.
If log4j2.provider is set, this property is ignored.
Log4j Core properties
While the only required configuration of the log4j-core library is provided by the configuration file, the library offers many configuration properties that can be used to finely tune the way it works.
Async components
The behavior of all three async components (AsyncLogger, AsyncLoggerConfig and AsyncAppender) can be tuned using these properties:
log4j2.formatMsgAsync
| Env. variable | LOG4J_FORMAT_MSG_ASYNC |
| Type | boolean |
| Default value | false |
If false, Log4j will make sure the message is formatted in the caller thread, otherwise the formatting will occur on the asynchronous thread.
Remark: messages annotated with
AsynchronouslyFormattable
will be formatted on the async thread regardless of this setting.
log4j2.asyncQueueFullPolicy
| Env. variable | LOG4J_ASYNC_QUEUE_FULL_POLICY |
| Type | Class<? extends AsyncQueueFullPolicy> or predefined constant |
| Default value | Default |
Determines the
AsyncQueueFullPolicy
to use when the underlying async component cannot keep up with the logging rate and the queue is filling up.
Its value should be the fully qualified class name of an AsyncQueueFullPolicy implementation or one of these predefined constants:
Default : blocks the calling thread until the event can be added to the queue.
Discard
: when the queue is full, it drops the events whose level is equal or less than the threshold level (see
log4j2.discardThreshold).
log4j2.discardThreshold
| Env. variable | LOG4J_DISCARD_THRESHOLD |
| Type | Level |
| Default value | INFO |
Determines the threshold level used by a Discard queue full policy.
Log events whose level is not more severe than the threshold level will be discarded during a queue full event.
See also log4j2.asyncQueueFullPolicy.
Full asynchronous logger
The AsyncLogger component supports the following additional properties:
log4j2.asyncLoggerExceptionHandler
| Env. variable | LOG4J_ASYNC_LOGGER_EXCEPTION_HANDLER |
| Type | Class<? extends ExceptionHandler<? super RingBufferLogEvent>> |
| Default value | AsyncLoggerDefaultExceptionHandler |
Fully qualified name of a class that implements the ExceptionHandler interface, which will be notified when an exception occurs while logging messages.
The class needs to have a public zero-argument constructor.
The default exception handler will print a message and stack trace to the standard error output stream.
log4j2.asyncLoggerRingBufferSize
| Env. variable | LOG4J_ASYNC_LOGGER_RING_BUFFER_SIZE |
| Type | int |
| Default value | 256 × 1024 (GC-free mode: 4 × 1024) |
Size (number of slots) in the RingBuffer used by the asynchronous logging subsystem. Make this value large enough to deal with bursts of activity. The minimum size is 128. The RingBuffer will be pre-allocated at first use and will never grow or shrink during the life of the system.
When the application is logging faster than the underlying appender can keep up with for a long enough time to fill up the queue, the behaviour is determined by the AsyncQueueFullPolicy.
log4j2.asyncLoggerWaitStrategy
| Env. variable | LOG4J_ASYNC_LOGGER_WAIT_STRATEGY |
| Type | predefined constant |
| Default value | Timeout |
Specifies the WaitStrategy used by the LMAX Disruptor.
The value needs to be one of the predefined constants:
Block : a strategy that uses a lock and condition variable for the I/O thread waiting for log events. Block can be used when throughput and low-latency are not as important as CPU resource. Recommended for resource constrained/virtualized environments. This wait strategy is not garbage free.
Timeout
: a variation of the Block strategy that will periodically wake up from the lock condition await() call.
This ensures that if a notification is missed somehow the consumer thread is not stuck but will recover with a small latency delay, see log4j2.asyncLoggerTimeout.
This wait strategy is garbage free.
Sleep
: a strategy that initially spins, then uses a Thread.yield(), and eventually parks for the minimum number of nanos the OS and JVM will allow while the I/O thread is waiting for log events (see log4j2.asyncLoggerRetries and log4j2.asyncLoggerSleepTimeNs).
Sleep is a good compromise between performance and CPU resource.
This strategy has very low impact on the application thread, in exchange for some additional latency for actually getting the message logged.
This wait strategy is garbage free.
Yield
: is a strategy that will use 100% CPU, but will give up the CPU if other threads require CPU resources.
This wait strategy is garbage free.
log4j2.asyncLoggerTimeout
| Env. variable | LOG4J_ASYNC_LOGGER_TIMEOUT |
| Type | int |
| Default value | 10 |
Timeout in milliseconds of Timeout wait strategy (see log4j2.asyncLoggerWaitStrategy).
log4j2.asyncLoggerSleepTimeNs
| Env. variable | LOG4J_ASYNC_LOGGER_SLEEP_TIME_NS |
| Type | long |
| Default value | 100 |
Sleep time in nanoseconds of Sleep wait strategy (see log4j2.asyncLoggerWaitStrategy).
log4j2.asyncLoggerRetries
| Env. variable | LOG4J_ASYNC_LOGGER_RETRIES |
| Type | int |
| Default value | 200 |
Total number of spin cycles and Thread.yield() cycles of Sleep (see log4j2.asyncLoggerWaitStrategy).
log4j2.asyncLoggerSynchronizeEnqueueWhenQueueFull
| Env. variable | LOG4J_ASYNC_LOGGER_SYNCHRONIZE_ENQUEUE_WHEN_QUEUE_FULL |
| Type | boolean |
| Default value | true |
Synchronizes access to the Disruptor ring buffer for blocking enqueue operations when the queue is full.
Users encountered excessive CPU utilization with Disruptor v3.4.2 when the application was logging more than the underlying appender could keep up with and the ring buffer became full, especially when the number of application threads vastly outnumbered the number of cores.
CPU utilization is significantly reduced by restricting access to the enqueue operation.
Setting this value to false may lead to very high CPU utilization when the async logging queue is full.
log4j2.asyncLoggerThreadNameStrategy
| Env. variable | LOG4J_ASYNC_LOGGER_HREAD_NAME_STRATEGY |
| Type | ThreadNameCachingStrategy (enumeration) |
| Default value | UNCACHED for JRE 8u102 or later, CACHED otherwise |
Specifies the
ThreadNameCachingStrategy
to use to cache the result of
Thread#getName().
This setting allows to cache the result of Thread.getName() calls and has two values:
CACHED
: stores the name of the current thread in a ThreadLocal field,
UNCACHED : disables caching.
Since JRE 8u102 the Thread.getName() method does not allocate a new object. |
Mixed asynchronous logger
The AsyncLoggerConfig component supports the following additional properties:
log4j2.asyncLoggerConfigExceptionHandler
| Env. variable | LOG4J_ASYNC_LOGGER_CONFIG_EXCEPTION_HANDLER |
| Type | Class<? extends ExceptionHandler<? super Log4jEventWrapper>> |
| Default value | AsyncLoggerConfigDefaultExceptionHandler |
Fully qualified name of a class that implements the ExceptionHandler interface, which will be notified when an exception occurs while logging messages.
The class needs to have a public zero-argument constructor.
The default exception handler will print a message and stack trace to the standard error output stream.
log4j2.asyncLoggerConfigRingBufferSize
| Env. variable | LOG4J_ASYNC_LOGGER_CONFIG_RING_BUFFER_SIZE |
| Type | int |
| Default value | 256 × 1024 (GC-free mode: 4 × 1024) |
Size (number of slots) in the RingBuffer used by the asynchronous logging subsystem. Make this value large enough to deal with bursts of activity. The minimum size is 128. The RingBuffer will be pre-allocated at first use and will never grow or shrink during the life of the system.
When the application is logging faster than the underlying appender can keep up with for a long enough time to fill up the queue, the behaviour is determined by the AsyncQueueFullPolicy.
log4j2.asyncLoggerConfigWaitStrategy
| Env. variable | LOG4J_ASYNC_LOGGER_CONFIG_WAIT_STRATEGY |
| Type | predefined constant |
| Default value | Timeout |
Specifies the WaitStrategy used by the LMAX Disruptor.
The value needs to be one of the predefined constants:
Block : a strategy that uses a lock and condition variable for the I/O thread waiting for log events. Block can be used when throughput and low-latency are not as important as CPU resource. Recommended for resource constrained/virtualised environments.
Timeout
: a variation of the Block strategy that will periodically wake up from the lock condition await() call.
This ensures that if a notification is missed somehow the consumer thread is not stuck but will recover with a small latency delay (see log4j2.asyncLoggerTimeout)
Sleep
: a strategy that initially spins, then uses a Thread.yield(), and eventually parks for the minimum number of nanos the OS and JVM will allow while the I/O thread is waiting for log events (see log4j2.asyncLoggerRetries and log4j2.asyncLoggerSleepTimeNs).
Sleep is a good compromise between performance and CPU resource.
This strategy has very low impact on the application thread, in exchange for some additional latency for actually getting the message logged.
Yield
: is a strategy that will use 100% CPU, but will give up the CPU if other threads require CPU resources.
See also Custom WaitStrategy for an alternative way to configure the wait strategy.
log4j2.asyncLoggerConfigTimeout
| Env. variable | LOG4J_ASYNC_LOGGER_CONFIG_TIMEOUT |
| Type | int |
| Default value | 10 |
Timeout in milliseconds of Timeout wait strategy (see log4j2.asyncLoggerConfigWaitStrategy).
log4j2.asyncLoggerConfigSleepTimeNs
| Env. variable | LOG4J_ASYNC_LOGGER_CONFIG_SLEEP_TIME_NS |
| Type | long |
| Default value | 100 |
Sleep time in nanoseconds of Sleep wait strategy (see log4j2.asyncLoggerConfigWaitStrategy)).
log4j2.asyncLoggerConfigRetries
| Env. variable | LOG4J_ASYNC_LOGGER_CONFIG_RETRIES |
| Type | int |
| Default value | 200 |
Total number of spin cycles and Thread.yield() cycles of Sleep (see log4j2.asyncLoggerConfigWaitStrategy)).
log4j2.asyncLoggerConfigSynchronizeEnqueueWhenQueueFull
| Env. variable | LOG4J_ASYNC_LOGGER_CONFIG_SYNCHRONIZE_ENQUEUE_WHEN_QUEUE_FULL |
| Type | boolean |
| Default value | true |
Synchronizes access to the Disruptor ring buffer for blocking enqueue operations when the queue is full.
Users encountered excessive CPU utilization with Disruptor v3.4.2 when the application was logging more than the underlying appender could keep up with and the ring buffer became full, especially when the number of application threads vastly outnumbered the number of cores.
CPU utilization is significantly reduced by restricting access to the enqueue operation.
Setting this value to false may lead to very high CPU utilization when the async logging queue is full.
Context selector
The
ContextSelector
component specifies the strategy used by Log4j to create new logger contexts.
The choice of ContextSelector determines in particular:
- how loggers are divided among logger contexts. See Log Separation for details.
- the
Loggerimplementation used by Log4j Core. See Async Logging as an example of this usage.
log4j2.contextSelector
| Env. variable | LOG4J_CONTEXT_SELECTOR |
| Type | Class<? extends ContextSelector> |
| Default value | ClassLoaderContextSelector (on Android) BasicContextSelector |
Specifies the fully qualified class name of the
ContextSelector
implementation to use.
The implementations available by default are:
org.apache.logging.log4j.core.selector.BasicContextSelector
: Creates a single logger context and synchronous loggers
org.apache.logging.log4j.core.async.BasicAsyncLoggerContextSelector
: Creates a single logger context and asynchronous loggers
org.apache.logging.log4j.core.selector.ClassLoaderContextSelector
: Creates a separate logger context per classloader and synchronous loggers
org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
: Creates a separate logger context per classloader and asynchronous loggers
org.apache.logging.log4j.core.osgi.BundleContextSelector
: Creates a separate logger context per OSGi bundle and synchronous loggers
org.apache.logging.log4j.core.selector.JndiContextSelector
: Creates loggers contexts based on a JNDI lookup and synchronous loggers See Web application for details.
There are also third-party context selector implementations:
| These context selectors are provided by third-party vendors and are not maintained by the Apache Logging Services (Log4j, Log4cxx, Log4net) project. |
eu.copernik.log4j.tomcat.TomcatContextSelector
: Selects the currently active Tomcat web application and creates synchronous loggers.
eu.copernik.log4j.tomcat.TomcatAsyncContextSelector
: Selects the currently active Tomcat web application and creates asynchronous loggers.
Configuration factory
Since configuration factories are used to parse the configuration file, they can only be configured through global configuration properties.
| Log4j Core supports both local and remote configuration files. If a remote configuration file is used, its transport must be secured. See Transport security for details. |
log4j2.configurationFactory
| Env. variable | LOG4J_CONFIGURATION_FACTORY |
| Type | Class<? extends ConfigurationFactory> |
| Default value | null |
Specifies the fully qualified class name of the preferred
ConfigurationFactory
to use.
Log4j will attempt to use the provided configuration factory before any other factory implementation.
log4j2.configurationFile
| Env. variable | LOG4J_CONFIGURATION_FILE |
| Type | Comma-separated list of Paths or URIs |
| Default value | automatically detected |
Specifies a comma-separated list of URIs or file paths to Log4j 2 configuration files.
If a relative URL is provided, it is interpreted as:
- path to a file, if the file exists,
- a classpath resource otherwise.
Usage of absolute URLs is restricted by the Transport Security configuration options.
See also Automatic Configuration.
log4j2.level
| Env. variable | LOG4J_LEVEL |
| Type | Level |
| Default value | ERROR |
Specifies the level of the root logger if:
- the default configuration is used,
- or the configuration file does not specify a level for the root logger.
log4j2.mergeStrategy
| Env. variable | LOG4J_MERGE_STRATEGY |
| Type | Class<? extends MergeStrategy> |
| Default value | DefaultMergeStrategy |
Specifies the fully qualified class name of the MergeStrategy implementation used to merge multiple configuration files into one.
Garbage Collection
log4j2.enableDirectEncoders
| Env. variable | LOG4J_ENABLE_DIRECT_ENCODERS |
| Type | boolean |
| Default value | true |
If true, garbage-aware layouts will directly encode log events into ByteBuffers provided by appenders.
This prevents allocating temporary String and char[] instances.
log4j2.encoderByteBufferSize
| Env. variable | LOG4J_ENCODER_BYTE_BUFFER_SIZE |
| Type | int |
| Default value | 8192 |
The size in bytes of the
ByteBuffers
stored in ThreadLocal fields by layouts and
StringBuilderEncoders.
This setting is only used if log4j2.enableDirectEncoders is set to true.
log4j2.encoderCharBufferSize
| Env. variable | LOG4J_ENCODER_CHAR_BUFFER_SIZE |
| Type | int |
| Default value | 4096 |
The size in chars of the
ByteBuffers
stored in ThreadLocal fields
StringBuilderEncoders.
This setting is only used if log4j2.enableDirectEncoders is set to true.
log4j2.initialReusableMsgSize
| Env. variable | LOG4J_INITIAL_REUSABLE_MSG_SIZE |
| Type | int |
| Default value | 128 |
In GC-free mode, this property determines the initial size of the reusable StringBuilders used by
ReusableMessages
for formatting purposes.
log4j2.maxReusableMsgSize
| Env. variable | LOG4J_MAX_REUSABLE_MSG_SIZE |
| Type | int |
| Default value | 518 |
In GC-free mode, this property determines the maximum size of the reusable StringBuilders used by
ReusableMessages
for formatting purposes.
The default value allows is equal to 2 × (2 × log4j.initialReusableMsgSize + 2) + 2 and allows the
StringBuilder to be resized twice by the current JVM resize algorithm.
log4j2.layoutStringBuilderMaxSize
| Env. variable | LOG4J_LAYOUT_STRING_BUILDER_MAX_SIZE |
| Type | int |
| Default value | 2048 |
This property determines the maximum size of the reusable StringBuilders used to format
LogEvents.
log4j2.unboxRingbufferSize
| Env. variable | LOG4J_UNBOX_RINGBUFFER_SIZE |
| Type | int |
| Default value | 32 |
The
Unbox
utility class can be used by users to format primitive values without incurring in the boxing allocation cost.
This property specifies the maximum number of primitive arguments to a log message that will be cached and usually does not need to be changed.
JMX
log4j2.disableJmx
| Env. variable | LOG4J_DISABLE_JMX |
| Type | boolean |
| Default value | true |
If false, Log4j configuration objects like LoggerContexts, Appenders, Loggers, etc.
will be instrumented with MBeans and can be remotely monitored and managed.
log4j2.jmxNotifyAsync
| Env. variable | LOG4J_JMX_NOTIFY_ASYNC |
| Type | int |
| Default value | true (Web-app mode: false) |
If true, Log4j’s JMX notifications are sent from a separate background thread, otherwise they are sent from the caller thread.
JNDI
Due to the inherent security problems of JNDI, its usage in Log4j is restricted to the java: protocol.
Moreover, each JNDI usage must be explicitly enabled by the user through the following configuration properties.
log4j2.enableJndiContextSelector
| Env. variable | LOG4J_ENABLE_JNDI_CONTEXT_SELECTOR |
| Type | boolean |
| Default value | false |
When true the JndiContextSelector is enabled for the java: protocol.
See Web application for more details.
log4j2.enableJndiJdbc
| Env. variable | LOG4J_ENABLE_JNDI_JDBC |
| Type | boolean |
| Default value | false |
When true, a Log4j JDBC Appender can use JNDI to retrieve a DataSource using the java: protocol.
log4j2.enableJndiJms
| Env. variable | LOG4J_ENABLE_JNDI_JMS |
| Type | boolean |
| Default value | false |
When true, a Log4j JMS Appender can use JNDI to retrieve the necessary components using the java: protocol.
log4j2.enableJndiLookup
| Env. variable | LOG4J_ENABLE_JNDI_LOOKUP |
| Type | boolean |
| Default value | false |
When true, the Log4j JNDI Lookup can use the java: protocol.
Thread context
The behavior of the ThreadContext class can be fine-tuned using the following properties.
These configuration properties are only used by the Log4j Core and Simple Logger implementations of Log4j API. The log4j-to-slf4j logging bridge delegates ThreadContext calls to the SLF4J MDC class. The log4j-to-jul logging bridge ignores all ThreadContext method calls. |
log4j2.disableThreadContext
| Env. variable | LOG4J_DISABLE_THREAD_CONTEXT |
| Type | boolean |
| Default value | false |
If true, the ThreadContext stack and map are disabled.
log4j2.disableThreadContextStack
| Env. variable | LOG4J_DISABLE_THREAD_CONTEXT_STACK |
| Type | boolean |
| Default value | false |
If true, the ThreadContext stack is disabled.
log4j2.disableThreadContextMap
| Env. variable | LOG4J_DISABLE_THREAD_CONTEXT_MAP |
| Type | boolean |
| Default value | false |
If true, the ThreadContext map is disabled.
log4j2.threadContextMap
| Env. variable | LOG4J_THREAD_CONTEXT_MAP |
| Type | Class<? extends ThreadContextMap> or predefined constant |
| Default value | WebApp |
Fully specified class name of a custom
ThreadContextMap
implementation class or (since version 2.24.0) one of the predefined constants:
NoOp : to disable the thread context,
WebApp
: a web application-safe implementation, that only binds JRE classes to ThreadLocal to prevent memory leaks,
GarbageFree : a garbage-free implementation.
log4j2.isThreadContextMapInheritable
| Env. variable | LOG4J_IS_THREAD_CONTEXT_MAP_INHERITABLE |
| Type | boolean |
| Default value | false |
If true uses an InheritableThreadLocal to copy the thread context map to newly created threads.
Note that, as explained in
Java’s Executors#privilegedThreadFactory(), when you are dealing with privileged threads, thread context might not get propagated completely.
log4j2.garbagefreeThreadContextMap
| Env. variable | LOG4J_GARBAGEFREE_THREAD_CONTEXT_MAP |
| Default value | false |
If set to true selects a garbage-free thread context map implementation.
Transport security
Since configuration files can be used to load arbitrary classes into a Log4j Core Configuration, users need to ensure that all the configuration elements come from trusted sources (cf. Thread model for more information).
In order to protect the user Log4j disables the http URI scheme by default and provides several configuration options to ensure secure transport of configuration files:
log4j2.configurationAllowedProtocols
| Env. variable | LOG4J_CONFIGURATION_ALLOWED_PROTOCOLS |
| Type | Comma-separated list of URL protocols |
| Default value | file, https, jar (JVM) file, https, jar, resource (GraalVM) |
A comma separated list of URL protocols that may be used to load any kind of configuration source.
To completely prevent accessing the configuration via the Java URL class specify a value of _none.
NOTE
: Since Log4j does not use URL to access file: resources, this protocol can not be effectively disabled.
log4j2.configurationAuthorizationProvider
| Env. variable | LOG4J_CONFIGURATION_AUTHORIZATION_PROVIDER |
| Type | Class<? extends AuthorizationProvider> |
| Default value | BasicAuthorizationProvider |
The fully qualified class name of the
AuthorizationProvider
implementation to use with http and https URL protocols.
log4j2.configurationAuthorizationEncoding
| Env. variable | LOG4J_CONFIGURATION_AUTHORIZATION_ENCODING |
| Type | Charset |
| Default value | UTF-8 |
The encoding used in Basic Authentication (cf. RFC 7617).
log4j2.configurationPassword
| Env. variable | LOG4J_CONFIGURATION_PASSWORD |
| Type | String |
| Default value | null |
The password to use in HTTP Basic authentication.
If used in conjunction with log4j2.configurationPasswordDecryptor the contents of this variable are interpreted by the decryptor.
log4j2.configurationPasswordDecryptor
| Env. variable | LOG4J_CONFIGURATION_PASSWORD_DECRYPTOR |
| Type | Class<? extends PasswordDecryptor> |
| Default value | null |
Fully qualified class name of an implementation of
PasswordDecryptor
to use for the value of the log4j2.configurationPassword property.
If null, the literal value of the password is used.
log4j2.configurationUsername
| Env. variable | LOG4J_CONFIGURATION_USERNAME |
| Type | String |
| Default value | null |
The username used in HTTP Basic authentication.
log4j2.trustStoreLocation
| Env. variable | LOG4J_TRUST_STORE_LOCATION |
| Type | Path or URI |
| Default value | see Default Java trust store |
The location of the trust store.
| Log4j Core typically does not communicate with external organizations; therefore, the default trust store provided by the Java Runtime Environment is often not appropriate. When configuring a trust store for Log4j Core, follow established best practices. For example, NIST SP 800-52 Rev. 2 (§4.5.2) recommends using a trust store that contains only the CA certificates required for the intended communication scope, such as a private or enterprise CA. This reduces exposure to unintended or compromised CA certificates included in the default trust store. |
log4j2.trustStorePassword
| Env. variable | LOG4J_TRUST_STORE_PASSWORD |
| Type | String |
| Default value | null |
The password for the trust store.
log4j2.trustStorePasswordFile
| Env. variable | LOG4J_TRUST_STORE_PASSWORD_FILE |
| Type | Path |
| Default value | null |
The name of a file that contains the password for the trust store.
log4j2.trustStorePasswordEnvironmentVariable
| Env. variable | LOG4J_TRUST_STORE_PASSWORD_ENVIRONMENT_VARIABLE |
| Type | String |
| Default value | null |
The name of the environment variable that contains password for the trust store.
log4j2.trustStoreType
| Env. variable | LOG4J_TRUST_STORE_TYPE |
| Type | KeyStore type |
| Default value | Default Java KeyStore type |
The type of trust store.
log4j2.trustStoreKeyManagerFactoryAlgorithm
| Env. variable | LOG4J_TRUST_STORE_KEY_MANAGER_FACTORY_ALGORITHM |
| Type | KeyManagerFactory |
| Default value | Default Java KeyManagerFactory algorithm |
Name of the KeyManagerFactory implementation to use for the trust store.
log4j2.sslVerifyHostName
| Env. variable | LOG4J_SSL_VERIFY_HOST_NAME |
| Type | boolean |
| Default value | false |
If true enables verification of the name of the TLS server.
log4j2.keyStoreLocation
| Env. variable | LOG4J_KEY_STORE_LOCATION |
| Type | Path or URI |
| Default value | see Default Java key store |
The location of the private key store.
log4j2.keyStorePassword
| Env. variable | LOG4J_KEY_STORE_PASSWORD |
| Type | String |
| Default value | null |
The password for the private key store.
log4j2.keyStorePasswordFile
| Env. variable | LOG4J_KEY_STORE_PASSWORD_FILE |
| Type | Path |
| Default value | null |
The name of a file that contains the password for the private key store.
log4j2.keyStorePasswordEnvironmentVariable
| Env. variable | LOG4J_KEY_STORE_PASSWORD_ENVIRONMENT_VARIABLE |
| Type | String |
| Default value | null |
The name of the environment variable that contains the password for the private key store.
log4j2.keyStoreType
| Env. variable | LOG4J_KEY_STORE_TYPE |
| Type | KeyStore |
| Default value | Default Java KeyStore type |
The type of private key store.
See KeyStore.
log4j2.keyStoreKeyManagerFactoryAlgorithm
| Env. variable | LOG4J_KEY_STORE_KEY_MANAGER_FACTORY_ALGORITHM |
| Type | KeyManagerFactory |
| Default value | Default Java KeyManagerFactory algorithm |
Name of the KeyManagerFactory implementation to use for the private key store.
See KeyManagerFactory.
Miscellaneous properties
log4j2.clock
| Env. variable | LOG4J_CLOCK |
| Type | [`Class<? extends Cl |
(本文超出站点单文档体积上限,已截断)
