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.

Shortcuts

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.

Known implementations

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.

Known implementations

Parser

Class : org.apache.log4j.builders.Parser

Provider : org.apache.logging.log4j:log4j-1.2-api

Parses DOM and properties.

Known implementations

AppenderBuilder

Class : org.apache.log4j.builders.appender.AppenderBuilder

Provider : org.apache.logging.log4j:log4j-1.2-api

Define an Appender Builder.

Known implementations

org.apache.log4j.AsyncAppender

Class : org.apache.log4j.builders.appender.AsyncAppenderBuilder

Provider : org.apache.logging.log4j:log4j-1.2-api

Build an Async Appender

XML snippet
<org.apache.log4j.AsyncAppender/>

org.apache.log4j.ConsoleAppender

Class : org.apache.log4j.builders.appender.ConsoleAppenderBuilder

Provider : org.apache.logging.log4j:log4j-1.2-api

Build a Console Appender

XML snippet
<org.apache.log4j.ConsoleAppender/>

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

XML snippet
<org.apache.log4j.DailyRollingFileAppender/>

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

XML snippet
<org.apache.log4j.rolling.RollingFileAppender/>

org.apache.log4j.FileAppender

Class : org.apache.log4j.builders.appender.FileAppenderBuilder

Provider : org.apache.logging.log4j:log4j-1.2-api

Build a File Appender

XML snippet
<org.apache.log4j.FileAppender/>

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

XML snippet
<org.apache.log4j.varia.NullAppender/>

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

XML snippet
<org.apache.log4j.rewrite.RewriteAppender/>

org.apache.log4j.RollingFileAppender

Class : org.apache.log4j.builders.appender.RollingFileAppenderBuilder

Provider : org.apache.logging.log4j:log4j-1.2-api

Build a File Appender

XML snippet
<org.apache.log4j.RollingFileAppender/>

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

XML snippet
<org.apache.log4j.net.SocketAppender/>

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

XML snippet
<org.apache.log4j.net.SyslogAppender/>

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

XML snippet
<org.apache.log4j.varia.DenyAllFilter/>

FilterBuilder

Class : org.apache.log4j.builders.filter.FilterBuilder

Provider : org.apache.logging.log4j:log4j-1.2-api

Define a Filter Builder.

Known implementations

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.

XML snippet
<org.apache.log4j.varia.LevelMatchFilter/>

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.

In this class, order of Level is log4j1 way, i.e., Level and Level have minimum and maximum order, respectively. (see: LOG4J2-2315)

XML snippet
<org.apache.log4j.varia.LevelRangeFilter/>

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.

XML snippet
<org.apache.log4j.varia.StringMatchFilter/>

org.apache.log4j.HTMLLayout

Class : org.apache.log4j.builders.layout.HtmlLayoutBuilder

Provider : org.apache.logging.log4j:log4j-1.2-api

Build a Pattern Layout

XML snippet
<org.apache.log4j.HTMLLayout/>

LayoutBuilder

Class : org.apache.log4j.builders.layout.LayoutBuilder

Provider : org.apache.logging.log4j:log4j-1.2-api

Define a Layout Builder.

Known implementations

org.apache.log4j.PatternLayout

Class : org.apache.log4j.builders.layout.PatternLayoutBuilder

Provider : org.apache.logging.log4j:log4j-1.2-api

Build a Pattern Layout

XML snippet
<org.apache.log4j.PatternLayout/>

org.apache.log4j.SimpleLayout

Class : org.apache.log4j.builders.layout.SimpleLayoutBuilder

Provider : org.apache.logging.log4j:log4j-1.2-api

Build a Pattern Layout

XML snippet
<org.apache.log4j.SimpleLayout/>

org.apache.log4j.TTCCLayout

Class : org.apache.log4j.builders.layout.TTCCLayoutBuilder

Provider : org.apache.logging.log4j:log4j-1.2-api

Build a Pattern Layout

