Plugin reference
This page is a Javadoc-on-steroids specialized for Log4j plugins.
This reference manual is derived from the source code of all Log4j plugins and types associated with them.
You can use this reference manual to precisely customize your log4j2.xml
.
Every running Log4j system is a constellation of plugins, which is analogous to beans in Java EE and Spring. This not only allows Log4j itself to be developed in individual components, but also enables extensibility users can leverage. |
Index
Below is a list of all types reachable by plugins grouped by the Maven coordinate of the artifact bundling them.
log4j-1.2-api
AbstractBuilder
- Class
-
org.apache.log4j.builders.AbstractBuilder
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
Base class for Log4j 1 component builders.
Builder
- Class
-
org.apache.log4j.builders.Builder
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
A marker interface for Log4j 1.x component builders.
Parser
- Class
-
org.apache.log4j.builders.Parser
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
Parses DOM and properties.
AppenderBuilder
- Class
-
org.apache.log4j.builders.appender.AppenderBuilder
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
Define an Appender Builder.
org.apache.log4j.AsyncAppender
- Class
-
org.apache.log4j.builders.appender.AsyncAppenderBuilder
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
Build an Async Appender
org.apache.log4j.ConsoleAppender
- Class
-
org.apache.log4j.builders.appender.ConsoleAppenderBuilder
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
Build a Console Appender
org.apache.log4j.DailyRollingFileAppender
- Class
-
org.apache.log4j.builders.appender.DailyRollingFileAppenderBuilder
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
Build a Daily Rolling File Appender
org.apache.log4j.rolling.RollingFileAppender
- Class
-
org.apache.log4j.builders.appender.EnhancedRollingFileAppenderBuilder
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
Build a File Appender
org.apache.log4j.FileAppender
- Class
-
org.apache.log4j.builders.appender.FileAppenderBuilder
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
Build a File Appender
org.apache.log4j.varia.NullAppender
- Class
-
org.apache.log4j.builders.appender.NullAppenderBuilder
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
Build a Null Appender
org.apache.log4j.rewrite.RewriteAppender
- Class
-
org.apache.log4j.builders.appender.RewriteAppenderBuilder
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
Build a Rewrite Appender
org.apache.log4j.RollingFileAppender
- Class
-
org.apache.log4j.builders.appender.RollingFileAppenderBuilder
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
Build a File Appender
org.apache.log4j.net.SocketAppender
- Class
-
org.apache.log4j.builders.appender.SocketAppenderBuilder
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
Build a Console Appender
org.apache.log4j.net.SyslogAppender
- Class
-
org.apache.log4j.builders.appender.SyslogAppenderBuilder
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
Build a File Appender
org.apache.log4j.varia.DenyAllFilter
- Class
-
org.apache.log4j.builders.filter.DenyAllFilterBuilder
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
Build a Pattern Layout
FilterBuilder
- Class
-
org.apache.log4j.builders.filter.FilterBuilder
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
Define a Filter Builder.
org.apache.log4j.varia.LevelMatchFilter
- Class
-
org.apache.log4j.builders.filter.LevelMatchFilterBuilder
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
Build a Level match filter.
org.apache.log4j.varia.LevelRangeFilter
- Class
-
org.apache.log4j.builders.filter.LevelRangeFilterBuilder
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
Build a Level range filter.
org.apache.log4j.varia.StringMatchFilter
- Class
-
org.apache.log4j.builders.filter.StringMatchFilterBuilder
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
Build a String match filter.
org.apache.log4j.HTMLLayout
- Class
-
org.apache.log4j.builders.layout.HtmlLayoutBuilder
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
Build a Pattern Layout
LayoutBuilder
- Class
-
org.apache.log4j.builders.layout.LayoutBuilder
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
Define a Layout Builder.
org.apache.log4j.PatternLayout
- Class
-
org.apache.log4j.builders.layout.PatternLayoutBuilder
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
Build a Pattern Layout
org.apache.log4j.SimpleLayout
- Class
-
org.apache.log4j.builders.layout.SimpleLayoutBuilder
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
Build a Pattern Layout
org.apache.log4j.TTCCLayout
- Class
-
org.apache.log4j.builders.layout.TTCCLayoutBuilder
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
Build a Pattern Layout
org.apache.log4j.xml.XMLLayout
- Class
-
org.apache.log4j.builders.layout.XmlLayoutBuilder
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
Build an XML Layout
org.apache.log4j.rolling.CompositeTriggeringPolicy
- Class
-
org.apache.log4j.builders.rolling.CompositeTriggeringPolicyBuilder
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
org.apache.log4j.rolling.SizeBasedTriggeringPolicy
- Class
-
org.apache.log4j.builders.rolling.SizeBasedTriggeringPolicyBuilder
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
org.apache.log4j.rolling.TimeBasedRollingPolicy
- Class
-
org.apache.log4j.builders.rolling.TimeBasedRollingPolicyBuilder
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
TriggeringPolicyBuilder
- Class
-
org.apache.log4j.builders.rolling.TriggeringPolicyBuilder
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
Log4j1PropertiesConfigurationFactory
- Class
-
org.apache.log4j.config.PropertiesConfigurationFactory
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
Configures Log4j from a log4j 1 format properties file.
Log4j1SyslogLayout
- Class
-
org.apache.log4j.layout.Log4j1SyslogLayout
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
Port of the layout used by SyslogAppender in Log4j 1.x.
Provided for compatibility with existing Log4j 1 configurations. Originally developed by Ceki Glc and Anders Kristensen.
XML snippet
<Log4j1SyslogLayout charset=""
facility=""
facilityPrinting=""
footer=""
header="">
<a-Layout-implementation/>
<a-Serializer-implementation/>
</Log4j1SyslogLayout>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
||
|
|||
|
|
||
|
|
||
|
|
Log4j1XmlLayout
- Class
-
org.apache.log4j.layout.Log4j1XmlLayout
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
Port of XMLLayout in Log4j 1.x.
Provided for compatibility with existing Log4j 1 configurations. Originally developed by Ceki Glc, Mathias Bogaert.
Log4j1LevelPatternConverter
- Class
-
org.apache.log4j.pattern.Log4j1LevelPatternConverter
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
Outputs the Log4j 1.x level name.
Log4j1MdcPatternConverter
- Class
-
org.apache.log4j.pattern.Log4j1MdcPatternConverter
- Provider
-
org.apache.logging.log4j:log4j-1.2-api
Able to handle the contents of the LogEvent’s MDC and either output the entire contents of the properties, or to output the value of a specific key within the property bundle when this pattern converter has the option set.
log4j-cassandra
Type
- Class
-
com.datastax.driver.core.BatchStatement.Type
- Provider
-
org.apache.logging.log4j:log4j-cassandra
Cassandra
- Class
-
org.apache.logging.log4j.cassandra.CassandraAppender
- Provider
-
org.apache.logging.log4j:log4j-cassandra
Appender plugin that uses a Cassandra database.
XML snippet
<Cassandra batched=""
batchType=""
bufferSize=""
clusterName=""
ignoreExceptions=""
keyspace=""
name=""
password=""
table=""
useClockForTimestampGenerator=""
username=""
useTls="">
<a-Filter-implementation/>
<a-Layout-implementation/>
<ColumnMapping/><!-- multiple occurrences allowed -->
<Property/><!-- multiple occurrences allowed -->
<SocketAddress/><!-- multiple occurrences allowed -->
</Cassandra>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
Whether or not to use batch statements when inserting records. |
|
|
|
If batch statements are enabled, use this type of batch statement. |
|
|
|
Number of LogEvents to buffer before writing. Can be used with or without batch statements. |
|
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
Override the default TimestampGenerator with one based on the configured |
|
|
|
||
|
|
Nested components
Optional components are denoted by ?
-suffixed types.
Tag | Type | Description |
---|---|---|
|
List of column mappings to convert a LogEvent into a database row. |
|
|
||
|
List of Cassandra node contact points. Addresses without a port (or port set to 0) will use the default Cassandra port (9042). |
log4j-core
SpinPolicy
- Class
-
com.conversantmedia.util.concurrent.SpinPolicy
- Provider
-
org.apache.logging.log4j:log4j-core
Level
- Class
-
org.apache.logging.log4j.Level
- Provider
-
org.apache.logging.log4j:log4j-core
Represents a logging level. NOTE: The Log4j API supports custom levels, the following list contains only the standard ones.
AbstractLifeCycle
- Class
-
org.apache.logging.log4j.core.AbstractLifeCycle
- Provider
-
org.apache.logging.log4j:log4j-core
A life cycle to be extended.
Wraps a org.apache.logging.log4j.core.LifeCycle.State
.
Appender
- Class
-
org.apache.logging.log4j.core.Appender
- Provider
-
org.apache.logging.log4j:log4j-core
Appends org.apache.logging.log4j.core.LogEvent
s.
An Appender can contain a Layout if applicable as well as an org.apache.logging.log4j.core.ErrorHandler
. Typical Appender implementations coordinate with an implementation of org.apache.logging.log4j.core.appender.AbstractManager
to handle external resources such as streams, connections, and other shared state.
As Appenders are plugins, concrete implementations need to be annotated with org.apache.logging.log4j.core.config.plugins.Plugin
and need to provide a static factory method annotated with org.apache.logging.log4j.core.config.plugins.PluginFactory
.
Most core plugins are written using a related Manager class that handle the actual task of serializing a org.apache.logging.log4j.core.LogEvent
to some output location.
For instance, many Appenders can take advantage of the org.apache.logging.log4j.core.appender.OutputStreamManager
class.
It is recommended that Appenders don’t do any heavy lifting since there can be many instances of the class being used at any given time.
When resources require locking (e.g., through org.apache.logging.log4j.core.java.nio.channels.FileLock
), it is important to isolate synchronized code to prevent concurrency issues.
Filter
- Class
-
org.apache.logging.log4j.core.Filter
- Provider
-
org.apache.logging.log4j:log4j-core
Interface that must be implemented to allow custom event filtering.
It is highly recommended that applications make use of the Filters provided with this implementation before creating their own.
This interface supports "global" filters (i.e. - all events must pass through them first), attached to specific loggers and associated with Appenders. It is recommended that, where possible, Filter implementations create a generic filtering method that can be called from any of the filter methods.
Result
- Class
-
org.apache.logging.log4j.core.Filter.Result
- Provider
-
org.apache.logging.log4j:log4j-core
The result that can returned from a filter method call.
Layout
- Class
-
org.apache.logging.log4j.core.Layout
- Provider
-
org.apache.logging.log4j:log4j-core
Lays out a org.apache.logging.log4j.core.LogEvent
in different formats.
The formats are:
-
byte[]
-
an implementer of
java.io.Serializable
, likebyte[]
-
java.lang.String
-
org.apache.logging.log4j.core.LogEvent
Since 2.6, Layouts can encode a LogEvent
directly to a org.apache.logging.log4j.core.layout.ByteBufferDestination
without creating temporary intermediary objects.
LifeCycle
- Class
-
org.apache.logging.log4j.core.LifeCycle
- Provider
-
org.apache.logging.log4j:log4j-core
All proper Java frameworks implement some sort of object life cycle.
In Log4j, the main interface for handling the life cycle context of an object is this one.
An object first starts in the org.apache.logging.log4j.core.State#INITIALIZED
state by default to indicate the class has been loaded.
From here, calling the LifeCycle method will change this state to org.apache.logging.log4j.core.State#STARTING
. After successfully being started, this state is changed to org.apache.logging.log4j.core.State#STARTED
. When the LifeCycle is called, this goes into the org.apache.logging.log4j.core.State#STOPPING
state.
After successfully being stopped, this goes into the org.apache.logging.log4j.core.State#STOPPED
state.
In most circumstances, implementation classes should store their org.apache.logging.log4j.core.State
in a volatile
field or inside an org.apache.logging.log4j.core.java.util.concurrent.atomic.AtomicReference
dependent on synchronization and concurrency requirements.
LifeCycle2
- Class
-
org.apache.logging.log4j.core.LifeCycle2
- Provider
-
org.apache.logging.log4j:log4j-core
Extends the LifeCycle interface.
This interface should be merged with the super-interface in 3.0.
StringLayout
- Class
-
org.apache.logging.log4j.core.StringLayout
- Provider
-
org.apache.logging.log4j:log4j-core
Instantiates the Layout type for String-based layouts.
AbstractAppender
- Class
-
org.apache.logging.log4j.core.appender.AbstractAppender
- Provider
-
org.apache.logging.log4j:log4j-core
Abstract base class for Appenders.
Although Appenders do not have to extend this class, doing so will simplify their implementation.
AbstractOutputStreamAppender
- Class
-
org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender
- Provider
-
org.apache.logging.log4j:log4j-core
Appends log events as bytes to a byte output stream.
The stream encoding is defined in the layout.
AbstractWriterAppender
- Class
-
org.apache.logging.log4j.core.appender.AbstractWriterAppender
- Provider
-
org.apache.logging.log4j:log4j-core
Appends log events as strings to a writer.
AppenderSet
- Class
-
org.apache.logging.log4j.core.appender.AppenderSet
- Provider
-
org.apache.logging.log4j:log4j-core
A deferred plugin for appenders.
Async
- Class
-
org.apache.logging.log4j.core.appender.AsyncAppender
- Provider
-
org.apache.logging.log4j:log4j-core
Appends to one or more Appenders asynchronously.
You can configure an AsyncAppender with one or more Appenders and an Appender to append to if the queue is full. The AsyncAppender does not allow a filter to be specified on the Appender references.
XML snippet
<Async blocking=""
bufferSize=""
errorRef=""
ignoreExceptions=""
includeLocation=""
name=""
shutdownTimeout="">
<a-Filter-implementation/>
<a-BlockingQueueFactory-implementation/>
<AppenderRef/><!-- multiple occurrences allowed -->
<Property/><!-- multiple occurrences allowed -->
</Async>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
Console
- Class
-
org.apache.logging.log4j.core.appender.ConsoleAppender
- Provider
-
org.apache.logging.log4j:log4j-core
Appends log events to System. out
or System. err
using a layout specified by the user.
The default target is System. out
.
TODO Accessing System. out
or System. err
as a byte stream instead of a writer bypasses the JVM’s knowledge of the proper encoding.
(RG) Encoding is handled within the Layout.
Typically, a Layout will generate a String and then call getBytes which may use a configured encoding or the system default.
OTOH, a Writer cannot print byte streams.
XML snippet
<Console bufferedIo=""
bufferSize=""
direct=""
follow=""
ignoreExceptions=""
immediateFlush=""
name=""
target="">
<a-Filter-implementation/>
<a-Layout-implementation/>
<Property/><!-- multiple occurrences allowed -->
</Console>
Target
- Class
-
org.apache.logging.log4j.core.appender.ConsoleAppender.Target
- Provider
-
org.apache.logging.log4j:log4j-core
Enumeration of console destinations.
CountingNoOp
- Class
-
org.apache.logging.log4j.core.appender.CountingNoOpAppender
- Provider
-
org.apache.logging.log4j:log4j-core
No-Operation Appender that counts events.
Failover
- Class
-
org.apache.logging.log4j.core.appender.FailoverAppender
- Provider
-
org.apache.logging.log4j:log4j-core
The FailoverAppender will capture exceptions in an Appender and then route the event to a different appender.
Hopefully it is obvious that the Appenders must be configured to not suppress exceptions for the FailoverAppender to work.
XML snippet
<Failover ignoreExceptions=""
name=""
primary=""
retryIntervalSeconds="">
<a-String-implementation/><!-- multiple occurrences allowed -->
<a-Filter-implementation/>
</Failover>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
If |
|
|
|
The name of the Appender (required). |
|
|
|
The name of the primary Appender (required). |
|
|
|
The retry interval in seconds. |
Failovers
- Class
-
org.apache.logging.log4j.core.appender.FailoversPlugin
- Provider
-
org.apache.logging.log4j:log4j-core
The array of failover Appenders.
File
- Class
-
org.apache.logging.log4j.core.appender.FileAppender
- Provider
-
org.apache.logging.log4j:log4j-core
File Appender.
XML snippet
<File advertise=""
advertiseUri=""
append=""
bufferedIo=""
bufferSize=""
createOnDemand=""
fileGroup=""
fileName=""
fileOwner=""
filePermissions=""
ignoreExceptions=""
immediateFlush=""
locking=""
name="">
<a-Filter-implementation/>
<a-Layout-implementation/>
<Property/><!-- multiple occurrences allowed -->
</File>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
Http
- Class
-
org.apache.logging.log4j.core.appender.HttpAppender
- Provider
-
org.apache.logging.log4j:log4j-core
Sends log events over HTTP.
XML snippet
<Http connectTimeoutMillis=""
ignoreExceptions=""
method=""
name=""
readTimeoutMillis=""
url=""
verifyHostname="">
<a-Filter-implementation/>
<a-Layout-implementation/>
<Property/><!-- multiple occurrences allowed -->
<Ssl/>
</Http>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
MemoryMappedFile
- Class
-
org.apache.logging.log4j.core.appender.MemoryMappedFileAppender
- Provider
-
org.apache.logging.log4j:log4j-core
Memory Mapped File Appender.
XML snippet
<MemoryMappedFile advertise=""
advertiseURI=""
append=""
bufferedIo=""
bufferSize=""
fileName=""
ignoreExceptions=""
immediateFlush=""
name=""
regionLength="">
<a-Filter-implementation/>
<a-Layout-implementation/>
<Property/><!-- multiple occurrences allowed -->
</MemoryMappedFile>
Null
- Class
-
org.apache.logging.log4j.core.appender.NullAppender
- Provider
-
org.apache.logging.log4j:log4j-core
An Appender that ignores log events.
Use for compatibility with version 1.2 and handy for composing a ScriptAppenderSelector.
OutputStream
- Class
-
org.apache.logging.log4j.core.appender.OutputStreamAppender
- Provider
-
org.apache.logging.log4j:log4j-core
Appends log events to a given output stream using a layout.
Character encoding is handled within the Layout.
XML snippet
<OutputStream bufferedIo=""
bufferSize=""
ignoreExceptions=""
immediateFlush=""
name="">
<a-Filter-implementation/>
<a-Layout-implementation/>
<Property/><!-- multiple occurrences allowed -->
</OutputStream>
RandomAccessFile
- Class
-
org.apache.logging.log4j.core.appender.RandomAccessFileAppender
- Provider
-
org.apache.logging.log4j:log4j-core
File Appender.
XML snippet
<RandomAccessFile advertise=""
advertiseURI=""
append=""
bufferedIo=""
bufferSize=""
fileName=""
ignoreExceptions=""
immediateFlush=""
name="">
<a-Filter-implementation/>
<a-Layout-implementation/>
<Property/><!-- multiple occurrences allowed -->
</RandomAccessFile>
RollingFile
- Class
-
org.apache.logging.log4j.core.appender.RollingFileAppender
- Provider
-
org.apache.logging.log4j:log4j-core
An appender that writes to files and can roll over at intervals.
XML snippet
<RollingFile advertise=""
advertiseUri=""
append=""
bufferedIo=""
bufferSize=""
createOnDemand=""
fileGroup=""
fileName=""
fileOwner=""
filePattern=""
filePermissions=""
ignoreExceptions=""
immediateFlush=""
locking=""
name="">
<a-Filter-implementation/>
<a-Layout-implementation/>
<a-RolloverStrategy-implementation/>
<a-TriggeringPolicy-implementation/>
<Property/><!-- multiple occurrences allowed -->
</RollingFile>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
RollingRandomAccessFile
- Class
-
org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender
- Provider
-
org.apache.logging.log4j:log4j-core
An appender that writes to random access files and can roll over at intervals.
XML snippet
<RollingRandomAccessFile advertise=""
advertiseURI=""
append=""
bufferedIo=""
bufferSize=""
fileGroup=""
fileName=""
fileOwner=""
filePattern=""
filePermissions=""
ignoreExceptions=""
immediateFlush=""
name="">
<a-Filter-implementation/>
<a-Layout-implementation/>
<a-RolloverStrategy-implementation/>
<a-TriggeringPolicy-implementation/>
<Property/><!-- multiple occurrences allowed -->
</RollingRandomAccessFile>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
ScriptAppenderSelector
- Class
-
org.apache.logging.log4j.core.appender.ScriptAppenderSelector
- Provider
-
org.apache.logging.log4j:log4j-core
XML snippet
<ScriptAppenderSelector name="">
<AppenderSet/>
<a-AbstractScript-implementation/>
</ScriptAppenderSelector>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
SMTP
- Class
-
org.apache.logging.log4j.core.appender.SmtpAppender
- Provider
-
org.apache.logging.log4j:log4j-core
Send an e-mail when a specific logging event occurs, typically on errors or fatal errors.
The number of logging events delivered in this e-mail depend on the value of BufferSize option.
The SmtpAppender
keeps only the last BufferSize
logging events in its cyclic buffer.
This keeps memory requirements at a reasonable level while still delivering useful application context.
By default, an email message will formatted as HTML.
This can be modified by setting a layout for the appender.
By default, an email message will be sent when an ERROR or higher severity message is appended.
This can be modified by setting a filter for the appender.
XML snippet
<SMTP bcc=""
bufferSize=""
cc=""
from=""
ignoreExceptions=""
name=""
replyTo=""
smtpDebug=""
smtpHost=""
smtpPassword=""
smtpPort=""
smtpProtocol=""
smtpUsername=""
subject=""
to="">
<a-Filter-implementation/>
<a-Layout-implementation/>
<Property/><!-- multiple occurrences allowed -->
<Ssl/>
</SMTP>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
Comma-separated list of BCC email addresses. |
|
|
|
Number of log events to buffer before sending an email. Defaults to . |
|
|
|
Comma-separated list of CC email addresses. |
|
|
|
Email address of the sender. |
|
|
|
||
|
|
||
|
|
Comma-separated list of Reply-To email addresses. |
|
|
|
Enables or disables mail session debugging on STDOUT. Disabled by default. |
|
|
|
Host name of SMTP server to send messages through. |
|
|
|
Password to authenticate with SMTP server. |
|
|
|
Port number of SMTP server to send messages through. |
|
|
|
Transport protocol to use for SMTP such as "smtp" or "smtps". Defaults to "smtp". |
|
|
|
Username to authenticate with SMTP server. |
|
|
|
Subject template for the email messages. |
|
|
|
Comma-separated list of recipient email addresses. |
Nested components
Optional components are denoted by ?
-suffixed types.
Tag | Type | Description |
---|---|---|
|
||
Specifies the filter used for this appender. By default, uses a ThresholdFilter with a level of ERROR. |
||
Specifies the layout used for the email message body. By default, this uses the default HTML layout. |
||
|
Specifies an SSL configuration for smtps connections. |
Socket
- Class
-
org.apache.logging.log4j.core.appender.SocketAppender
- Provider
-
org.apache.logging.log4j:log4j-core
An Appender that delivers events over socket connections.
Supports both TCP and UDP.
XML snippet
<Socket advertise=""
bufferedIo=""
bufferSize=""
connectTimeoutMillis=""
host=""
ignoreExceptions=""
immediateFail=""
immediateFlush=""
name=""
port=""
protocol=""
reconnectDelayMillis="">
<a-Filter-implementation/>
<a-Layout-implementation/>
<Property/><!-- multiple occurrences allowed -->
<SocketOptions/>
<Ssl/>
</Socket>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|||
|
|
Nested components
Optional components are denoted by ?
-suffixed types.
Tag | Type | Description |
---|---|---|
|
||
|
||
|
Syslog
- Class
-
org.apache.logging.log4j.core.appender.SyslogAppender
- Provider
-
org.apache.logging.log4j:log4j-core
The Syslog Appender.
XML snippet
<Syslog advertise=""
appName=""
bufferedIo=""
bufferSize=""
charset=""
connectTimeoutMillis=""
enterpriseNumber=""
eventPrefix=""
exceptionPattern=""
facility=""
format=""
host=""
id=""
ignoreExceptions=""
immediateFail=""
immediateFlush=""
includeMdc=""
mdcExcludes=""
mdcId=""
mdcIncludes=""
mdcPrefix=""
mdcRequired=""
messageId=""
name=""
newLine=""
newLineEscape=""
port=""
protocol=""
reconnectDelayMillis="">
<a-Filter-implementation/>
<a-Layout-implementation/>
<Property/><!-- multiple occurrences allowed -->
<LoggerFields/><!-- multiple occurrences allowed -->
<SocketOptions/>
<Ssl/>
</Syslog>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|||
|
|
Writer
- Class
-
org.apache.logging.log4j.core.appender.WriterAppender
- Provider
-
org.apache.logging.log4j:log4j-core
Appends log events to a java.io.Writer
.
XML snippet
<Writer ignoreExceptions=""
name="">
<a-Filter-implementation/>
<a-Layout-implementation/>
<Property/><!-- multiple occurrences allowed -->
</Writer>
AbstractDatabaseAppender
- Class
-
org.apache.logging.log4j.core.appender.db.AbstractDatabaseAppender
- Provider
-
org.apache.logging.log4j:log4j-core
An abstract Appender for writing events to a database of some type, be it relational or NoSQL.
All database appenders should inherit from this base appender.
ColumnMapping
- Class
-
org.apache.logging.log4j.core.appender.db.ColumnMapping
- Provider
-
org.apache.logging.log4j:log4j-core
A configuration element for specifying a database column name mapping.
XML snippet
<ColumnMapping columnType=""
literal=""
name=""
parameter=""
pattern=""
source=""
type="">
<a-StringLayout-implementation/>
</ColumnMapping>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
Class to convert value to before storing in database. If the type is compatible with |
|
|
|
Literal value to use for populating a column. This is generally useful for functions, stored procedures, etc. No escaping will be done on this value. |
|
|
|
Column name. |
|
|
|
Parameter value to use for populating a column, MUST contain a single parameter marker '?'. This is generally useful for functions, stored procedures, etc. No escaping will be done on this value. |
|
|
|
Pattern to use as a PatternLayout. Convenient shorthand for ColumnMapping with a PatternLayout. |
|
|
|
Source name. Useful when combined with a |
|
|
|
Nested components
Optional components are denoted by ?
-suffixed types.
Tag | Type | Description |
---|---|---|
Layout of value to write to database (before type conversion). Not applicable if ColumnMapping is a |
AbstractConnectionSource
- Class
-
org.apache.logging.log4j.core.appender.db.jdbc.AbstractConnectionSource
- Provider
-
org.apache.logging.log4j:log4j-core
AbstractDriverManagerConnectionSource
- Class
-
org.apache.logging.log4j.core.appender.db.jdbc.AbstractDriverManagerConnectionSource
- Provider
-
org.apache.logging.log4j:log4j-core
A ConnectionSource that uses a JDBC connection string, a user name, and a password to call java.sql.DriverManager#getConnection(String,String,String)
.
This plugin does not provide any connection pooling unless it is available through the connection string and driver itself. This handy to get you off the ground without having to deal with JNDI.
Column
- Class
-
org.apache.logging.log4j.core.appender.db.jdbc.ColumnConfig
- Provider
-
org.apache.logging.log4j:log4j-core
A configuration element used to configure which event properties are logged to which columns in the database table.
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
||
|
|
||
|
|
||
|
|
The literal value to insert into the column as-is without any quoting or escaping. Mutually exclusive with |
|
|
|
The name of the database column as it exists within the database table. |
|
|
|
The PatternLayout pattern to insert in this column. Mutually exclusive with |
ConnectionSource
- Class
-
org.apache.logging.log4j.core.appender.db.jdbc.ConnectionSource
- Provider
-
org.apache.logging.log4j:log4j-core
Configuration element for JdbcAppender.
If you want to use the JdbcAppender but none of the provided connection sources meet your needs, you can simply create your own connection source.
DataSource
- Class
-
org.apache.logging.log4j.core.appender.db.jdbc.DataSourceConnectionSource
- Provider
-
org.apache.logging.log4j:log4j-core
A JdbcAppender connection source that uses a javax.sql.DataSource
to connect to the database.
DriverManager
- Class
-
org.apache.logging.log4j.core.appender.db.jdbc.DriverManagerConnectionSource
- Provider
-
org.apache.logging.log4j:log4j-core
A ConnectionSource that uses a JDBC connection string, a user name, and a password to call java.sql.DriverManager#getConnection(String,String,String)
.
This plugin does not provide any connection pooling unless it is available through the connection string and driver itself. This handy to get you off the ground without having to deal with JNDI.
XML snippet
<DriverManager connectionString=""
driverClassName=""
password=""
userName="">
<Property/><!-- multiple occurrences allowed -->
</DriverManager>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
||
|
|
||
|
|
||
|
|
ConnectionFactory
- Class
-
org.apache.logging.log4j.core.appender.db.jdbc.FactoryMethodConnectionSource
- Provider
-
org.apache.logging.log4j:log4j-core
A JdbcAppender connection source that uses a public static factory method to obtain a java.sql.Connection
or javax.sql.DataSource
.
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
The name of a public class that contains a static method capable of returning either a |
|
|
|
The name of the public static method on the aforementioned class that returns the data source or connection.
If this method returns a |
JDBC
- Class
-
org.apache.logging.log4j.core.appender.db.jdbc.JdbcAppender
- Provider
-
org.apache.logging.log4j:log4j-core
This Appender writes logging events to a relational database using standard JDBC mechanisms.
It takes a list of ColumnConfigs and/or ColumnMappings with which it determines how to save the event data into the appropriate columns in the table.
ColumnMapping is new as of Log4j 2.8 and supports type conversion and persistence using java.sql.PreparedStatement#setObject(int,Object)
. A ConnectionSource plugin instance instructs the appender (and org.apache.logging.log4j.core.appender.db.jdbc.JdbcDatabaseManager
) how to connect to the database.
This appender can be reconfigured at run time.
XML snippet
<JDBC bufferSize=""
ignoreExceptions=""
immediateFail=""
name=""
reconnectIntervalMillis=""
tableName=""
truncateStrings="">
<a-Filter-implementation/>
<a-Layout-implementation/>
<ColumnMapping/><!-- multiple occurrences allowed -->
<Column/><!-- multiple occurrences allowed -->
<a-ConnectionSource-implementation/>
<Property/><!-- multiple occurrences allowed -->
</JDBC>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
If an integer greater than 0, this causes the appender to buffer log events and flush whenever the buffer reaches this size. |
|
|
|
||
|
|
||
|
|
||
|
|
||
|
|
The name of the database table to insert log events into. |
|
|
|
Nested components
Optional components are denoted by ?
-suffixed types.
Tag | Type | Description |
---|---|---|
|
||
|
Information about the columns that log event data should be inserted into and how to insert that data. |
|
The connections source from which database connections should be retrieved. |
||
|
||
JMS
- Class
-
org.apache.logging.log4j.core.appender.mom.JmsAppender
- Provider
-
org.apache.logging.log4j:log4j-core
Generic JMS Appender plugin for both queues and topics.
This Appender replaces the previous split ones. However, configurations set up for the 2.0 version of the JMS appenders will still work.
XML snippet
<JMS destinationBindingName=""
factoryBindingName=""
factoryName=""
ignoreExceptions=""
immediateFail=""
name=""
password=""
providerUrl=""
reconnectIntervalMillis=""
securityCredentials=""
securityPrincipalName=""
urlPkgPrefixes=""
userName="">
<a-Filter-implementation/>
<a-Layout-implementation/>
<Property/><!-- multiple occurrences allowed -->
</JMS>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
JeroMQ
- Class
-
org.apache.logging.log4j.core.appender.mom.jeromq.JeroMqAppender
- Provider
-
org.apache.logging.log4j:log4j-core
Sends log events to one or more ZeroMQ (JeroMQ) endpoints.
Requires the JeroMQ jar (LGPL as of 0.3.5)
XML snippet
<JeroMQ affinity=""
backlog=""
delayAttachOnConnect=""
identity=""
ignoreExceptions=""
ipv4Only=""
linger=""
maxMsgSize=""
name=""
rcvHwm=""
receiveBufferSize=""
receiveTimeOut=""
reconnectIVL=""
reconnectIVLMax=""
sendBufferSize=""
sendTimeOut=""
sndHwm=""
tcpKeepAlive=""
tcpKeepAliveCount=""
tcpKeepAliveIdle=""
tcpKeepAliveInterval=""
xpubVerbose="">
<a-Filter-implementation/>
<a-Layout-implementation/>
<Property/><!-- multiple occurrences allowed -->
</JeroMQ>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
Kafka
- Class
-
org.apache.logging.log4j.core.appender.mom.kafka.KafkaAppender
- Provider
-
org.apache.logging.log4j:log4j-core
Sends log events to an Apache Kafka topic.
XML snippet
<Kafka ignoreExceptions=""
key=""
name=""
retryCount=""
sendEventTimestamp=""
syncSend=""
topic="">
<a-Filter-implementation/>
<a-Layout-implementation/>
<Property/><!-- multiple occurrences allowed -->
</Kafka>
NoSql
- Class
-
org.apache.logging.log4j.core.appender.nosql.NoSqlAppender
- Provider
-
org.apache.logging.log4j:log4j-core
This Appender writes logging events to a NoSQL database using a configured NoSQL provider.
It requires implementations of org.apache.logging.log4j.core.appender.nosql.NoSqlObject
, org.apache.logging.log4j.core.appender.nosql.NoSqlConnection
, and NoSqlProvider to "know" how to write events to the chosen NoSQL database.
For examples on how to write your own NoSQL provider, see the simple source code for the MongoDB and CouchDB providers.
XML snippet
<NoSql bufferSize=""
ignoreExceptions=""
name="">
<a-Filter-implementation/>
<a-Layout-implementation/>
<a-NoSqlProvider-implementation/>
<Property/><!-- multiple occurrences allowed -->
<KeyValuePair/><!-- multiple occurrences allowed -->
</NoSql>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
Sets the buffer size. |
|
|
|
||
|
|
LoggerNameLevelRewritePolicy
- Class
-
org.apache.logging.log4j.core.appender.rewrite.LoggerNameLevelRewritePolicy
- Provider
-
org.apache.logging.log4j:log4j-core
Rewrites log event levels for a given logger name.
XML snippet
<LoggerNameLevelRewritePolicy logger="">
<KeyValuePair/><!-- multiple occurrences allowed -->
</LoggerNameLevelRewritePolicy>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
The logger name prefix for events to rewrite; all event logger names that start with this string will be rewritten. |
MapRewritePolicy
- Class
-
org.apache.logging.log4j.core.appender.rewrite.MapRewritePolicy
- Provider
-
org.apache.logging.log4j:log4j-core
This policy modifies events by replacing or possibly adding keys and values to the MapMessage.
XML snippet
<MapRewritePolicy mode="">
<KeyValuePair/><!-- multiple occurrences allowed -->
</MapRewritePolicy>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
The string representation of the Mode. |
PropertiesRewritePolicy
- Class
-
org.apache.logging.log4j.core.appender.rewrite.PropertiesRewritePolicy
- Provider
-
org.apache.logging.log4j:log4j-core
This policy modifies events by replacing or possibly adding keys and values to the MapMessage.
Rewrite
- Class
-
org.apache.logging.log4j.core.appender.rewrite.RewriteAppender
- Provider
-
org.apache.logging.log4j:log4j-core
This Appender allows the logging event to be manipulated before it is processed by other Appenders.
XML snippet
<Rewrite ignoreExceptions=""
name="">
<a-Filter-implementation/>
<a-RewritePolicy-implementation/>
<AppenderRef/><!-- multiple occurrences allowed -->
</Rewrite>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
If |
|
|
|
The name of the Appender. |
RewritePolicy
- Class
-
org.apache.logging.log4j.core.appender.rewrite.RewritePolicy
- Provider
-
org.apache.logging.log4j:log4j-core
Interface to be implemented by components that support modifications to the LogEvent.
AbstractRolloverStrategy
- Class
-
org.apache.logging.log4j.core.appender.rolling.AbstractRolloverStrategy
- Provider
-
org.apache.logging.log4j:log4j-core
AbstractTriggeringPolicy
- Class
-
org.apache.logging.log4j.core.appender.rolling.AbstractTriggeringPolicy
- Provider
-
org.apache.logging.log4j:log4j-core
Abstract convenience class for triggering policies that extend AbstractLifeCycle and implement TriggeringPolicy.
Policies
- Class
-
org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy
- Provider
-
org.apache.logging.log4j:log4j-core
Triggering policy that wraps other triggering policies.
CronTriggeringPolicy
- Class
-
org.apache.logging.log4j.core.appender.rolling.CronTriggeringPolicy
- Provider
-
org.apache.logging.log4j:log4j-core
Rolls a file over based on a cron schedule.
DefaultRolloverStrategy
- Class
-
org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy
- Provider
-
org.apache.logging.log4j:log4j-core
When rolling over, DefaultRolloverStrategy
renames files according to an algorithm as described below.
The DefaultRolloverStrategy is a combination of a time-based policy and a fixed-window policy. When the file name pattern contains a date format then the rollover time interval will be used to calculate the time to use in the file pattern. When the file pattern contains an integer replacement token one of the counting techniques will be used.
When the ascending attribute is set to true (the default) then the counter will be incremented and the current log file will be renamed to include the counter value. If the counter hits the maximum value then the oldest file, which will have the smallest counter, will be deleted, all other files will be renamed to have their counter decremented and then the current file will be renamed to have the maximum counter value. Note that with this counting strategy specifying a large maximum value may entirely avoid renaming files.
When the ascending attribute is false, then the "normal" fixed-window strategy will be used.
Let max and min represent the values of respectively the MaxIndex and MinIndex options.
Let "foo.
log" be the value of the ActiveFile option and "foo.
%i.log" the value of FileNamePattern. Then, when rolling over, the file foo. max.log
will be deleted, the file foo. max-1.log
will be renamed as foo. max.log
, the file foo. max-2.log
renamed as foo. max-1.log
, and so on, the file foo. min+1.log
renamed as foo. min+2.log
. Lastly, the active file foo. log
will be renamed as foo. min.log
and a new active file name foo. log
will be created.
Given that this rollover algorithm requires as many file renaming operations as the window size, large window sizes are discouraged.
XML snippet
<DefaultRolloverStrategy compressionLevel=""
fileIndex=""
max=""
min=""
stopCustomActionsOnError=""
tempCompressedFilePattern="">
<a-Action-implementation/><!-- multiple occurrences allowed -->
</DefaultRolloverStrategy>
DirectFileRolloverStrategy
- Class
-
org.apache.logging.log4j.core.appender.rolling.DirectFileRolloverStrategy
- Provider
-
org.apache.logging.log4j:log4j-core
Created by rgoers on 1/12/17.
DirectWriteRolloverStrategy
- Class
-
org.apache.logging.log4j.core.appender.rolling.DirectWriteRolloverStrategy
- Provider
-
org.apache.logging.log4j:log4j-core
When rolling over, DirectWriteRolloverStrategy
writes directly to the file as resolved by the file pattern.
Files will be renamed files according to an algorithm as described below.
The DirectWriteRolloverStrategy uses similar logic as DefaultRolloverStrategy to determine the file name based on the file pattern, however the DirectWriteRolloverStrategy writes directly to a file and does not rename it during rollover, except if it is compressed, in which case it will add the appropriate file extension.
XML snippet
<DirectWriteRolloverStrategy compressionLevel=""
maxFiles=""
stopCustomActionsOnError=""
tempCompressedFilePattern="">
<a-Action-implementation/><!-- multiple occurrences allowed -->
</DirectWriteRolloverStrategy>
NoOpTriggeringPolicy
- Class
-
org.apache.logging.log4j.core.appender.rolling.NoOpTriggeringPolicy
- Provider
-
org.apache.logging.log4j:log4j-core
OnStartupTriggeringPolicy
- Class
-
org.apache.logging.log4j.core.appender.rolling.OnStartupTriggeringPolicy
- Provider
-
org.apache.logging.log4j:log4j-core
Triggers a rollover on every restart, but only if the file size is greater than zero.
RolloverStrategy
- Class
-
org.apache.logging.log4j.core.appender.rolling.RolloverStrategy
- Provider
-
org.apache.logging.log4j:log4j-core
A RollingPolicy
specifies the actions taken on a logging file rollover.
SizeBasedTriggeringPolicy
- Class
-
org.apache.logging.log4j.core.appender.rolling.SizeBasedTriggeringPolicy
- Provider
-
org.apache.logging.log4j:log4j-core
TimeBasedTriggeringPolicy
- Class
-
org.apache.logging.log4j.core.appender.rolling.TimeBasedTriggeringPolicy
- Provider
-
org.apache.logging.log4j:log4j-core
Rolls a file over based on time.
TriggeringPolicy
- Class
-
org.apache.logging.log4j.core.appender.rolling.TriggeringPolicy
- Provider
-
org.apache.logging.log4j:log4j-core
A TriggeringPolicy
controls the conditions under which rollover occurs.
Such conditions include time of day, file size, an external event, the log request or a combination thereof.
AbstractAction
- Class
-
org.apache.logging.log4j.core.appender.rolling.action.AbstractAction
- Provider
-
org.apache.logging.log4j:log4j-core
Abstract base class for implementations of Action.
AbstractPathAction
- Class
-
org.apache.logging.log4j.core.appender.rolling.action.AbstractPathAction
- Provider
-
org.apache.logging.log4j:log4j-core
Abstract action for processing files that are accepted by the specified PathFilters.
Action
- Class
-
org.apache.logging.log4j.core.appender.rolling.action.Action
- Provider
-
org.apache.logging.log4j:log4j-core
The Action interface should be implemented by any class that performs file system actions for RollingFileAppenders after the close of the active log file.
Delete
- Class
-
org.apache.logging.log4j.core.appender.rolling.action.DeleteAction
- Provider
-
org.apache.logging.log4j:log4j-core
Rollover or scheduled action for deleting old log files that are accepted by the specified PathFilters.
XML snippet
<Delete basePath=""
followLinks=""
maxDepth=""
testMode="">
<a-PathCondition-implementation/><!-- multiple occurrences allowed -->
<a-PathSorter-implementation/>
<ScriptCondition/>
</Delete>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
base path from where to start scanning for files to delete. |
|
|
|
whether to follow symbolic links. Default is false. |
|
|
|
The maxDepth parameter is the maximum number of levels of directories to visit. A value of 0 means that only the starting file is visited, unless denied by the security manager. A value of MAX_VALUE may be used to indicate that all levels should be visited. |
|
|
|
if true, files are not deleted but instead a message is printed to the status logger at INFO level. Users can use this to do a dry run to test if their configuration works as expected. Default is false. |
Nested components
Optional components are denoted by ?
-suffixed types.
Tag | Type | Description |
---|---|---|
an array of path conditions (if more than one, they all need to accept a path before it is deleted). |
||
a plugin implementing the PathSorter interface |
||
|
Duration
- Class
-
org.apache.logging.log4j.core.appender.rolling.action.Duration
- Provider
-
org.apache.logging.log4j:log4j-core
Simplified implementation of the ISO-8601 Durations standard.
The supported format is PnDTnHnMnS
, with 'P' and 'T' optional.
Days are considered to be exactly 24 hours.
Similarly to the java. time. Duration
class, this class does not support year or month sections in the format.
This implementation does not support fractions or negative values.
IfAccumulatedFileCount
- Class
-
org.apache.logging.log4j.core.appender.rolling.action.IfAccumulatedFileCount
- Provider
-
org.apache.logging.log4j:log4j-core
PathCondition that accepts paths after some count threshold is exceeded during the file tree walk.
XML snippet
<IfAccumulatedFileCount exceeds="">
<a-PathCondition-implementation/><!-- multiple occurrences allowed -->
</IfAccumulatedFileCount>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
The threshold count from which files will be deleted. |
IfAccumulatedFileSize
- Class
-
org.apache.logging.log4j.core.appender.rolling.action.IfAccumulatedFileSize
- Provider
-
org.apache.logging.log4j:log4j-core
PathCondition that accepts paths after the accumulated file size threshold is exceeded during the file tree walk.
XML snippet
<IfAccumulatedFileSize exceeds="">
<a-PathCondition-implementation/><!-- multiple occurrences allowed -->
</IfAccumulatedFileSize>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
The threshold accumulated file size from which files will be deleted. |
IfAll
- Class
-
org.apache.logging.log4j.core.appender.rolling.action.IfAll
- Provider
-
org.apache.logging.log4j:log4j-core
Composite PathCondition
that only accepts objects that are accepted by all component conditions.
Corresponds to logical "AND".
IfAny
- Class
-
org.apache.logging.log4j.core.appender.rolling.action.IfAny
- Provider
-
org.apache.logging.log4j:log4j-core
Composite PathCondition
that accepts objects that are accepted by any component conditions.
Corresponds to logical "OR".
IfFileName
- Class
-
org.apache.logging.log4j.core.appender.rolling.action.IfFileName
- Provider
-
org.apache.logging.log4j:log4j-core
PathCondition that accepts files for deletion if their relative path matches either a glob pattern or a regular expression.
If both a regular expression and a glob pattern are specified the glob pattern is used and the regular expression is ignored.
The regular expression is a pattern as defined by the java.util.regex.Pattern
class.
A glob is a simplified pattern expression described in java.nio.file.FileSystem#getPathMatcher(String)
.
XML snippet
<IfFileName glob=""
regex="">
<a-PathCondition-implementation/><!-- multiple occurrences allowed -->
</IfFileName>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
the baseDir-relative path pattern of the files to delete (may contain '*' and '?' wildcarts) |
|
|
|
the regular expression that matches the baseDir-relative path of the file(s) to delete |
IfLastModified
- Class
-
org.apache.logging.log4j.core.appender.rolling.action.IfLastModified
- Provider
-
org.apache.logging.log4j:log4j-core
PathCondition that accepts paths that are older than the specified duration.
XML snippet
<IfLastModified age="">
<a-PathCondition-implementation/><!-- multiple occurrences allowed -->
</IfLastModified>
IfNot
- Class
-
org.apache.logging.log4j.core.appender.rolling.action.IfNot
- Provider
-
org.apache.logging.log4j:log4j-core
Wrapper PathCondition
that accepts objects that are rejected by the wrapped component filter.
PathCondition
- Class
-
org.apache.logging.log4j.core.appender.rolling.action.PathCondition
- Provider
-
org.apache.logging.log4j:log4j-core
Filter that accepts or rejects a candidate Path
for deletion.
SortByModificationTime
- Class
-
org.apache.logging.log4j.core.appender.rolling.action.PathSortByModificationTime
- Provider
-
org.apache.logging.log4j:log4j-core
PathSorter that sorts path by their LastModified attribute.
PathSorter
- Class
-
org.apache.logging.log4j.core.appender.rolling.action.PathSorter
- Provider
-
org.apache.logging.log4j:log4j-core
Defines the interface of classes that can sort Paths.
PosixViewAttribute
- Class
-
org.apache.logging.log4j.core.appender.rolling.action.PosixViewAttributeAction
- Provider
-
org.apache.logging.log4j:log4j-core
File POSIX attribute view action.
Allow to define file permissions, user and group for log files on POSIX supported OS.
XML snippet
<PosixViewAttribute basePath=""
fileGroup=""
fileOwner=""
filePermissions=""
followLinks=""
maxDepth="">
<a-PathCondition-implementation/><!-- multiple occurrences allowed -->
</PosixViewAttribute>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
ScriptCondition
- Class
-
org.apache.logging.log4j.core.appender.rolling.action.ScriptCondition
- Provider
-
org.apache.logging.log4j:log4j-core
A condition of the DeleteAction where a user-provided script selects the files to delete from a provided list.
The specified script may be a org.apache.logging.log4j.core.appender.rolling.action.org.apache.logging.log4j.core.script.Script
, a ScriptFile or a ScriptRef.
Nested components
Optional components are denoted by ?
-suffixed types.
Tag | Type | Description |
---|---|---|
The script to run.
This may be a
|
IdlePurgePolicy
- Class
-
org.apache.logging.log4j.core.appender.routing.IdlePurgePolicy
- Provider
-
org.apache.logging.log4j:log4j-core
Policy is purging appenders that were not in use specified time in minutes
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
when all appenders purged, the number of increments of timeUnit to check if any appenders appeared |
|
|
|
the number of increments of timeUnit before the Appender should be purged. |
|
|
|
the unit of time the timeToLive and the checkInterval is expressed in. |
PurgePolicy
- Class
-
org.apache.logging.log4j.core.appender.routing.PurgePolicy
- Provider
-
org.apache.logging.log4j:log4j-core
Policy for purging routed appenders
Route
- Class
-
org.apache.logging.log4j.core.appender.routing.Route
- Provider
-
org.apache.logging.log4j:log4j-core
A Route to an appender.
Routes
- Class
-
org.apache.logging.log4j.core.appender.routing.Routes
- Provider
-
org.apache.logging.log4j:log4j-core
Contains the individual Route elements.
XML snippet
<Routes pattern="">
<Route/><!-- multiple occurrences allowed -->
<a-AbstractScript-implementation/>
</Routes>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
Routing
- Class
-
org.apache.logging.log4j.core.appender.routing.RoutingAppender
- Provider
-
org.apache.logging.log4j:log4j-core
This Appender "routes" between various Appenders, some of which can be references to Appenders defined earlier in the configuration while others can be dynamically created within this Appender as required.
Routing is achieved by specifying a pattern on the Routing appender declaration. The pattern should contain one or more substitution patterns of the form "$${[key:]token}". The pattern will be resolved each time the Appender is called using the built in StrSubstitutor and the StrLookup plugin that matches the specified key.
XML snippet
<Routing ignoreExceptions=""
name="">
<a-Filter-implementation/>
<a-Layout-implementation/>
<a-RewritePolicy-implementation/>
<a-PurgePolicy-implementation/>
<Routes/>
<Property/><!-- multiple occurrences allowed -->
<a-AbstractScript-implementation/>
</Routing>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
||
|
|
ArrayBlockingQueue
- Class
-
org.apache.logging.log4j.core.async.ArrayBlockingQueueFactory
- Provider
-
org.apache.logging.log4j:log4j-core
Factory for creating instances of java.util.concurrent.ArrayBlockingQueue
.
AsyncLogger
- Class
-
org.apache.logging.log4j.core.async.AsyncLoggerConfig
- Provider
-
org.apache.logging.log4j:log4j-core
Asynchronous Logger object that is created via configuration and can be combined with synchronous loggers.
AsyncLoggerConfig is a logger designed for high throughput and low latency logging. It does not perform any I/O in the calling (application) thread, but instead hands off the work to another thread as soon as possible. The actual logging is performed in the background thread. It uses LMAX Disruptor for inter-thread communication.
To use AsyncLoggerConfig, specify <asyncLogger>
or <asyncRoot>
in configuration.
Note that for performance reasons, this logger does not include source location by default.
You need to specify includeLocation="true"
in the configuration or any %class, %location or %line conversion patterns in your log4j.
xml configuration will produce either a "?" character or no output at all.
For best performance, use AsyncLoggerConfig with the RandomAccessFileAppender or RollingRandomAccessFileAppender, with immediateFlush=false. These appenders have built-in support for the batching mechanism used by the Disruptor library, and they will flush to disk at the end of each batch. This means that even with immediateFlush=false, there will never be any items left in the buffer; all log events will all be written to disk in a very efficient manner.
XML snippet
<AsyncLogger additivity=""
includeLocation=""
level=""
levelAndRefs=""
name="">
<a-Filter-implementation/>
<AppenderRef/><!-- multiple occurrences allowed -->
<Property/><!-- multiple occurrences allowed -->
</AsyncLogger>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
||
|
|
||
|
|||
|
|
||
|
|
AsyncRoot
- Class
-
org.apache.logging.log4j.core.async.AsyncLoggerConfig.RootLogger
- Provider
-
org.apache.logging.log4j:log4j-core
An asynchronous root Logger.
XML snippet
<AsyncRoot additivity=""
includeLocation=""
level=""
levelAndRefs="">
<a-Filter-implementation/>
<AppenderRef/><!-- multiple occurrences allowed -->
<Property/><!-- multiple occurrences allowed -->
</AsyncRoot>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
||
|
|
||
|
|||
|
|
AsyncWaitStrategyFactory
- Class
-
org.apache.logging.log4j.core.async.AsyncWaitStrategyFactoryConfig
- Provider
-
org.apache.logging.log4j:log4j-core
This class allows users to configure the factory used to create an instance of the LMAX disruptor WaitStrategy used by Async Loggers in the log4j configuration.
BlockingQueueFactory
- Class
-
org.apache.logging.log4j.core.async.BlockingQueueFactory
- Provider
-
org.apache.logging.log4j:log4j-core
Factory for creating instances of java.util.concurrent.BlockingQueue
.
DisruptorBlockingQueue
- Class
-
org.apache.logging.log4j.core.async.DisruptorBlockingQueueFactory
- Provider
-
org.apache.logging.log4j:log4j-core
Factory for creating instances of com.conversantmedia.util.concurrent.DisruptorBlockingQueue
.
JCToolsBlockingQueue
- Class
-
org.apache.logging.log4j.core.async.JCToolsBlockingQueueFactory
- Provider
-
org.apache.logging.log4j:log4j-core
Factory for creating instances of BlockingQueues backed by JCTools org.jctools.queues.MpscArrayQueue
.
WaitStrategy
- Class
-
org.apache.logging.log4j.core.async.JCToolsBlockingQueueFactory.WaitStrategy
- Provider
-
org.apache.logging.log4j:log4j-core
LinkedTransferQueue
- Class
-
org.apache.logging.log4j.core.async.LinkedTransferQueueFactory
- Provider
-
org.apache.logging.log4j:log4j-core
Factory for creating instances of java.util.concurrent.LinkedTransferQueue
.
AppenderRef
- Class
-
org.apache.logging.log4j.core.config.AppenderRef
- Provider
-
org.apache.logging.log4j:log4j-core
An Appender reference.
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
The Level to filter against. |
||
|
|
The name of the Appender. |
Appenders
- Class
-
org.apache.logging.log4j.core.config.AppendersPlugin
- Provider
-
org.apache.logging.log4j:log4j-core
An Appender container.
Configuration
- Class
-
org.apache.logging.log4j.core.config.Configuration
- Provider
-
org.apache.logging.log4j:log4j-core
A Log4j configuration contains many components of which two are required: Appenders
and Loggers
.
XML snippet
<Configuration dest="err"
monitorInterval="0"
name=""
schema=""
shutdownHook=""
shutdownTimeout=""
status="ERROR"
strict="false">
<Properties/>
<Appenders/>
<CustomLevels/>
<Loggers/>
</Configuration>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
|
Specifies the destination for status logger events. The possible values are:
If the provided value is invalid, then the default destination of standard out will be used. |
|
|
|
Number of seconds between polls for configuration changes |
|
|
Name of the configuration |
|
|
|
The name of a classpath resource to use to validate the configuration |
|
|
|
Indicates if Log4j should automatically shut down when the JVM shuts down.
Possible values are |
|
|
|
Timeout in milliseconds of the logger context shut down |
|
|
|
Sets the level of the status logger |
|
|
|
|
If set to |
Nested components
Optional components are denoted by ?
-suffixed types.
Tag | Type | Description |
---|---|---|
|
Wrapper element for a list of appenders |
|
|
Wrapper element for a list of custom levels |
|
|
Wrapper element for a list of logger configurations |
|
|
Wrapper element for a list of properties |
ConfigurationAware
- Class
-
org.apache.logging.log4j.core.config.ConfigurationAware
- Provider
-
org.apache.logging.log4j:log4j-core
Indicates that a class requests the current Configuration to be injected.
ConfigurationFactory
- Class
-
org.apache.logging.log4j.core.config.ConfigurationFactory
- Provider
-
org.apache.logging.log4j:log4j-core
Factory class for parsed org.apache.logging.log4j.core.config.Configuration
objects from a configuration file.
ConfigurationFactory allows the configuration implementation to be dynamically chosen in 1 of 3 ways:
-
A system property named "log4j. configurationFactory" can be set with the name of the ConfigurationFactory to be used.
-
ConfigurationFactory can be called with the instance of the ConfigurationFactory to be used. This must be called before any other calls to Log4j.
-
A ConfigurationFactory implementation can be added to the classpath and configured as a plugin in the ConfigurationFactory category. The
org.apache.logging.log4j.core.config.Order
annotation should be used to configure the factory to be the first one inspected. See XmlConfigurationFactory for an example.
If the ConfigurationFactory that was added returns null on a call to getConfiguration then any other ConfigurationFactories found as plugins will be called in their respective order. DefaultConfiguration is always called last if no configuration has been returned.
CustomLevel
- Class
-
org.apache.logging.log4j.core.config.CustomLevelConfig
- Provider
-
org.apache.logging.log4j:log4j-core
Descriptor of a custom Level object that is created via configuration.
CustomLevels
- Class
-
org.apache.logging.log4j.core.config.CustomLevels
- Provider
-
org.apache.logging.log4j:log4j-core
Container for CustomLevelConfig objects.
Default
- Class
-
org.apache.logging.log4j.core.config.DefaultAdvertiser
- Provider
-
org.apache.logging.log4j:log4j-core
The default advertiser does not do anything.
http
- Class
-
org.apache.logging.log4j.core.config.HttpWatcher
- Provider
-
org.apache.logging.log4j:log4j-core
Logger
- Class
-
org.apache.logging.log4j.core.config.LoggerConfig
- Provider
-
org.apache.logging.log4j:log4j-core
Logger object that is created via configuration.
XML snippet
<Logger additivity=""
includeLocation=""
level=""
levelAndRefs=""
name="">
<a-Filter-implementation/>
<AppenderRef/><!-- multiple occurrences allowed -->
<Property/><!-- multiple occurrences allowed -->
</Logger>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
||
|
|
||
|
|||
|
|
||
|
|
Nested components
Optional components are denoted by ?
-suffixed types.
Tag | Type | Description |
---|---|---|
|
||
|
||
Root
- Class
-
org.apache.logging.log4j.core.config.LoggerConfig.RootLogger
- Provider
-
org.apache.logging.log4j:log4j-core
The root Logger.
XML snippet
<Root additivity=""
includeLocation=""
level=""
levelAndRefs="">
<a-Filter-implementation/>
<AppenderRef/><!-- multiple occurrences allowed -->
<Property/><!-- multiple occurrences allowed -->
</Root>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
||
|
|
||
|
|||
|
|
Loggers
- Class
-
org.apache.logging.log4j.core.config.LoggersPlugin
- Provider
-
org.apache.logging.log4j:log4j-core
Container of Logger objects.
Properties
- Class
-
org.apache.logging.log4j.core.config.PropertiesPlugin
- Provider
-
org.apache.logging.log4j:log4j-core
Handles properties defined in the configuration.
Property
- Class
-
org.apache.logging.log4j.core.config.Property
- Provider
-
org.apache.logging.log4j:log4j-core
Represents a key/value pair in the configuration.
Scripts
- Class
-
org.apache.logging.log4j.core.config.ScriptsPlugin
- Provider
-
org.apache.logging.log4j:log4j-core
A container of Scripts.
Arbiter
- Class
-
org.apache.logging.log4j.core.config.arbiters.Arbiter
- Provider
-
org.apache.logging.log4j:log4j-core
Interface used to check for portions of the configuration that may be optionally included.
ClassArbiter
- Class
-
org.apache.logging.log4j.core.config.arbiters.ClassArbiter
- Provider
-
org.apache.logging.log4j:log4j-core
Conditional that determines if the specified class is present.
DefaultArbiter
- Class
-
org.apache.logging.log4j.core.config.arbiters.DefaultArbiter
- Provider
-
org.apache.logging.log4j:log4j-core
Default Condition for a Select Condition.
EnvironmentArbiter
- Class
-
org.apache.logging.log4j.core.config.arbiters.EnvironmentArbiter
- Provider
-
org.apache.logging.log4j:log4j-core
Condition that determines if the specified environment variable is set.
ScriptArbiter
- Class
-
org.apache.logging.log4j.core.config.arbiters.ScriptArbiter
- Provider
-
org.apache.logging.log4j:log4j-core
Condition that evaluates a script.
Select
- Class
-
org.apache.logging.log4j.core.config.arbiters.SelectArbiter
- Provider
-
org.apache.logging.log4j:log4j-core
Class Description goes here.
SystemPropertyArbiter
- Class
-
org.apache.logging.log4j.core.config.arbiters.SystemPropertyArbiter
- Provider
-
org.apache.logging.log4j:log4j-core
Condition that determines if the specified property is set.
ConfigurationBuilderFactory
- Class
-
org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilderFactory
- Provider
-
org.apache.logging.log4j:log4j-core
Provides methods to create ConfigurationBuilders.
JsonConfigurationFactory
- Class
-
org.apache.logging.log4j.core.config.json.JsonConfigurationFactory
- Provider
-
org.apache.logging.log4j:log4j-core
TypeConverter
- Class
-
org.apache.logging.log4j.core.config.plugins.convert.TypeConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Interface for doing automatic String conversion to a specific type.
BigDecimal
- Class
-
org.apache.logging.log4j.core.config.plugins.convert.TypeConverters.BigDecimalConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Parses a java.lang.String
into a java.math.BigDecimal
.
BigInteger
- Class
-
org.apache.logging.log4j.core.config.plugins.convert.TypeConverters.BigIntegerConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Parses a java.lang.String
into a java.math.BigInteger
.
Boolean
- Class
-
org.apache.logging.log4j.core.config.plugins.convert.TypeConverters.BooleanConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Converts a java.lang.String
into a java.lang.Boolean
.
ByteArray
- Class
-
org.apache.logging.log4j.core.config.plugins.convert.TypeConverters.ByteArrayConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Converts a java.lang.String
into a byte[]
.
The supported formats are:
-
0x0123456789ABCDEF
-
Base64:ABase64String
-
String using
java.nio.charset.Charset#defaultCharset()
[TODO Should this be UTF-8 instead? ]
Byte
- Class
-
org.apache.logging.log4j.core.config.plugins.convert.TypeConverters.ByteConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Converts a java.lang.String
into a java.lang.Byte
.
CharacterArray
- Class
-
org.apache.logging.log4j.core.config.plugins.convert.TypeConverters.CharArrayConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Converts a java.lang.String
into a char[]
.
Character
- Class
-
org.apache.logging.log4j.core.config.plugins.convert.TypeConverters.CharacterConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Converts a java.lang.String
into a java.lang.Character
.
Charset
- Class
-
org.apache.logging.log4j.core.config.plugins.convert.TypeConverters.CharsetConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Converts a java.lang.String
into a java.nio.charset.Charset
.
Class
- Class
-
org.apache.logging.log4j.core.config.plugins.convert.TypeConverters.ClassConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Converts a java.lang.String
into a java.lang.Class
.
CronExpression
- Class
-
org.apache.logging.log4j.core.config.plugins.convert.TypeConverters.CronExpressionConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Double
- Class
-
org.apache.logging.log4j.core.config.plugins.convert.TypeConverters.DoubleConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Converts a java.lang.String
into a java.lang.Double
.
Duration
- Class
-
org.apache.logging.log4j.core.config.plugins.convert.TypeConverters.DurationConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Converts a java.lang.String
into a org.apache.logging.log4j.core.config.plugins.convert.TypeConverters.org.apache.logging.log4j.core.appender.rolling.action.Duration
.
File
- Class
-
org.apache.logging.log4j.core.config.plugins.convert.TypeConverters.FileConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Converts a java.lang.String
into a java.io.File
.
Float
- Class
-
org.apache.logging.log4j.core.config.plugins.convert.TypeConverters.FloatConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Converts a java.lang.String
into a java.lang.Float
.
InetAddress
- Class
-
org.apache.logging.log4j.core.config.plugins.convert.TypeConverters.InetAddressConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Converts a java.lang.String
into an java.net.InetAddress
.
Integer
- Class
-
org.apache.logging.log4j.core.config.plugins.convert.TypeConverters.IntegerConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Converts a java.lang.String
into a java.lang.Integer
.
Level
- Class
-
org.apache.logging.log4j.core.config.plugins.convert.TypeConverters.LevelConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Converts a java.lang.String
into a Log4j Level.
Returns null
for invalid level names.
Long
- Class
-
org.apache.logging.log4j.core.config.plugins.convert.TypeConverters.LongConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Converts a java.lang.String
into a java.lang.Long
.
Path
- Class
-
org.apache.logging.log4j.core.config.plugins.convert.TypeConverters.PathConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Converts a java.lang.String
into a java.nio.file.Path
.
Pattern
- Class
-
org.apache.logging.log4j.core.config.plugins.convert.TypeConverters.PatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Converts a java.lang.String
into a java.util.regex.Pattern
.
SecurityProvider
- Class
-
org.apache.logging.log4j.core.config.plugins.convert.TypeConverters.SecurityProviderConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Converts a java.lang.String
into a java.security.Provider
.
Short
- Class
-
org.apache.logging.log4j.core.config.plugins.convert.TypeConverters.ShortConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Converts a java.lang.String
into a java.lang.Short
.
String
- Class
-
org.apache.logging.log4j.core.config.plugins.convert.TypeConverters.StringConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Returns the given java.lang.String
, no conversion takes place.
URI
- Class
-
org.apache.logging.log4j.core.config.plugins.convert.TypeConverters.UriConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Converts a java.lang.String
into a java.net.URI
.
URL
- Class
-
org.apache.logging.log4j.core.config.plugins.convert.TypeConverters.UrlConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Converts a java.lang.String
into a java.net.URL
.
UUID
- Class
-
org.apache.logging.log4j.core.config.plugins.convert.TypeConverters.UuidConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Converts a java.lang.String
into a java.util.UUID
.
PropertiesConfigurationFactory
- Class
-
org.apache.logging.log4j.core.config.properties.PropertiesConfigurationFactory
- Provider
-
org.apache.logging.log4j:log4j-core
Creates a PropertiesConfiguration from a properties file.
XmlConfigurationFactory
- Class
-
org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory
- Provider
-
org.apache.logging.log4j:log4j-core
Factory to construct an XmlConfiguration.
YamlConfigurationFactory
- Class
-
org.apache.logging.log4j.core.config.yaml.YamlConfigurationFactory
- Provider
-
org.apache.logging.log4j:log4j-core
AbstractFilter
- Class
-
org.apache.logging.log4j.core.filter.AbstractFilter
- Provider
-
org.apache.logging.log4j:log4j-core
Users should extend this class to implement filters.
Filters can be either context wide or attached to an appender.
A filter may choose to support being called only from the context or only from an appender in which case it will only implement the required method(s). The rest will default to return org.apache.logging.log4j.core.filter.org.apache.logging.log4j.core.Filter.Result#NEUTRAL
.
Garbage-free note: the methods with unrolled varargs by default delegate to the apiref:org.apache.logging.log4j.core.filter.AbstractFilter#filter(Logger, Level, Marker, String, Object…)[filter method with vararg parameters]. Subclasses that want to be garbage-free should override these methods to implement the appropriate filtering without creating a vararg array.
AbstractFilterable
- Class
-
org.apache.logging.log4j.core.filter.AbstractFilterable
- Provider
-
org.apache.logging.log4j:log4j-core
Enhances a Class by allowing it to contain Filters.
BurstFilter
- Class
-
org.apache.logging.log4j.core.filter.BurstFilter
- Provider
-
org.apache.logging.log4j:log4j-core
The BurstFilter
is a logging filter that regulates logging traffic.
Use this filter when you want to control the maximum burst of log statements that can be sent to an appender.
The filter is configured in the log4j configuration file.
For example, the following configuration limits the number of INFO level (as well as DEBUG and TRACE) log statements that can be sent to the console to a burst of 100 with an average rate of 16 per second.
WARN, ERROR and FATAL messages would continue to be delivered.
<Console name="console"> <PatternLayout pattern="%-5p %d{dd-MMM-yyyy HH:mm:ss} %x %t %m%n"/> <Filters> <BurstFilter level="INFO" rate="16" maxBurst="100"/> </Filters> </Console>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
Sets the logging level to use. |
||
|
|
Sets the maximum number of events that can occur before events are filtered for exceeding the average rate. |
|
|
Sets the Result to return when the filter matches. Defaults to Result. NEUTRAL. |
||
|
Sets the Result to return when the filter does not match. The default is Result. DENY. |
||
|
|
Sets the average number of events per second to allow. |
Filters
- Class
-
org.apache.logging.log4j.core.filter.CompositeFilter
- Provider
-
org.apache.logging.log4j:log4j-core
Composes and invokes one or more filters.
DenyAllFilter
- Class
-
org.apache.logging.log4j.core.filter.DenyAllFilter
- Provider
-
org.apache.logging.log4j:log4j-core
This filter causes all logging events to be dropped.
DynamicThresholdFilter
- Class
-
org.apache.logging.log4j.core.filter.DynamicThresholdFilter
- Provider
-
org.apache.logging.log4j:log4j-core
Compares against a log level that is associated with a context value.
By default the context is the org.apache.logging.log4j.ThreadContext
, but users may configure a custom org.apache.logging.log4j.core.ContextDataInjector
which obtains context data from some other source.
XML snippet
<DynamicThresholdFilter defaultThreshold=""
key=""
onMatch=""
onMismatch="">
<KeyValuePair/><!-- multiple occurrences allowed -->
</DynamicThresholdFilter>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
The default Level. |
||
|
|
The name of the key to compare. |
|
|
The action to perform if a match occurs. |
||
|
The action to perform if no match occurs. |
Filterable
- Class
-
org.apache.logging.log4j.core.filter.Filterable
- Provider
-
org.apache.logging.log4j:log4j-core
Interface implemented by Classes that allow filtering to occur.
Extends LifeCycle since filters have a life cycle.
LevelMatchFilter
- Class
-
org.apache.logging.log4j.core.filter.LevelMatchFilter
- Provider
-
org.apache.logging.log4j:log4j-core
This filter returns the onMatch result if the logging level in the event matches the specified logging level exactly.
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
Sets the logging level to use. |
||
|
Sets the Result to return when the filter matches. Defaults to Result. NEUTRAL. |
||
|
Sets the Result to return when the filter does not match. The default is Result. DENY. |
LevelRangeFilter
- Class
-
org.apache.logging.log4j.core.filter.LevelRangeFilter
- Provider
-
org.apache.logging.log4j:log4j-core
This filter returns the LevelRangeFilter result if the level of the org.apache.logging.log4j.core.LogEvent
is in the range of the configured LevelRangeFilter and LevelRangeFilter values, otherwise it returns the LevelRangeFilter result.
The default values for LevelRangeFilter and LevelRangeFilter are set to Level and Level, respectively.
The default values for LevelRangeFilter and LevelRangeFilter are set to org.apache.logging.log4j.core.filter.Result#NEUTRAL
and org.apache.logging.log4j.core.filter.Result#DENY
, respectively.
The levels get compared by their associated integral values; Level has an integral value of 0, Level 100, Level 200, and so on.
For example, if the filter is configured with LevelRangeFilter set to Level, the filter will return LevelRangeFilter result for org.apache.logging.log4j.core.LogEvent
s of level with higher integral values; Level, Level, etc.
MapFilter
- Class
-
org.apache.logging.log4j.core.filter.MapFilter
- Provider
-
org.apache.logging.log4j:log4j-core
A Filter that operates on a Map.
XML snippet
<MapFilter onMatch=""
onMismatch=""
operator="">
<KeyValuePair/><!-- multiple occurrences allowed -->
</MapFilter>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|||
|
|||
|
|
Nested components
Optional components are denoted by ?
-suffixed types.
Tag | Type | Description |
---|---|---|
|
MarkerFilter
- Class
-
org.apache.logging.log4j.core.filter.MarkerFilter
- Provider
-
org.apache.logging.log4j:log4j-core
This filter returns the onMatch result if the marker in the LogEvent is the same as or has the configured marker as a parent.
MutableThreadContextMapFilter
- Class
-
org.apache.logging.log4j.core.filter.MutableThreadContextMapFilter
- Provider
-
org.apache.logging.log4j:log4j-core
Filter based on a value in the Thread Context Map (MDC).
XML snippet
<MutableThreadContextMapFilter configLocation=""
onMatch=""
onMismatch=""
pollInterval=""/>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
Sets the configuration to use. |
|
|
Sets the Result to return when the filter matches. Defaults to Result. NEUTRAL. |
||
|
Sets the Result to return when the filter does not match. The default is Result. DENY. |
||
|
|
Set the frequency in seconds that changes to the list a ThreadContext valudes should be checked. |
NoMarkerFilter
- Class
-
org.apache.logging.log4j.core.filter.NoMarkerFilter
- Provider
-
org.apache.logging.log4j:log4j-core
This filter returns the onMatch result if there is no marker in the LogEvent.
RegexFilter
- Class
-
org.apache.logging.log4j.core.filter.RegexFilter
- Provider
-
org.apache.logging.log4j:log4j-core
A filter that matches the given regular expression pattern against messages.
XML snippet
<RegexFilter onMatch=""
onMismatch=""
regex=""
useRawMsg="">
<a-String-implementation/><!-- multiple occurrences allowed -->
</RegexFilter>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
The action to perform when a match occurs. |
||
|
The action to perform when a mismatch occurs. |
||
|
|
The regular expression to match. |
|
|
|
If |
ScriptFilter
- Class
-
org.apache.logging.log4j.core.filter.ScriptFilter
- Provider
-
org.apache.logging.log4j:log4j-core
Returns the onMatch result if the script returns True and returns the onMismatch value otherwise.
XML snippet
<ScriptFilter onMatch=""
onMismatch="">
<a-AbstractScript-implementation/>
</ScriptFilter>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
The action to take if a match occurs. |
||
|
The action to take if no match occurs. |
StringMatchFilter
- Class
-
org.apache.logging.log4j.core.filter.StringMatchFilter
- Provider
-
org.apache.logging.log4j:log4j-core
This filter returns the onMatch result if the logging level in the event matches the specified logging level exactly.
StructuredDataFilter
- Class
-
org.apache.logging.log4j.core.filter.StructuredDataFilter
- Provider
-
org.apache.logging.log4j:log4j-core
Filter based on data in a StructuredDataMessage.
XML snippet
<StructuredDataFilter onMatch=""
onMismatch=""
operator="">
<KeyValuePair/><!-- multiple occurrences allowed -->
</StructuredDataFilter>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
The action to perform on a match. |
||
|
The action to perform on a mismatch. |
||
|
|
The operator to perform. If not "or" the operation will be an "and". |
ThreadContextMapFilter
- Class
-
org.apache.logging.log4j.core.filter.ThreadContextMapFilter
- Provider
-
org.apache.logging.log4j:log4j-core
Filter based on a value in the Thread Context Map (MDC).
XML snippet
<ThreadContextMapFilter onMatch=""
onMismatch=""
operator="">
<KeyValuePair/><!-- multiple occurrences allowed -->
</ThreadContextMapFilter>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|||
|
|||
|
|
ThresholdFilter
- Class
-
org.apache.logging.log4j.core.filter.ThresholdFilter
- Provider
-
org.apache.logging.log4j:log4j-core
This filter returns the onMatch result if the level in the LogEvent is the same or more specific than the configured level and the onMismatch value otherwise.
For example, if the ThresholdFilter is configured with Level ERROR and the LogEvent contains Level DEBUG then the onMismatch value will be returned since ERROR events are more specific than DEBUG. The default Level is ERROR.
TimeFilter
- Class
-
org.apache.logging.log4j.core.filter.TimeFilter
- Provider
-
org.apache.logging.log4j:log4j-core
Filters events that fall within a specified time period in each day.
LocationAware
- Class
-
org.apache.logging.log4j.core.impl.LocationAware
- Provider
-
org.apache.logging.log4j:log4j-core
Classes that use location information should implement this interface.
AbstractCsvLayout
- Class
-
org.apache.logging.log4j.core.layout.AbstractCsvLayout
- Provider
-
org.apache.logging.log4j:log4j-core
A superclass for Comma-Separated Value (CSV) layouts.
Depends on Apache Commons CSV 1.2.
AbstractJacksonLayout
- Class
-
org.apache.logging.log4j.core.layout.AbstractJacksonLayout
- Provider
-
org.apache.logging.log4j:log4j-core
AbstractLayout
- Class
-
org.apache.logging.log4j.core.layout.AbstractLayout
- Provider
-
org.apache.logging.log4j:log4j-core
Abstract base class for Layouts.
AbstractStringLayout
- Class
-
org.apache.logging.log4j.core.layout.AbstractStringLayout
- Provider
-
org.apache.logging.log4j:log4j-core
Abstract base class for Layouts that result in a String.
Since 2.4.1, this class has custom logic to convert ISO-8859-1 or US-ASCII Strings to byte[] arrays to improve performance: all characters are simply cast to bytes.
CsvLogEventLayout
- Class
-
org.apache.logging.log4j.core.layout.CsvLogEventLayout
- Provider
-
org.apache.logging.log4j:log4j-core
A Comma-Separated Value (CSV) layout to log events.
Depends on Apache Commons CSV 1.2.
XML snippet
<CsvLogEventLayout charset=""
delimiter=""
escape=""
footer=""
format=""
header=""
nullString=""
quote=""
quoteMode=""
recordSeparator=""/>
CsvParameterLayout
- Class
-
org.apache.logging.log4j.core.layout.CsvParameterLayout
- Provider
-
org.apache.logging.log4j:log4j-core
A Comma-Separated Value (CSV) layout to log event parameters.
The event message is currently ignored.
Best used with:
logger. debug(new ObjectArrayMessage(1, 2, "Bob"));
Depends on Apache Commons CSV 1.4.
XML snippet
<CsvParameterLayout charset=""
delimiter=""
escape=""
footer=""
format=""
header=""
nullString=""
quote=""
quoteMode=""
recordSeparator=""/>
Encoder
- Class
-
org.apache.logging.log4j.core.layout.Encoder
- Provider
-
org.apache.logging.log4j:log4j-core
Objects implementing the Encoder
interface know how to convert an object to some binary representation and write the result to a ByteBuffer
, ideally without creating temporary objects.
GelfLayout
- Class
-
org.apache.logging.log4j.core.layout.GelfLayout
- Provider
-
org.apache.logging.log4j:log4j-core
Lays out events in the Graylog Extended Log Format (GELF) 1.1.
This layout compresses JSON to GZIP or ZLIB (the compressionType
) if log event data is larger than 1024 bytes (the compressionThreshold
). This layout does not implement chunking.
XML snippet
<GelfLayout charset=""
compressionThreshold=""
compressionType=""
footer=""
header=""
host=""
includeMapMessage=""
includeNewLineDelimiter=""
includeNullDelimiter=""
includeStacktrace=""
includeThreadContext=""
mapMessageExcludes=""
mapMessageIncludes=""
mapPrefix=""
messagePattern=""
omitEmptyFields=""
threadContextExcludes=""
threadContextIncludes=""
threadContextPrefix="">
<a-Serializer-implementation/>
<a-PatternSelector-implementation/>
<KeyValuePair/><!-- multiple occurrences allowed -->
</GelfLayout>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
||
|
|
Compress if data is larger than this number of bytes (optional, defaults to 1024). |
|
|
Compression to use (optional, defaults to GZIP). |
||
|
|
||
|
|
||
|
|
The value of the |
|
|
|
Whether to include MapMessage fields as additional fields (optional, default to true). |
|
|
|
Whether to include newline (LF) as delimiter after each event (optional, default to false). |
|
|
|
Whether to include NULL byte as delimiter after each event (optional, default to false). Useful for Graylog GELF TCP input. |
|
|
|
Whether to include full stacktrace of logged Throwables (optional, default to true). If set to false, only the class name and message of the Throwable will be included. |
|
|
|
Whether to include thread context as additional fields (optional, default to true). |
|
|
|
A comma separated list of MapMessage keys to exclude; |
|
|
|
A comma separated list of thread context keys to include; |
|
|
|
The String to prefix the MapMessage attributes. |
|
|
|
The pattern to use to format the message. |
|
|
|
||
|
|
||
|
|
||
|
|
The String to prefix the ThreadContext attributes. |
CompressionType
- Class
-
org.apache.logging.log4j.core.layout.GelfLayout.CompressionType
- Provider
-
org.apache.logging.log4j:log4j-core
HtmlLayout
- Class
-
org.apache.logging.log4j.core.layout.HtmlLayout
- Provider
-
org.apache.logging.log4j:log4j-core
Outputs events as rows in an HTML table on an HTML page.
Appenders using this layout should have their encoding set to UTF-8 or UTF-16, otherwise events containing non ASCII characters could result in corrupted log files.
XML snippet
<HtmlLayout charset=""
contentType=""
datePattern=""
fontName=""
fontSize=""
locationInfo=""
timezone=""
title=""/>
FontSize
- Class
-
org.apache.logging.log4j.core.layout.HtmlLayout.FontSize
- Provider
-
org.apache.logging.log4j:log4j-core
Possible font sizes
JsonLayout
- Class
-
org.apache.logging.log4j.core.layout.JsonLayout
- Provider
-
org.apache.logging.log4j:log4j-core
Note: The JsonLayout should be considered to be deprecated.
Please use JsonTemplateLayout instead. Appends a series of JSON events as strings serialized as bytes.
Additional Fields
If you configure complete="true"
, the appender outputs a well-formed JSON document.
By default, with complete="false"
, you should include the output as an external file in a separate file to form a well-formed JSON document.
If complete="false"
, the appender does not write the JSON open array character "[" at the start of the document, "]" and the end, nor comma "," between records.
Appenders using this layout should have their charset
set to UTF-8
or UTF-16
, otherwise events containing non ASCII characters could result in corrupted log files.
By default, the JSON layout is not compact (a.k.a. "pretty") with compact="false"
, which means the appender uses end-of-line characters and indents lines to format the text.
If compact="true"
, then no end-of-line or indentation is used.
Message content may contain, of course, escaped end-of-lines.
This property allows addition of custom fields into generated JSON.
<JsonLayout><KeyValuePair key="foo" value="bar"/></JsonLayout>
inserts "foo":"bar"
directly into JSON output.
Supports Lookup expressions.
XML snippet
<JsonLayout charset=""
compact=""
complete=""
endOfLine=""
eventEol=""
footer=""
header=""
includeNullDelimiter=""
includeStacktrace=""
includeTimeMillis=""
locationInfo=""
objectMessageAsJsonObject=""
properties=""
propertiesAsList=""
stacktraceAsString="">
<a-Serializer-implementation/>
<KeyValuePair/><!-- multiple occurrences allowed -->
</JsonLayout>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
Whether to include NULL byte as delimiter after each event (optional, default to false). |
|
|
|
If "true", includes the stacktrace of any Throwable in the generated data, defaults to "true". If "true", includes the stacktrace of any Throwable in the generated JSON, defaults to "true". |
|
|
|
Whether to include the timestamp (in addition to the Instant) (optional, default to false). |
|
|
|
||
|
|
||
|
|
||
|
|
||
|
|
Whether to format the stacktrace as a string, and not a nested object (optional, defaults to false). |
LevelPatternSelector
- Class
-
org.apache.logging.log4j.core.layout.LevelPatternSelector
- Provider
-
org.apache.logging.log4j:log4j-core
Selects the pattern to use based on the Level in the LogEvent.
XML snippet
<LevelPatternSelector alwaysWriteExceptions=""
defaultPattern=""
disableAnsi=""
noConsoleNoAnsi="">
<PatternMatch/><!-- multiple occurrences allowed -->
</LevelPatternSelector>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
||
|
|
||
|
|
||
|
|
LoggerFields
- Class
-
org.apache.logging.log4j.core.layout.LoggerFields
- Provider
-
org.apache.logging.log4j:log4j-core
A LoggerFields container.
XML snippet
<LoggerFields discardIfAllFieldsAreEmpty=""
enterpriseId=""
sdId="">
<KeyValuePair/><!-- multiple occurrences allowed -->
</LoggerFields>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
this SD-ELEMENT should be discarded if all fields are empty |
|
|
|
The IANA assigned enterprise number |
|
|
|
The SD-ID in an SD-ELEMENT |
MarkerPatternSelector
- Class
-
org.apache.logging.log4j.core.layout.MarkerPatternSelector
- Provider
-
org.apache.logging.log4j:log4j-core
Selects the pattern to use based on the Marker in the LogEvent.
XML snippet
<MarkerPatternSelector alwaysWriteExceptions=""
defaultPattern=""
disableAnsi=""
noConsoleNoAnsi="">
<PatternMatch/><!-- multiple occurrences allowed -->
</MarkerPatternSelector>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
||
|
|
||
|
|
||
|
|
MessageLayout
- Class
-
org.apache.logging.log4j.core.layout.MessageLayout
- Provider
-
org.apache.logging.log4j:log4j-core
Formats a org.apache.logging.log4j.core.LogEvent
in its org.apache.logging.log4j.message.Message
form.
Useful in combination with a JMS Appender to map a Log4j org.apache.logging.log4j.core.layout.org.apache.logging.log4j.message.MapMessage
or org.apache.logging.log4j.core.layout.org.apache.logging.log4j.message.StringMapMessage
to a JMS org.apache.logging.log4j.core.layout.javax.jms.MapMessage
.
PatternLayout
- Class
-
org.apache.logging.log4j.core.layout.PatternLayout
- Provider
-
org.apache.logging.log4j:log4j-core
A flexible layout configurable with pattern string.
The goal of this class is to format a org.apache.logging.log4j.core.LogEvent
and return the results.
The format of the result depends on the conversion pattern.
The conversion pattern is closely related to the conversion pattern of the printf function in C. A conversion pattern is composed of literal text and format control expressions called conversion specifiers.
See the Log4j Manual for details on the supported pattern converters.
XML snippet
<PatternLayout alwaysWriteExceptions=""
charset=""
disableAnsi=""
footer=""
header=""
noConsoleNoAnsi=""
pattern="">
<a-PatternSelector-implementation/>
<Replace/>
</PatternLayout>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
PatternMatch
- Class
-
org.apache.logging.log4j.core.layout.PatternMatch
- Provider
-
org.apache.logging.log4j:log4j-core
PatternMatch configuration item.
PatternSelector
- Class
-
org.apache.logging.log4j.core.layout.PatternSelector
- Provider
-
org.apache.logging.log4j:log4j-core
Allows different patterns to be used with the PatternLayout based on some selection criteria.
Rfc5424Layout
- Class
-
org.apache.logging.log4j.core.layout.Rfc5424Layout
- Provider
-
org.apache.logging.log4j:log4j-core
Formats a log event in accordance with RFC 5424.
XML snippet
<Rfc5424Layout appName=""
charset=""
ein=""
enterpriseNumber=""
escapeNL=""
eventPrefix=""
exceptionPattern=""
excludes=""
facility=""
footer=""
header=""
id=""
includeMDC=""
includeNL=""
includes=""
mdcId=""
mdcPrefix=""
messageId=""
required=""
useTLSMessageFormat="">
<a-Serializer-implementation/>
<LoggerFields/><!-- multiple occurrences allowed -->
</Rfc5424Layout>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
ScriptPatternSelector
- Class
-
org.apache.logging.log4j.core.layout.ScriptPatternSelector
- Provider
-
org.apache.logging.log4j:log4j-core
Selects the pattern to use based on the result of executing a Script.
The returned value will be used as the "key" to choose between one of the configured patterns. If no key is returned or there is no match the default pattern will be used.
XML snippet
<ScriptPatternSelector alwaysWriteExceptions=""
defaultPattern=""
disableAnsi=""
noConsoleNoAnsi="">
<PatternMatch/><!-- multiple occurrences allowed -->
<a-AbstractScript-implementation/>
</ScriptPatternSelector>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
||
|
|
||
|
|
||
|
|
SerializedLayout
- Class
-
org.apache.logging.log4j.core.layout.SerializedLayout
- Provider
-
org.apache.logging.log4j:log4j-core
Formats a org.apache.logging.log4j.core.LogEvent
in its Java serialized form.
SyslogLayout
- Class
-
org.apache.logging.log4j.core.layout.SyslogLayout
- Provider
-
org.apache.logging.log4j:log4j-core
Formats a log event as a BSD Log record.
XML snippet
<SyslogLayout charset=""
facility=""
footer=""
header=""
newLine=""
newLineEscape="">
<a-Serializer-implementation/>
</SyslogLayout>
XmlLayout
- Class
-
org.apache.logging.log4j.core.layout.XmlLayout
- Provider
-
org.apache.logging.log4j:log4j-core
Appends a series of event
elements as defined in the Log4j-events.
xsd.
Additional Fields
If you configure complete="true"
, the appender outputs a well-formed XML document where the default namespace is the log4j namespace . By default, with complete="false"
, you should include the output as an external entity in a separate file to form a well-formed XML document.
If complete="false"
, the appender does not write the XML processing instruction and the root element.
Appenders using this layout should have their charset
set to UTF-8
or UTF-16
, otherwise events containing non-ASCII characters could result in corrupted log files.
By default, the XML layout is not compact (compact = not "pretty") with compact="false"
, which means the appender uses end-of-line characters and indents lines to format the XML.
If compact="true"
, then no end-of-line or indentation is used.
Message content may contain, of course, end-of-lines.
This property allows addition of custom fields into generated JSON.
<XmlLayout><KeyValuePair key="foo" value="bar"/></XmlLayout>
inserts <foo>bar</foo>
directly into XML output.
Supports Lookup expressions.
XML snippet
<XmlLayout charset=""
compact=""
complete=""
endOfLine=""
eventEol=""
footer=""
header=""
includeNullDelimiter=""
includeStacktrace=""
includeTimeMillis=""
locationInfo=""
properties=""
stacktraceAsString="">
<a-Serializer-implementation/>
<KeyValuePair/><!-- multiple occurrences allowed -->
</XmlLayout>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
Whether to include NULL byte as delimiter after each event (optional, default to false). |
|
|
|
If "true", includes the stacktrace of any Throwable in the generated data, defaults to "true". If "true", includes the stacktrace of any Throwable in the generated JSON, defaults to "true". |
|
|
|
Whether to include the timestamp (in addition to the Instant) (optional, default to false). |
|
|
|
||
|
|
||
|
|
Whether to format the stacktrace as a string, and not a nested object (optional, defaults to false). |
YamlLayout
- Class
-
org.apache.logging.log4j.core.layout.YamlLayout
- Provider
-
org.apache.logging.log4j:log4j-core
Appends a series of YAML events as strings serialized as bytes.
Additional Fields
Appenders using this layout should have their charset
set to UTF-8
or UTF-16
, otherwise events containing non ASCII characters could result in corrupted log files.
This property allows addition of custom fields into generated JSON.
<YamlLayout><KeyValuePair key="foo" value="bar"/></YamlLayout>
inserts foo: "bar"
directly into YAML output.
Supports Lookup expressions.
XML snippet
<YamlLayout charset=""
compact=""
complete=""
endOfLine=""
eventEol=""
footer=""
header=""
includeNullDelimiter=""
includeStacktrace=""
includeTimeMillis=""
locationInfo=""
properties=""
stacktraceAsString="">
<a-Serializer-implementation/>
<KeyValuePair/><!-- multiple occurrences allowed -->
</YamlLayout>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
Whether to include NULL byte as delimiter after each event (optional, default to false). |
|
|
|
If "true", includes the stacktrace of any Throwable in the generated data, defaults to "true". If "true", includes the stacktrace of any Throwable in the generated JSON, defaults to "true". |
|
|
|
Whether to include the timestamp (in addition to the Instant) (optional, default to false). |
|
|
|
||
|
|
||
|
|
Whether to format the stacktrace as a string, and not a nested object (optional, defaults to false). |
AbstractConfigurationAwareLookup
- Class
-
org.apache.logging.log4j.core.lookup.AbstractConfigurationAwareLookup
- Provider
-
org.apache.logging.log4j:log4j-core
StrLookup that is ConfigurationAware.
Handles saving the Configuration.
AbstractLookup
- Class
-
org.apache.logging.log4j.core.lookup.AbstractLookup
- Provider
-
org.apache.logging.log4j:log4j-core
A default lookup for others to extend.
ctx
- Class
-
org.apache.logging.log4j.core.lookup.ContextMapLookup
- Provider
-
org.apache.logging.log4j:log4j-core
Looks up keys from the context.
By default this is the org.apache.logging.log4j.ThreadContext
, but users may configure a custom org.apache.logging.log4j.core.ContextDataInjector
which obtains context data from some other source.
date
- Class
-
org.apache.logging.log4j.core.lookup.DateLookup
- Provider
-
org.apache.logging.log4j:log4j-core
Formats the current date or the date in the LogEvent.
The "key" is used as the format String, following the java. text. SimpleDateFormat date and time pattern strings.
env
- Class
-
org.apache.logging.log4j.core.lookup.EnvironmentLookup
- Provider
-
org.apache.logging.log4j:log4j-core
Looks up keys from environment variables.
event
- Class
-
org.apache.logging.log4j.core.lookup.EventLookup
- Provider
-
org.apache.logging.log4j:log4j-core
Looks up values from the log event.
java
- Class
-
org.apache.logging.log4j.core.lookup.JavaLookup
- Provider
-
org.apache.logging.log4j:log4j-core
Looks up keys related to Java: Java version, JRE version, VM version, and so on.
jvmrunargs
- Class
-
org.apache.logging.log4j.core.lookup.JmxRuntimeInputArgumentsLookup
- Provider
-
org.apache.logging.log4j:log4j-core
Maps JVM input arguments (but not main arguments) using JMX to acquire JVM arguments.
jndi
- Class
-
org.apache.logging.log4j.core.lookup.JndiLookup
- Provider
-
org.apache.logging.log4j:log4j-core
Looks up keys from JNDI resources.
log4j
- Class
-
org.apache.logging.log4j.core.lookup.Log4jLookup
- Provider
-
org.apache.logging.log4j:log4j-core
Lookup properties of Log4j
lower
- Class
-
org.apache.logging.log4j.core.lookup.LowerLookup
- Provider
-
org.apache.logging.log4j:log4j-core
Converts values to lower case.
The passed in "key" should be the value of another lookup.
main
- Class
-
org.apache.logging.log4j.core.lookup.MainMapLookup
- Provider
-
org.apache.logging.log4j:log4j-core
A map-based lookup for main arguments.
See MainMapLookup)[].
map
- Class
-
org.apache.logging.log4j.core.lookup.MapLookup
- Provider
-
org.apache.logging.log4j:log4j-core
A map-based lookup.
marker
- Class
-
org.apache.logging.log4j.core.lookup.MarkerLookup
- Provider
-
org.apache.logging.log4j:log4j-core
Looks-up markers.
bundle
- Class
-
org.apache.logging.log4j.core.lookup.ResourceBundleLookup
- Provider
-
org.apache.logging.log4j:log4j-core
Looks up keys from resource bundles.
StrLookup
- Class
-
org.apache.logging.log4j.core.lookup.StrLookup
- Provider
-
org.apache.logging.log4j:log4j-core
Lookup a String key to a String value.
This class represents the simplest form of a string to string map. It has a benefit over a map in that it can create the result on demand based on the key.
This class comes complete with various factory methods. If these do not suffice, you can subclass and implement your own matcher.
For example, it would be possible to implement a lookup that used the key as a primary key, and looked up the value on demand from the database
sd
- Class
-
org.apache.logging.log4j.core.lookup.StructuredDataLookup
- Provider
-
org.apache.logging.log4j:log4j-core
Looks up keys from org.apache.logging.log4j.core.lookup.org.apache.logging.log4j.message.StructuredDataMessage
log messages.
sys
- Class
-
org.apache.logging.log4j.core.lookup.SystemPropertiesLookup
- Provider
-
org.apache.logging.log4j:log4j-core
Looks up keys from system properties.
upper
- Class
-
org.apache.logging.log4j.core.lookup.UpperLookup
- Provider
-
org.apache.logging.log4j:log4j-core
Converts values to upper case.
The passed in "key" should be the value of another lookup.
Advertiser
- Class
-
org.apache.logging.log4j.core.net.Advertiser
- Provider
-
org.apache.logging.log4j:log4j-core
Facility
- Class
-
org.apache.logging.log4j.core.net.Facility
- Provider
-
org.apache.logging.log4j:log4j-core
The facility codes used by the Syslog system.
Numerical Code |
Facility |
---|---|
Facility |
0 |
kernel messages |
1 |
user-level messages |
2 |
mail system |
3 |
system daemons |
4 |
security/authorization messages |
5 |
messages generated internally by syslogd |
6 |
line printer subsystem |
7 |
network news subsystem |
8 |
UUCP subsystem |
9 |
clock daemon |
10 |
security/authorization messages |
11 |
FTP daemon |
12 |
NTP subsystem |
13 |
log audit |
14 |
log alert |
15 |
clock daemon (note 2) |
16 |
local use 0 (local0) |
17 |
local use 1 (local1) |
18 |
local use 2 (local2) |
19 |
local use 3 (local3) |
20 |
local use 4 (local4) |
21 |
local use 5 (local5) |
22 |
local use 6 (local6) |
23 |
MulticastDns
- Class
-
org.apache.logging.log4j.core.net.MulticastDnsAdvertiser
- Provider
-
org.apache.logging.log4j:log4j-core
Advertise an entity via ZeroConf/MulticastDNS and the JmDNS library.
The length of property names and values must be 255 bytes or less. Entries with names or values larger than 255 bytes will be removed prior to advertisement.
Protocol
- Class
-
org.apache.logging.log4j.core.net.Protocol
- Provider
-
org.apache.logging.log4j:log4j-core
Enumerates the supported protocols.
Rfc1349TrafficClass
- Class
-
org.apache.logging.log4j.core.net.Rfc1349TrafficClass
- Provider
-
org.apache.logging.log4j:log4j-core
Enumerates the RFC 1349 TOS field.
-
IPTOS_LOWCOST (0x02)
-
IPTOS_RELIABILITY (0x04)
-
IPTOS_THROUGHPUT (0x08)
-
IPTOS_LOWDELAY (0x10)
*
SocketAddress
- Class
-
org.apache.logging.log4j.core.net.SocketAddress
- Provider
-
org.apache.logging.log4j:log4j-core
Plugin to hold a hostname and port (socket address).
SocketOptions
- Class
-
org.apache.logging.log4j.core.net.SocketOptions
- Provider
-
org.apache.logging.log4j:log4j-core
Holds all socket options settable via java.net.Socket
methods.
XML snippet
<SocketOptions keepAlive=""
oobInline=""
receiveBufferSize=""
reuseAddress=""
rfc1349TrafficClass=""
sendBufferSize=""
soLinger=""
soTimeout=""
tcpNoDelay=""
trafficClass="">
<SocketPerformancePreferences/>
</SocketOptions>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
See See |
|
|
|
See See |
|
|
|
See See |
|
|
|
See See |
|
|
See See |
||
|
|
See See |
|
|
|
See See |
|
|
|
See See |
|
|
|
See See |
|
|
|
See See |
SocketPerformancePreferences
- Class
-
org.apache.logging.log4j.core.net.SocketPerformancePreferences
- Provider
-
org.apache.logging.log4j:log4j-core
Holds all socket options settable via java.net.Socket#setPerformancePreferences(int,int,int)
.
The java.net.Socket#setPerformancePreferences(int,int,int)
API may not be implemented by a JRE.
AbstractKeyStoreConfiguration
- Class
-
org.apache.logging.log4j.core.net.ssl.AbstractKeyStoreConfiguration
- Provider
-
org.apache.logging.log4j:log4j-core
Configuration of the KeyStore
KeyStore
- Class
-
org.apache.logging.log4j.core.net.ssl.KeyStoreConfiguration
- Provider
-
org.apache.logging.log4j:log4j-core
Configuration of the KeyStore
XML snippet
<KeyStore keyManagerFactoryAlgorithm=""
location=""
password=""
passwordEnvironmentVariable=""
passwordFile=""
type=""/>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
The standard name of the requested algorithm. See the Java Secure Socket Extension Reference Guide for information about these names. |
|
|
|
The location of the KeyStore, a file path, URL or resource. |
|
|
|
The password to access the KeyStore. |
|
|
|
||
|
|
||
|
|
The KeyStore type, null defaults to |
Ssl
- Class
-
org.apache.logging.log4j.core.net.ssl.SslConfiguration
- Provider
-
org.apache.logging.log4j:log4j-core
SSL Configuration
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
The protocol, see SSLContext Algorithms |
StoreConfiguration
- Class
-
org.apache.logging.log4j.core.net.ssl.StoreConfiguration
- Provider
-
org.apache.logging.log4j:log4j-core
TrustStore
- Class
-
org.apache.logging.log4j.core.net.ssl.TrustStoreConfiguration
- Provider
-
org.apache.logging.log4j:log4j-core
Configuration of the TrustStore
XML snippet
<TrustStore location=""
password=""
passwordEnvironmentVariable=""
passwordFile=""
trustManagerFactoryAlgorithm=""
type=""/>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
The location of the KeyStore, a file path, URL or resource. |
|
|
|
The password to access the KeyStore. |
|
|
|
||
|
|
||
|
|
The standard name of the requested trust management algorithm. See the Java Secure Socket Extension Reference Guide for information these names. |
|
|
|
The KeyStore type, null defaults to |
AbstractPatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.AbstractPatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
AbstractPatternConverter is an abstract class that provides the formatting functionality that derived classes need.
Conversion specifiers in a conversion patterns are parsed to individual PatternConverters. Each of which is responsible for converting an object in a converter specific manner.
AbstractStyleNameConverter
- Class
-
org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Style pattern converter.
Adds ANSI color styling to the result of the enclosed pattern.
black
- Class
-
org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter.Black
- Provider
-
org.apache.logging.log4j:log4j-core
Black style pattern converter.
Adds ANSI color styling to the result of the enclosed pattern.
blue
- Class
-
org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter.Blue
- Provider
-
org.apache.logging.log4j:log4j-core
Blue style pattern converter.
Adds ANSI color styling to the result of the enclosed pattern.
cyan
- Class
-
org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter.Cyan
- Provider
-
org.apache.logging.log4j:log4j-core
Cyan style pattern converter.
Adds ANSI color styling to the result of the enclosed pattern.
green
- Class
-
org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter.Green
- Provider
-
org.apache.logging.log4j:log4j-core
Green style pattern converter.
Adds ANSI color styling to the result of the enclosed pattern.
magenta
- Class
-
org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter.Magenta
- Provider
-
org.apache.logging.log4j:log4j-core
Magenta style pattern converter.
Adds ANSI color styling to the result of the enclosed pattern.
red
- Class
-
org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter.Red
- Provider
-
org.apache.logging.log4j:log4j-core
Red style pattern converter.
Adds ANSI color styling to the result of the enclosed pattern.
white
- Class
-
org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter.White
- Provider
-
org.apache.logging.log4j:log4j-core
White style pattern converter.
Adds ANSI color styling to the result of the enclosed pattern.
yellow
- Class
-
org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter.Yellow
- Provider
-
org.apache.logging.log4j:log4j-core
Yellow style pattern converter.
Adds ANSI color styling to the result of the enclosed pattern.
AnsiConverter
- Class
-
org.apache.logging.log4j.core.pattern.AnsiConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Marks classes that implement ANSI escape code conversions.
ArrayPatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.ArrayPatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
PatternConverters implement this interface to accept an array of objects when formatting.
ClassNamePatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.ClassNamePatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Formats the class name of the site of the logging request.
DatePatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.DatePatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Converts and formats the event’s date in a StringBuilder.
encode
- Class
-
org.apache.logging.log4j.core.pattern.EncodingPatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Converter that encodes the output from a pattern using a specified format.
Supported formats include HTML (default) and JSON.
EndOfBatchPatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.EndOfBatchPatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Formats the EndOfBatch.
EqualsBaseReplacementConverter
- Class
-
org.apache.logging.log4j.core.pattern.EqualsBaseReplacementConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Equals pattern converter.
equalsIgnoreCase
- Class
-
org.apache.logging.log4j.core.pattern.EqualsIgnoreCaseReplacementConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Equals ignore case pattern converter.
equals
- Class
-
org.apache.logging.log4j.core.pattern.EqualsReplacementConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Equals pattern converter.
ExtendedThrowablePatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.ExtendedThrowablePatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Outputs the Throwable portion of the LoggingEvent as a full stack trace unless this converter’s option is 'short', where it just outputs the first line of the trace, or if the number of lines to print is explicitly specified.
The extended stack trace will also include the location of where the class was loaded from and the version of the jar if available.
FileDatePatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.FileDatePatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Formats a date by delegating to DatePatternConverter.
The default date pattern for a %d specifier in a file name is different than the %d pattern in pattern layout.
FileLocationPatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.FileLocationPatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Returns the event’s line location information in a StringBuilder.
FullLocationPatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.FullLocationPatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Format the event’s line location information.
highlight
- Class
-
org.apache.logging.log4j.core.pattern.HighlightConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Highlight pattern converter.
Formats the result of a pattern using a color appropriate for the Level in the LogEvent.
For example:
%highlight{%d{ ISO8601 } [%t] %-5level: %msg%n%throwable}
You can define custom colors for each Level:
%highlight{%d{ ISO8601 } [%t] %-5level: %msg%n%throwable}{FATAL=red, ERROR=red, WARN=yellow, INFO=green, DEBUG=cyan,
TRACE=black}
You can use a predefined style:
%highlight{%d{ ISO8601 } [%t] %-5level: %msg%n%throwable}{STYLE=DEFAULT}
The available predefined styles are:
-
Default
-
Log4j
- The same asDefault
-
Logback
You can use whitespace around the comma and equal sign.
The names in values MUST come from the org.apache.logging.log4j.core.pattern.AnsiEscape
enum, case is normalized to upper-case internally.
To disable ANSI output unconditionally, specify an additional option disableAnsi=true
, or to disable ANSI output if no console is detected, specify option noConsoleNoAnsi=true
e.g..
%highlight{%d{ ISO8601 } [%t] %-5level: %msg%n%throwable}{STYLE=DEFAULT, noConsoleNoAnsi=true}
IntegerPatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.IntegerPatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Formats an integer.
LevelPatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.LevelPatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Returns the event’s level in a StringBuilder.
LineLocationPatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.LineLocationPatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Returns the event’s line location information in a StringBuilder.
LineSeparatorPatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.LineSeparatorPatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Formats a line separator.
LogEventPatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.LogEventPatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
LoggingEventPatternConverter is a base class for pattern converters that can format information from instances of LoggingEvent.
LoggerFqcnPatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.LoggerFqcnPatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Formats the Logger FQCN.
LoggerPatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.LoggerPatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Formats a logger name.
MapPatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.MapPatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Able to handle the contents of the LogEvent’s MapMessage and either output the entire contents of the properties in a similar format to the java. util. Hashtable. toString(), or to output the value of a specific key within the Map.
MarkerPatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.MarkerPatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Returns events' full marker string in a StringBuilder.
MarkerNamePatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.MarkerSimpleNamePatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Appends an event’s maker name to a StringBuilder.
maxLength
- Class
-
org.apache.logging.log4j.core.pattern.MaxLengthConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Max length pattern converter.
Limit contained text to a maximum length. On invalid length the default value 100 is used (and an error message is logged). If max length is greater than 20, an abbreviated text will get ellipsis ("…") appended. Example usage (for email subject):
`%maxLen{[AppName, ${hostName}, ${web:contextPath}] %p: %c{1} - %m%notEmpty{ =>%ex{short}}}{160}`
MdcPatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.MdcPatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Able to handle the contents of the LogEvent’s MDC and either output the entire contents of the properties in a similar format to the java. util. Hashtable. toString(), or to output the value of a specific key within the property bundle when this pattern converter has the option set.
MessagePatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.MessagePatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Returns the event’s rendered message in a StringBuilder.
MethodLocationPatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.MethodLocationPatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Returns the event’s line location information in a StringBuilder.
NamePatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.NamePatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Abstract base class for other pattern converters which can return only parts of their name.
NanoTimePatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.NanoTimePatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Converts and formats the event’s nanoTime in a StringBuilder.
NdcPatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.NdcPatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Returns the event’s NDC in a StringBuilder.
PatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.PatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Interface that all PatternConverters must implement.
ProcessIdPatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.ProcessIdPatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Replace
- Class
-
org.apache.logging.log4j.core.pattern.RegexReplacement
- Provider
-
org.apache.logging.log4j:log4j-core
Replace tokens in the LogEvent message.
replace
- Class
-
org.apache.logging.log4j.core.pattern.RegexReplacementConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Replacement pattern converter.
RelativeTimePatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.RelativeTimePatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Returns the relative time in milliseconds since JVM Startup.
repeat
- Class
-
org.apache.logging.log4j.core.pattern.RepeatPatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Equals pattern converter.
RootThrowablePatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.RootThrowablePatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Outputs the Throwable portion of the LoggingEvent as a full stack trace unless this converter’s option is 'short', where it just outputs the first line of the trace, or if the number of lines to print is explicitly specified.
The extended stack trace will also include the location of where the class was loaded from and the version of the jar if available.
SequenceNumberPatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.SequenceNumberPatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Formats the event sequence number.
style
- Class
-
org.apache.logging.log4j.core.pattern.StyleConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Style pattern converter.
Adds ANSI color styling to the result of the enclosed pattern.
To disable ANSI output unconditionally, specify an additional option disableAnsi=true
, or to disable ANSI output if no console is detected, specify option noConsoleNoAnsi=true
.
ThreadIdPatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.ThreadIdPatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Formats the event thread ID.
ThreadPatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.ThreadNamePatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Formats the event thread name.
ThreadPriorityPatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.ThreadPriorityPatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Formats the event thread priority.
ThrowablePatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.ThrowablePatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Outputs the Throwable portion of the LoggingEvent as a full stack trace unless this converter’s option is 'short', where it just outputs the first line of the trace, or if the number of lines to print is explicitly specified.
UuidPatternConverter
- Class
-
org.apache.logging.log4j.core.pattern.UuidPatternConverter
- Provider
-
org.apache.logging.log4j:log4j-core
Formats the event sequence number.
notEmpty
- Class
-
org.apache.logging.log4j.core.pattern.VariablesNotEmptyReplacementConverter
- Provider
-
org.apache.logging.log4j:log4j-core
VariablesNotEmpty pattern converter.
AbstractScript
- Class
-
org.apache.logging.log4j.core.script.AbstractScript
- Provider
-
org.apache.logging.log4j:log4j-core
Container for the language and body of a script.
Script
- Class
-
org.apache.logging.log4j.core.script.Script
- Provider
-
org.apache.logging.log4j:log4j-core
Container for the language and body of a script.
ScriptFile
- Class
-
org.apache.logging.log4j.core.script.ScriptFile
- Provider
-
org.apache.logging.log4j:log4j-core
Container for the language and body of a script file along with the file location.
ScriptRef
- Class
-
org.apache.logging.log4j.core.script.ScriptRef
- Provider
-
org.apache.logging.log4j:log4j-core
Contains a reference to a script defined elsewhere in the configuration.
AbstractWatcher
- Class
-
org.apache.logging.log4j.core.util.AbstractWatcher
- Provider
-
org.apache.logging.log4j:log4j-core
Watcher for configuration files.
Causes a reconfiguration when a file changes.
Builder
- Class
-
org.apache.logging.log4j.core.util.Builder
- Provider
-
org.apache.logging.log4j:log4j-core
A type of builder that can be used to configure and create a instances using a Java DSL instead of through a configuration file.
These builders are primarily useful for internal code and unit tests, but they can technically be used as a verbose alternative to configuration files.
When creating plugin builders, it is customary to create the builder class as a public static inner class called Builder
. For instance, the builder class for PatternLayout would be PatternLayout. Builder
.
KeyValuePair
- Class
-
org.apache.logging.log4j.core.util.KeyValuePair
- Provider
-
org.apache.logging.log4j:log4j-core
Key/Value pair configuration item.
log4j-couchdb
NoSqlProvider
- Class
-
org.apache.logging.log4j.core.appender.nosql.NoSqlProvider
- Provider
-
org.apache.logging.log4j:log4j-couchdb
CouchDB
- Class
-
org.apache.logging.log4j.couchdb.CouchDbProvider
- Provider
-
org.apache.logging.log4j:log4j-couchdb
The Apache CouchDB implementation of NoSqlProvider.
XML snippet
<CouchDB databaseName=""
factoryClassName=""
factoryMethodName=""
password=""
port=""
protocol=""
server=""
username=""/>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
The name of the database to which log event documents will be written. |
|
|
|
A fully qualified class name containing a static factory method capable of returning a |
|
|
|
The name of the public static factory method belonging to the aforementioned factory class. |
|
|
|
The password to authenticate against the MongoDB server with, mutually exclusive with |
|
|
|
The port that CouchDB is listening on, defaults to 80 if |
|
|
|
Either "http" or "https," defaults to "http" and mutually exclusive with |
|
|
|
The host name of the CouchDB server, defaults to localhost and mutually exclusive with |
|
|
|
The username to authenticate against the MongoDB server with, mutually exclusive with |
log4j-jdbc-dbcp2
PoolableConnectionFactory
- Class
-
org.apache.logging.log4j.core.appender.db.jdbc.PoolableConnectionFactoryConfig
- Provider
-
org.apache.logging.log4j:log4j-jdbc-dbcp2
Configures an Apache Commons DBCP org.apache.commons.dbcp2.PoolableConnectionFactory
.
XML snippet
<PoolableConnectionFactory autoCommitOnReturn=""
cacheState=""
defaultAutoCommit=""
defaultCatalog=""
defaultQueryTimeoutSeconds=""
defaultReadOnly=""
defaultTransactionIsolation=""
fastFailValidation=""
maxConnLifetimeMillis=""
maxOpenPreparedStatements=""
poolStatements=""
rollbackOnReturn=""
validationQuery=""
validationQueryTimeoutSeconds="">
<a-String-implementation/><!-- multiple occurrences allowed -->
</PoolableConnectionFactory>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
PoolingDriver
- Class
-
org.apache.logging.log4j.core.appender.db.jdbc.PoolingDriverConnectionSource
- Provider
-
org.apache.logging.log4j:log4j-jdbc-dbcp2
A ConnectionSource that uses a JDBC connection string, a user name, and a password to call java.sql.DriverManager#getConnection(String,String,String)
.
The connections are served from an Apache Commons DBCP pooling driver.
XML snippet
<PoolingDriver connectionString=""
driverClassName=""
password=""
poolName=""
userName="">
<PoolableConnectionFactory/>
<Property/><!-- multiple occurrences allowed -->
</PoolingDriver>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
||
|
|
||
|
|
||
|
|
||
|
|
log4j-jpa
JPA
- Class
-
org.apache.logging.log4j.core.appender.db.jpa.JpaAppender
- Provider
-
org.apache.logging.log4j:log4j-jpa
This Appender writes logging events to a relational database using the Java Persistence API.
It requires a pre-configured JPA persistence unit and a concrete implementation of the abstract org.apache.logging.log4j.core.appender.db.jpa.AbstractLogEventWrapperEntity
class decorated with JPA annotations.
XML snippet
<JPA bufferSize=""
entityClassName=""
ignoreExceptions=""
name=""
persistenceUnitName="">
<a-Filter-implementation/>
</JPA>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
If an integer greater than 0, this causes the appender to buffer log events and flush whenever the buffer reaches this size. |
|
|
|
The fully qualified name of the concrete |
|
|
|
If |
|
|
|
The name of the appender. |
|
|
|
The name of the JPA persistence unit that should be used for persisting log events. |
log4j-layout-template-json
JsonTemplateLayout
- Class
-
org.apache.logging.log4j.layout.template.json.JsonTemplateLayout
- Provider
-
org.apache.logging.log4j:log4j-layout-template-json
XML snippet
<JsonTemplateLayout charset=""
eventDelimiter=""
eventTemplate=""
eventTemplateRootObjectKey=""
eventTemplateUri=""
locationInfoEnabled=""
maxStringLength=""
nullEventDelimiterEnabled=""
recyclerFactory=""
stackTraceElementTemplate=""
stackTraceElementTemplateUri=""
stackTraceEnabled=""
truncatedStringSuffix="">
<EventTemplateAdditionalField/><!-- multiple occurrences allowed -->
</JsonTemplateLayout>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|||
|
|
||
|
|
||
|
|
||
|
|
EventTemplateAdditionalField
- Class
-
org.apache.logging.log4j.layout.template.json.JsonTemplateLayout.EventTemplateAdditionalField
- Provider
-
org.apache.logging.log4j:log4j-layout-template-json
Format
- Class
-
org.apache.logging.log4j.layout.template.json.JsonTemplateLayout.EventTemplateAdditionalField.Format
- Provider
-
org.apache.logging.log4j:log4j-layout-template-json
CaseConverterResolverFactory
- Class
-
org.apache.logging.log4j.layout.template.json.resolver.CaseConverterResolverFactory
- Provider
-
org.apache.logging.log4j:log4j-layout-template-json
org.apache.logging.log4j.layout.template.json.resolver.CaseConverterResolver
factory.
CounterResolverFactory
- Class
-
org.apache.logging.log4j.layout.template.json.resolver.CounterResolverFactory
- Provider
-
org.apache.logging.log4j:log4j-layout-template-json
org.apache.logging.log4j.layout.template.json.resolver.CounterResolver
factory.
EndOfBatchResolverFactory
- Class
-
org.apache.logging.log4j.layout.template.json.resolver.EndOfBatchResolverFactory
- Provider
-
org.apache.logging.log4j:log4j-layout-template-json
org.apache.logging.log4j.layout.template.json.resolver.EndOfBatchResolver
factory.
EventAdditionalFieldInterceptor
- Class
-
org.apache.logging.log4j.layout.template.json.resolver.EventAdditionalFieldInterceptor
- Provider
-
org.apache.logging.log4j:log4j-layout-template-json
Interceptor to add additional fields after event template read.
EventResolverFactory
- Class
-
org.apache.logging.log4j.layout.template.json.resolver.EventResolverFactory
- Provider
-
org.apache.logging.log4j:log4j-layout-template-json
TemplateResolverFactory specialized for org.apache.logging.log4j.core.LogEvent
s.
EventResolverInterceptor
- Class
-
org.apache.logging.log4j.layout.template.json.resolver.EventResolverInterceptor
- Provider
-
org.apache.logging.log4j:log4j-layout-template-json
TemplateResolverInterceptor specialized for org.apache.logging.log4j.core.LogEvent
s.
EventRootObjectKeyInterceptor
- Class
-
org.apache.logging.log4j.layout.template.json.resolver.EventRootObjectKeyInterceptor
- Provider
-
org.apache.logging.log4j:log4j-layout-template-json
Interceptor to add a root object key to the event template.
ExceptionResolverFactory
- Class
-
org.apache.logging.log4j.layout.template.json.resolver.ExceptionResolverFactory
- Provider
-
org.apache.logging.log4j:log4j-layout-template-json
org.apache.logging.log4j.layout.template.json.resolver.ExceptionResolver
factory.
ExceptionRootCauseResolverFactory
- Class
-
org.apache.logging.log4j.layout.template.json.resolver.ExceptionRootCauseResolverFactory
- Provider
-
org.apache.logging.log4j:log4j-layout-template-json
org.apache.logging.log4j.layout.template.json.resolver.ExceptionRootCauseResolver
factory.
LevelResolverFactory
- Class
-
org.apache.logging.log4j.layout.template.json.resolver.LevelResolverFactory
- Provider
-
org.apache.logging.log4j:log4j-layout-template-json
org.apache.logging.log4j.layout.template.json.resolver.LevelResolver
factory.
LoggerResolverFactory
- Class
-
org.apache.logging.log4j.layout.template.json.resolver.LoggerResolverFactory
- Provider
-
org.apache.logging.log4j:log4j-layout-template-json
org.apache.logging.log4j.layout.template.json.resolver.LoggerResolver
factory.
MainMapResolverFactory
- Class
-
org.apache.logging.log4j.layout.template.json.resolver.MainMapResolverFactory
- Provider
-
org.apache.logging.log4j:log4j-layout-template-json
org.apache.logging.log4j.layout.template.json.resolver.MainMapResolver
factory.
MapResolverFactory
- Class
-
org.apache.logging.log4j.layout.template.json.resolver.MapResolverFactory
- Provider
-
org.apache.logging.log4j:log4j-layout-template-json
org.apache.logging.log4j.layout.template.json.resolver.MapResolver
factory.
MarkerResolverFactory
- Class
-
org.apache.logging.log4j.layout.template.json.resolver.MarkerResolverFactory
- Provider
-
org.apache.logging.log4j:log4j-layout-template-json
org.apache.logging.log4j.layout.template.json.resolver.MarkerResolver
factory.
MessageParameterResolverFactory
- Class
-
org.apache.logging.log4j.layout.template.json.resolver.MessageParameterResolverFactory
- Provider
-
org.apache.logging.log4j:log4j-layout-template-json
org.apache.logging.log4j.layout.template.json.resolver.MessageParameterResolver
factory.
MessageResolverFactory
- Class
-
org.apache.logging.log4j.layout.template.json.resolver.MessageResolverFactory
- Provider
-
org.apache.logging.log4j:log4j-layout-template-json
A org.apache.logging.log4j.layout.template.json.resolver.MessageResolver
factory.
PatternResolverFactory
- Class
-
org.apache.logging.log4j.layout.template.json.resolver.PatternResolverFactory
- Provider
-
org.apache.logging.log4j:log4j-layout-template-json
org.apache.logging.log4j.layout.template.json.resolver.PatternResolver
factory.
SourceResolverFactory
- Class
-
org.apache.logging.log4j.layout.template.json.resolver.SourceResolverFactory
- Provider
-
org.apache.logging.log4j:log4j-layout-template-json
org.apache.logging.log4j.layout.template.json.resolver.SourceResolver
factory.
TemplateResolverFactory
- Class
-
org.apache.logging.log4j.layout.template.json.resolver.TemplateResolverFactory
- Provider
-
org.apache.logging.log4j:log4j-layout-template-json
org.apache.logging.log4j.layout.template.json.resolver.TemplateResolver
factory.
TemplateResolverInterceptor
- Class
-
org.apache.logging.log4j.layout.template.json.resolver.TemplateResolverInterceptor
- Provider
-
org.apache.logging.log4j:log4j-layout-template-json
Main org.apache.logging.log4j.layout.template.json.resolver.TemplateResolver
compilation interception interface.
ThreadContextDataResolverFactory
- Class
-
org.apache.logging.log4j.layout.template.json.resolver.ThreadContextDataResolverFactory
- Provider
-
org.apache.logging.log4j:log4j-layout-template-json
org.apache.logging.log4j.layout.template.json.resolver.ThreadContextDataResolver
factory.
ThreadContextStackResolverFactory
- Class
-
org.apache.logging.log4j.layout.template.json.resolver.ThreadContextStackResolverFactory
- Provider
-
org.apache.logging.log4j:log4j-layout-template-json
org.apache.logging.log4j.layout.template.json.resolver.ThreadContextStackResolver
factory.
ThreadResolverFactory
- Class
-
org.apache.logging.log4j.layout.template.json.resolver.ThreadResolverFactory
- Provider
-
org.apache.logging.log4j:log4j-layout-template-json
org.apache.logging.log4j.layout.template.json.resolver.ThreadResolver
factory.
TimestampResolverFactory
- Class
-
org.apache.logging.log4j.layout.template.json.resolver.TimestampResolverFactory
- Provider
-
org.apache.logging.log4j:log4j-layout-template-json
org.apache.logging.log4j.layout.template.json.resolver.TimestampResolver
factory.
RecyclerFactory
- Class
-
org.apache.logging.log4j.layout.template.json.util.RecyclerFactory
- Provider
-
org.apache.logging.log4j:log4j-layout-template-json
RecyclerFactoryConverter
- Class
-
org.apache.logging.log4j.layout.template.json.util.RecyclerFactoryConverter
- Provider
-
org.apache.logging.log4j:log4j-layout-template-json
The default string (i.e., recycler factory spec) to RecyclerFactory type converter.
log4j-mongodb
MongoDb
- Class
-
org.apache.logging.log4j.mongodb.MongoDbProvider
- Provider
-
org.apache.logging.log4j:log4j-mongodb
Delegates to MongoDb4Provider under the name MongoDb
.
XML snippet
<MongoDb capped=""
collectionSize=""
connection="">
<a-Filter-implementation/>
<Property/><!-- multiple occurrences allowed -->
</MongoDb>
log4j-mongodb4
MongoDb4
- Class
-
org.apache.logging.log4j.mongodb4.MongoDb4Provider
- Provider
-
org.apache.logging.log4j:log4j-mongodb4
The MongoDB implementation of NoSqlProvider using the MongoDB driver version 4 API.
XML snippet
<MongoDb4 capped=""
collectionSize=""
connection="">
<a-Filter-implementation/>
<Property/><!-- multiple occurrences allowed -->
</MongoDb4>
log4j-spring-boot
LoggerContextAware
- Class
-
org.apache.logging.log4j.core.config.LoggerContextAware
- Provider
-
org.apache.logging.log4j:log4j-spring-boot
spring
- Class
-
org.apache.logging.log4j.spring.boot.SpringLookup
- Provider
-
org.apache.logging.log4j:log4j-spring-boot
Lookup for Spring properties.
log4j-web
Servlet
- Class
-
org.apache.logging.log4j.web.appender.ServletAppender
- Provider
-
org.apache.logging.log4j:log4j-web
Logs using the ServletContext’s log method
XML snippet
<Servlet ignoreExceptions=""
logThrowables=""
name="">
<a-Filter-implementation/>
<a-Layout-implementation/>
<Property/><!-- multiple occurrences allowed -->
</Servlet>
Attributes
Optional attributes are denoted by ?
-suffixed types.
Name | Type | Default | Description |
---|---|---|---|
|
|
||
|
|
Logs with Logs with |
|
|
|