XML snippet
<org.apache.log4j.TTCCLayout/>

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

XML snippet
<org.apache.log4j.xml.XMLLayout/>

org.apache.log4j.rolling.CompositeTriggeringPolicy

Class : org.apache.log4j.builders.rolling.CompositeTriggeringPolicyBuilder

Provider : org.apache.logging.log4j:log4j-1.2-api

XML snippet
<org.apache.log4j.rolling.CompositeTriggeringPolicy/>

org.apache.log4j.rolling.SizeBasedTriggeringPolicy

Class : org.apache.log4j.builders.rolling.SizeBasedTriggeringPolicyBuilder

Provider : org.apache.logging.log4j:log4j-1.2-api

XML snippet
<org.apache.log4j.rolling.SizeBasedTriggeringPolicy/>

org.apache.log4j.rolling.TimeBasedRollingPolicy

Class : org.apache.log4j.builders.rolling.TimeBasedRollingPolicyBuilder

Provider : org.apache.logging.log4j:log4j-1.2-api

XML snippet
<org.apache.log4j.rolling.TimeBasedRollingPolicy/>

TriggeringPolicyBuilder

Class : org.apache.log4j.builders.rolling.TriggeringPolicyBuilder

Provider : org.apache.logging.log4j:log4j-1.2-api

Known implementations

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.

XML snippet
<Log4j1PropertiesConfigurationFactory/>

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
charset Charset?
facility Facility?
facilityPrinting boolean?
footer String?
header String?
Nested components

Optional components are denoted by ?-suffixed types.

Tag Type Description
Layout?
Serializer?

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.

XML snippet
<Log4j1XmlLayout locationInfo=""
                 properties=""/>
Attributes

Optional attributes are denoted by ?-suffixed types.

Name Type Default Description
locationInfo boolean?
properties boolean?

Log4j1LevelPatternConverter

Class : org.apache.log4j.pattern.Log4j1LevelPatternConverter

Provider : org.apache.logging.log4j:log4j-1.2-api

Outputs the Log4j 1.x level name.

XML snippet
<Log4j1LevelPatternConverter/>

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.

XML snippet
<Log4j1MdcPatternConverter/>

Log4j1NdcPatternConverter

Class : org.apache.log4j.pattern.Log4j1NdcPatternConverter

Provider : org.apache.logging.log4j:log4j-1.2-api

Returns the event’s NDC in a StringBuilder.

XML snippet
<Log4j1NdcPatternConverter/>

Log4j1XmlConfigurationFactory

Class : org.apache.log4j.xml.XmlConfigurationFactory

Provider : org.apache.logging.log4j:log4j-1.2-api

Constructs a Configuration usable in Log4j 2 from a Log4j 1 configuration file.

XML snippet
<Log4j1XmlConfigurationFactory/>

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
batched boolean? Whether or not to use batch statements when inserting records.
batchType Type? If batch statements are enabled, use this type of batch statement.
bufferSize int? Number of LogEvents to buffer before writing. Can be used with or without batch statements.
clusterName String
ignoreExceptions boolean?
keyspace String
name String
password String?
table String
useClockForTimestampGenerator boolean? Override the default TimestampGenerator with one based on the configured org.apache.logging.log4j.core.util.Clock.
username String?
useTls boolean?
Nested components

Optional components are denoted by ?-suffixed types.

Tag Type Description
ColumnMapping ColumnMapping List of column mappings to convert a LogEvent into a database row.
Property Property?
Filter?
Layout?
SocketAddress SocketAddress 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

QuoteMode

Class : org.apache.commons.csv.QuoteMode

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.

Known implementations

Appender

Class : org.apache.logging.log4j.core.Appender

Provider : org.apache.logging.log4j:log4j-core

Appends org.apache.logging.log4j.core.LogEvents.

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.

Known implementations

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.

Known implementations

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, like byte[]
  • 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.

Known implementations

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.

Known implementations

(本文超出站点单文档体积上限,已截断)