blob: fd17c85c1f594a5d11bf78708890d68114e010a7 [file] [log] [blame]
<!DOCTYPE html>
<!--
| Generated by Apache Maven Doxia Site Renderer 1.9.1 from src/site/xdoc/manual/plugins.xml at 2020-04-25
| Rendered using Apache Maven Fluido Skin 1.8
-->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="generator" content="Apache Maven Doxia Site Renderer 1.9.1" />
<meta name="author" content="Ralph Goers" />
<meta name="author" content="Matt Sicker" />
<title>Log4j &#x2013; Log4j 2 Plugins</title>
<link rel="stylesheet" href="../css/apache-maven-fluido-1.8.min.css" />
<link rel="stylesheet" href="../css/site.css" />
<link rel="stylesheet" href="../css/print.css" media="print" />
<script src="../js/apache-maven-fluido-1.8.min.js"></script>
</head>
<body class="topBarDisabled">
<div class="container-fluid">
<header>
<div id="banner">
<div class="pull-left"><a href="http://logging.apache.org" id="bannerLeft"><img src="../images/ls-logo.jpg" alt=""/></a></div>
<div class="pull-right"><a href="http://logging.apache.org/log4j/2.x" id="bannerRight"><img src="../images/logo.png" alt=""/></a></div>
<div class="clear"><hr/></div>
</div>
<div id="breadcrumbs">
<ul class="breadcrumb">
<li id="publishDate">Last Published: 2020-04-25<span class="divider">|</span>
</li>
<li id="projectVersion">Version: 2.13.2</li>
<li class="pull-right"><span class="divider">|</span>
<a href="https://github.com/apache/logging-log4j2" class="externalLink" title="GitHub">GitHub</a></li>
<li class="pull-right"><span class="divider">|</span>
<a href="https://analysis.apache.org/dashboard/index/org.apache.logging.log4j:log4j" class="externalLink" title="Sonar">Sonar</a></li>
<li class="pull-right"><span class="divider">|</span>
<a href="../../../" title="Logging Services">Logging Services</a></li>
<li class="pull-right"><span class="divider">|</span>
<a href="https://www.apache.org/" class="externalLink" title="Apache">Apache</a></li>
<li class="pull-right"><a href="https://cwiki.apache.org/confluence/display/LOGGING/Log4j" class="externalLink" title="Logging Wiki">Logging Wiki</a></li>
</ul>
</div>
</header>
<div class="row-fluid">
<header id="leftColumn" class="span2">
<nav class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header"><img class="imageLink" src="../img/glyphicons/home.png" alt="Apache Log4j™ 2" border="0"/> Apache Log4j™ 2</li>
<li><a href="../index.html" title="About"><span class="none"></span>About</a></li>
<li><a href="../download.html" title="Download"><span class="none"></span>Download</a></li>
<li><a href="../javadoc.html" title="Javadoc"><span class="icon-chevron-right"></span>Javadoc</a></li>
<li><a href="../maven-artifacts.html" title="Maven, Ivy, Gradle Artifacts"><span class="icon-chevron-right"></span>Maven, Ivy, Gradle Artifacts</a></li>
<li><a href="../runtime-dependencies.html" title="Runtime Dependencies"><span class="none"></span>Runtime Dependencies</a></li>
<li><a href="../changelog.html" title="Changelog"><span class="none"></span>Changelog</a></li>
<li><a href="../faq.html" title="FAQ"><span class="none"></span>FAQ</a></li>
<li><a href="../performance.html" title="Performance"><span class="icon-chevron-right"></span>Performance</a></li>
<li><a href="../articles.html" title="Articles and Tutorials"><span class="none"></span>Articles and Tutorials</a></li>
<li><a href="../security.html" title="Security"><span class="none"></span>Security</a></li>
<li><a href="../support.html" title="Support"><span class="none"></span>Support</a></li>
<li><a href="../thanks.html" title="Thanks"><span class="none"></span>Thanks</a></li>
<li class="nav-header"><img class="imageLink" src="../img/glyphicons/pencil.png" alt="For Contributors" border="0"/> For Contributors</li>
<li><a href="../build.html" title="Building Log4j from Source"><span class="none"></span>Building Log4j from Source</a></li>
<li><a href="../guidelines.html" title="Guidelines"><span class="none"></span>Guidelines</a></li>
<li><a href="../javastyle.html" title="Style Guide"><span class="none"></span>Style Guide</a></li>
<li class="nav-header"><img class="imageLink" src="../img/glyphicons/book.png" alt="Manual" border="0"/> Manual</li>
<li><a href="../manual/index.html" title="Introduction"><span class="none"></span>Introduction</a></li>
<li><a href="../manual/architecture.html" title="Architecture"><span class="none"></span>Architecture</a></li>
<li><a href="../manual/compatibility.html" title="Log4j 1.x Compatibility"><span class="none"></span>Log4j 1.x Compatibility</a></li>
<li><a href="../manual/migration.html" title="Log4j 1.x Migration"><span class="none"></span>Log4j 1.x Migration</a></li>
<li><a href="../manual/api.html" title="Java API"><span class="icon-chevron-right"></span>Java API</a></li>
<li><a href="../manual/scala-api.html" title="Scala API"><span class="none"></span>Scala API</a></li>
<li><a href="../manual/configuration.html" title="Configuration"><span class="icon-chevron-right"></span>Configuration</a></li>
<li><a href="../manual/usage.html" title="Usage"><span class="icon-chevron-right"></span>Usage</a></li>
<li><a href="../manual/webapp.html" title="Web Applications and JSPs"><span class="icon-chevron-right"></span>Web Applications and JSPs</a></li>
<li><a href="../manual/lookups.html" title="Lookups"><span class="icon-chevron-right"></span>Lookups</a></li>
<li><a href="../manual/appenders.html" title="Appenders"><span class="icon-chevron-right"></span>Appenders</a></li>
<li><a href="../manual/layouts.html" title="Layouts"><span class="icon-chevron-right"></span>Layouts</a></li>
<li><a href="../manual/filters.html" title="Filters"><span class="icon-chevron-right"></span>Filters</a></li>
<li><a href="../manual/async.html" title="Async Loggers"><span class="icon-chevron-right"></span>Async Loggers</a></li>
<li><a href="../manual/garbagefree.html" title="Garbage-free Logging"><span class="icon-chevron-right"></span>Garbage-free Logging</a></li>
<li><a href="../manual/jmx.html" title="JMX"><span class="none"></span>JMX</a></li>
<li><a href="../manual/logsep.html" title="Logging Separation"><span class="none"></span>Logging Separation</a></li>
<li><a href="../manual/extending.html" title="Extending Log4j"><span class="icon-chevron-right"></span>Extending Log4j</a></li>
<li class="active"><a href="#"><span class="icon-chevron-down"></span>Plugins</a>
<ul class="nav nav-list">
<li><a href="../manual/plugins.html#Core" title="Core"><span class="none"></span>Core</a></li>
<li><a href="../manual/plugins.html#Converters" title="Converters"><span class="none"></span>Converters</a></li>
<li><a href="../manual/plugins.html#KeyProviders" title="Key Providers"><span class="none"></span>Key Providers</a></li>
<li><a href="../manual/plugins.html#Lookups" title="Lookups"><span class="none"></span>Lookups</a></li>
<li><a href="../manual/plugins.html#TypeConverters" title="Type Converters"><span class="none"></span>Type Converters</a></li>
<li><a href="../manual/plugins.html#DeveloperNotes" title="Developer Notes"><span class="none"></span>Developer Notes</a></li>
</ul></li>
<li><a href="../manual/customconfig.html" title="Programmatic Log4j Configuration"><span class="icon-chevron-right"></span>Programmatic Log4j Configuration</a></li>
<li><a href="../manual/customloglevels.html" title="Custom Log Levels"><span class="icon-chevron-right"></span>Custom Log Levels</a></li>
<li class="nav-header"><img class="imageLink" src="../img/glyphicons/tag.png" alt="Related Projects" border="0"/> Related Projects</li>
<li><a href="http://logging.apache.org/log4j/scala/index.html" class="externalLink" title="Log4j-Scala"><span class="none"></span>Log4j-Scala</a></li>
<li class="nav-header"><img class="imageLink" src="../img/glyphicons/link.png" alt="Legacy Sites" border="0"/> Legacy Sites</li>
<li><a href="http://logging.apache.org/log4j/1.2/" class="externalLink" title="Log4j 1.2 - End of Life"><span class="none"></span>Log4j 1.2 - End of Life</a></li>
<li><a href="http://logging.apache.org/log4j/log4j-2.3/" class="externalLink" title="Log4j 2.3 - Java 6"><span class="none"></span>Log4j 2.3 - Java 6</a></li>
<li><a href="http://logging.apache.org/log4j/log4j-2.12.1" class="externalLink" title="Log4j 2.12.1 - Java 7"><span class="none"></span>Log4j 2.12.1 - Java 7</a></li>
<li class="nav-header"><img class="imageLink" src="../img/glyphicons/cog.png" alt="Components" border="0"/> Components</li>
<li><a href="../log4j-api/index.html" title="API"><span class="none"></span>API</a></li>
<li><a href="../log4j-core/index.html" title="Implementation"><span class="none"></span>Implementation</a></li>
<li><a href="../log4j-jcl/index.html" title="Commons Logging Bridge"><span class="none"></span>Commons Logging Bridge</a></li>
<li><a href="../log4j-1.2-api/index.html" title="Log4j 1.2 API"><span class="none"></span>Log4j 1.2 API</a></li>
<li><a href="../log4j-slf4j-impl/index.html" title="SLF4J Binding"><span class="none"></span>SLF4J Binding</a></li>
<li><a href="../log4j-jul/index.html" title="JUL Adapter"><span class="none"></span>JUL Adapter</a></li>
<li><a href="../log4j-jpl/index.html" title="JDK Platform Logger"><span class="none"></span>JDK Platform Logger</a></li>
<li><a href="../log4j-to-slf4j/index.html" title="Log4j 2 to SLF4J Adapter"><span class="none"></span>Log4j 2 to SLF4J Adapter</a></li>
<li><a href="../log4j-flume-ng/index.html" title="Apache Flume Appender"><span class="none"></span>Apache Flume Appender</a></li>
<li><a href="../log4j-taglib/index.html" title="Log4j Tag Library"><span class="none"></span>Log4j Tag Library</a></li>
<li><a href="../log4j-jmx-gui/index.html" title="Log4j JMX GUI"><span class="none"></span>Log4j JMX GUI</a></li>
<li><a href="../log4j-web/index.html" title="Log4j Web Application Support"><span class="none"></span>Log4j Web Application Support</a></li>
<li><a href="../log4j-appserver/index.html" title="Log4j Application Server Integration"><span class="none"></span>Log4j Application Server Integration</a></li>
<li><a href="../log4j-couchdb/index.html" title="Log4j CouchDB appender"><span class="none"></span>Log4j CouchDB appender</a></li>
<li><a href="../log4j-mongodb2/index.html" title="Log4j MongoDB2 appender"><span class="none"></span>Log4j MongoDB2 appender</a></li>
<li><a href="../log4j-mongodb3/index.html" title="Log4j MongoDB3 appender"><span class="none"></span>Log4j MongoDB3 appender</a></li>
<li><a href="../log4j-cassandra/index.html" title="Log4j Cassandra appender"><span class="none"></span>Log4j Cassandra appender</a></li>
<li><a href="../log4j-iostreams/index.html" title="Log4j IO Streams"><span class="none"></span>Log4j IO Streams</a></li>
<li><a href="../log4j-liquibase/index.html" title="Log4j Liquibase Binding"><span class="none"></span>Log4j Liquibase Binding</a></li>
<li><a href="../log4j-docker/index.html" title="Log4j Docker Support"><span class="none"></span>Log4j Docker Support</a></li>
<li><a href="../log4j-spring-cloud-config/log4j-spring-cloud-config-client/index.html" title="Log4j Spring Cloud Config Client"><span class="none"></span>Log4j Spring Cloud Config Client</a></li>
<li class="nav-header"><img class="imageLink" src="../img/glyphicons/info.png" alt="Project Information" border="0"/> Project Information</li>
<li><a href="../dependency-convergence.html" title="Dependency Convergence"><span class="none"></span>Dependency Convergence</a></li>
<li><a href="../dependency-management.html" title="Dependency Management"><span class="none"></span>Dependency Management</a></li>
<li><a href="../team-list.html" title="Project Team"><span class="none"></span>Project Team</a></li>
<li><a href="../mail-lists.html" title="Mailing Lists"><span class="none"></span>Mailing Lists</a></li>
<li><a href="../issue-tracking.html" title="Issue Tracking"><span class="none"></span>Issue Tracking</a></li>
<li><a href="../license.html" title="Project License"><span class="none"></span>Project License</a></li>
<li><a href="../source-repository.html" title="Source Repository"><span class="none"></span>Source Repository</a></li>
<li><a href="../project-summary.html" title="Project Summary"><span class="none"></span>Project Summary</a></li>
<li class="nav-header"><img class="imageLink" src="../img/glyphicons/layers.png" alt="Project Reports" border="0"/> Project Reports</li>
<li><a href="../changes-report.html" title="Changes Report"><span class="none"></span>Changes Report</a></li>
<li><a href="../jira-report.html" title="JIRA Report"><span class="none"></span>JIRA Report</a></li>
<li><a href="../rat-report.html" title="RAT Report"><span class="none"></span>RAT Report</a></li>
</ul>
</nav>
<div class="well sidebar-nav">
<hr />
<div id="poweredBy">
<div class="clear"></div>
<div class="clear"></div>
<div class="clear"></div>
<a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy"><img class="builtBy" alt="Built by Maven" src="../images/logos/maven-feather.png" /></a>
</div>
</div>
</header>
<main id="bodyColumn" class="span10" >
<section>
<h2><a name="Plugins"></a>Plugins</h2>
<section>
<h3><a name="Introduction"></a>Introduction</h3>
<a name="Introduction"></a>
<p>
Log4j 1.x allowed for extension by requiring class attributes on most of the configuration
declarations. In the case of some elements, notably the PatternLayout, the only way to add
new pattern converters was to extend the PatternLayout class and add them via code. One
goal of Log4j 2 is to make extending it extremely easy through the use of plugins.
</p>
<p>
In Log4j 2 a plugin is declared by adding a
<a href="../log4j-core/apidocs/org/apache/logging/log4j/core/config/plugins/Plugin.html" class="javadoc">@Plugin</a>
annotation to the class declaration. During initialization the
<a href="../log4j-core/apidocs/org/apache/logging/log4j/core/config/Configuration.html" class="javadoc">Configuration</a>
will invoke the
<a href="../log4j-core/apidocs/org/apache/logging/log4j/core/config/plugins/util/PluginManager.html" class="javadoc">PluginManager</a>
to load the built-in Log4j plugins as well as any custom plugins. The PluginManager locates
plugins by looking in five places:
</p>
<ol style="list-style-type: decimal">
<li>Serialized plugin listing files on the classpath. These files are generated automatically during
the build (more details below).</li>
<li>(OSGi only) Serialized plugin listing files in each active OSGi bundle. A BundleListener
is added on activation to continue checking new bundles after log4j-core has started.</li>
<li>A comma-separated list of packages specified by the log4j.plugin.packages
system property.</li>
<li>Packages passed to the static PluginManager.addPackages method (before Log4j configuration
occurs).</li>
<li>The <a href="./configuration.html#ConfigurationSyntax">packages</a> declared in your log4j2
configuration file.</li>
</ol>
<p>
If multiple Plugins specify the same (case-insensitive) name, then the load order above
determines which one will be used. For example, to override the File plugin which is provided
by the built-in FileAppender class, you would need to place your plugin in a JAR file in the
CLASSPATH ahead oflog4j-core.jar. This is not recommended; plugin name collisions will cause a
warning to be emitted. Note that in an OSGi environment, the order that bundles are scanned for plugins
generally follows the same order that bundles were installed into the framework. See
<a class="javadoc" href="http://www.osgi.org/javadoc/r5/core/org/osgi/framework/BundleContext.html#getBundles()">getBundles()</a>
and
<a class="javadoc" href="http://www.osgi.org/javadoc/r5/core/org/osgi/framework/SynchronousBundleListener.html">SynchronousBundleListener</a>.
In short, name collisions are even more unpredictable in an OSGi environment.
</p>
<p>
Serialized plugin listing files are generated by an annotation processor contained in the
log4j-core artifact which will automatically scan your code for Log4j 2 plugins and output a metadata
file in your processed classes. There is nothing extra that needs to be done to enable this; the Java
compiler will automatically pick up the annotation processor on the class path unless you explicitly
disable it. In that case, it would be important to add another compiler pass to your build process that
only handles annotation processing using the Log4j 2 annotation processor class,
org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor. To do this using
Apache Maven, add the following execution to your <i>maven-compiler-plugin</i> (version 2.2 or higher)
build plugin:
</p>
<div>
<pre class="prettyprint linenums">
&lt;plugin&gt;
&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
&lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
&lt;version&gt;3.1&lt;/version&gt;
&lt;executions&gt;
&lt;execution&gt;
&lt;id&gt;log4j-plugin-processor&lt;/id&gt;
&lt;goals&gt;
&lt;goal&gt;compile&lt;/goal&gt;
&lt;/goals&gt;
&lt;phase&gt;process-classes&lt;/phase&gt;
&lt;configuration&gt;
&lt;proc&gt;only&lt;/proc&gt;
&lt;annotationProcessors&gt;
&lt;annotationProcessor&gt;org.apache.logging.log4j.core.config.plugins.processor.PluginProcessor&lt;/annotationProcessor&gt;
&lt;/annotationProcessors&gt;
&lt;/configuration&gt;
&lt;/execution&gt;
&lt;/executions&gt;
&lt;/plugin&gt;
</pre></div>
<p>
As the configuration is processed the appropriate plugins will be automatically configured and
initialized. Log4j 2 utilizes a few different categories of plugins which are described in the following
sections.
</p>
</section>
<section>
<h3><a name="Core"></a>Core</h3>
<a name="Core"></a>
<p>
Core plugins are those that are directly represented by an element in a configuration file, such as an
Appender, Layout, Logger or Filter. Custom plugins that conform to the rules laid out in the next paragraph
may simply be referenced in the configuration, provided they are appropriate configured to be
loaded by the PluginManager.
</p>
<p>
Every Core plugin must declare a static method annotated with @PluginFactory or
@PluginBuilderFactory. The former is used for static factory methods that provide all options
as method parameters, and the latter is used to construct a new Builder&lt;T&gt; class whose
fields are used for injecting attributes and child nodes. To allow the Configuration to pass
the correct parameters to the method, every parameter to the method must be annotated as one of the following
attribute types. Each attribute or element annotation must include the name that must be present in the
configuration in order to match the configuration item to its respective parameter. For plugin builders,
the names of the fields will be used by default if no name is specified in the annotation. There are dozens
of plugins in Log4j Core that can be used as examples for more complex scenarios including hierarchical
builder classes (e.g., see FileAppender). See <a href="extending.html#Plugin_Builders">Extending
Log4j with Plugin Builders</a> for more details.
</p>
<section>
<h4><a name="Attribute_Types"></a>Attribute Types</h4>
<dl>
<dt><a href="../log4j-core/apidocs/org/apache/logging/log4j/core/config/plugins/PluginAttribute.html" class="javadoc">PluginAttribute</a></dt>
<dd>The parameter must be convertible from a String using a <a href="#TypeConverters">TypeConverter</a>.
Most built-in types are already supported, but custom TypeConverter plugins may also be
provided for more type support. Note that PluginBuilderAttribute can be used in builder class
fields as an easier way to provide default values.</dd>
<dt><a href="../log4j-core/apidocs/org/apache/logging/log4j/core/config/plugins/PluginElement.html" class="javadoc">PluginElement</a></dt>
<dd>The parameter may represent a complex object that itself has parameters that can be configured.
This also supports injecting an array of elements.</dd>
<dt><a href="../log4j-core/apidocs/org/apache/logging/log4j/core/config/plugins/PluginConfiguration.html" class="javadoc">PluginConfiguration</a></dt>
<dd>The current Configuration object will be passed to the plugin as a parameter.</dd>
<dt><a href="../log4j-core/apidocs/org/apache/logging/log4j/core/config/plugins/PluginNode.html" class="javadoc">PluginNode</a></dt>
<dd>The current Node being parsed will be passed to the plugin as a parameter.</dd>
<dt><a href="../log4j-core/apidocs/org/apache/logging/log4j/core/config/plugins/PluginValue.html" class="javadoc">PluginValue</a></dt>
<dd>The value of the current Node or its attribute named value.</dd>
</dl>
</section><section>
<h4><a name="Constraint_Validators"></a>Constraint Validators</h4>
<p>
Plugin factory fields and parameters can be automatically validated at runtime using constraint validators
inspired by the <a class="externalLink" href="http://beanvalidation.org/">Bean Validation spec</a>. The following annotations
are bundled in Log4j, but custom
<a href="../log4j-core/apidocs/org/apache/logging/log4j/core/config/plugins/validation/ConstraintValidator.html" class="javadoc">ConstraintValidators</a>
can be created as well.
</p>
<dl>
<dt><a href="../log4j-core/apidocs/org/apache/logging/log4j/core/config/plugins/validation/constraints/Required.html" class="javadoc">Required</a></dt>
<dd>This annotation validates that a value is non-empty. This covers a check for null as well
as several other scenarios: empty CharSequence objects, empty arrays, empty Collection
instances, and empty Map instances.</dd>
<dt><a href="../log4j-core/apidocs/org/apache/logging/log4j/core/config/plugins/validation/constraints/ValidHost.html" class="javadoc">ValidHost</a></dt>
<dd>This annotation validates that a value corresponds to a valid hostname. This uses the same validation as
<a class="javadoc" href="http://docs.oracle.com/javase/8/docs/api/java/net/InetAddress.html#getByName-java.lang.String-">InetAddress::getByName</a>.</dd>
<dt><a href="../log4j-core/apidocs/org/apache/logging/log4j/core/config/plugins/validation/constraints/ValidPort.html" class="javadoc">ValidPort</a></dt>
<dd>This annotation validates that a value corresponds to a valid port number between 0 and 65535.</dd>
</dl>
</section></section>
<section>
<h3><a name="Converters"></a>Converters</h3>
<a name="Converters"></a>
<p>
Converters are used by
<a href="../log4j-core/apidocs/org/apache/logging/log4j/core/layout/PatternLayout.html" class="javadoc">PatternLayout</a>
to render the elements identified by the conversion pattern. Every converter must specify its category as
&quot;Converter&quot; on the @Plugin annotation, have a static newInstance method that
accepts an array of Strings as its only parameter and returns an instance of the Converter, and
must have a @ConverterKeys annotation present that contains the array of converter patterns
that will cause the Converter to be selected. Converters that are meant to handle LogEvents
must extend the
<a href="../log4j-core/apidocs/org/apache/logging/log4j/core/layout/LogEventPatternConverter.html" class="javadoc">LogEventPatternConverter</a>
class and must implement a format method that accepts a LogEvent and a StringBuilder
as arguments. The Converter should append the result of its operation to the StringBuilder.
</p>
<p>
A second type of Converter is the FileConverter - which must have &quot;FileConverter&quot; specified in the
category attribute of the @Plugin annotation. While similar to a LogEventPatternConverter,
instead of a single format method these Converters will have two variations; one that takes an
Object and one that takes an array of Objects instead of the LogEvent.
Both append to the provided StringBuilder in the same fashion as a LogEventPatternConverter.
These Converters are typically used by the RollingFileAppender to construct the name of the
file to log to.
</p>
<p>
If multiple Converters specify the same ConverterKeys, then the load order above determines
which one will be used. For example, to override the %date converter which is provided by the
built-in DatePatternConverter class, you would need to place your plugin in a JAR file in the
CLASSPATH ahead oflog4j-core.jar. This is not recommended; pattern ConverterKeys collisions
will cause a warning to be emitted. Try to use unique ConverterKeys for your custom pattern converters.
</p>
</section>
<section>
<h3><a name="KeyProviders"></a>KeyProviders</h3>
<a name="KeyProviders"></a>
<p>
Some components within Log4j may provide the ability to perform data encryption. These components require
a secret key to perform the encryption. Applications may provide the key by creating a class that
implements the
<a href="../log4j-core/apidocs/org/apache/logging/log4j/core/util/SecretKeyProvider.html" class="javadoc">SecretKeyProvider</a>
interface.
</p>
</section>
<section>
<h3><a name="Lookups"></a>Lookups</h3>
<a name="Lookups"></a>
<p>
Lookups are perhaps the simplest plugins of all. They must declare their type as &quot;Lookup&quot; on the
plugin annotation and must implement the
<a href="../log4j-core/apidocs/org/apache/logging/log4j/core/lookup/StrLookup.html" class="javadoc">StrLookup</a>
interface. They will have two methods; a
lookup method that accepts a String key and returns a String value and a second lookup method that
accepts both a LogEvent and a String key and returns a String. Lookups may be referenced by
specifying ${<var>name</var>:key} where <var>name</var> is the name specified in the Plugin annotation and
key is the name of the item to locate.
</p>
</section>
<section>
<h3><a name="TypeConverters"></a>TypeConverters</h3>
<a name="TypeConverters"></a>
<p>
<a href="../log4j-core/apidocs/org/apache/logging/log4j/core/config/plugins/convert/TypeConverter.html" class="javadoc">TypeConverter</a>s
are a sort of meta-plugin used for converting strings into other types in a plugin factory method
parameter. Other plugins can already be injected via the @PluginElement annotation; now, any
type supported by the type conversion system can be used in a @PluginAttribute parameter.
Conversion of enum types are supported on demand and do not require custom TypeConverter
classes. A large number of built-in Java classes are already supported; see
<a href="../log4j-core/apidocs/org/apache/logging/log4j/core/config/plugins/convert/TypeConverters.html" class="javadoc">TypeConverters</a>
for a more exhaustive listing.
</p>
<p>
Unlike other plugins, the plugin name of a TypeConverter is purely cosmetic. Appropriate
type converters are looked up via the Type interface rather than via Class&lt;?&gt;
objects only. Do note that TypeConverter plugins must have a default constructor.
</p>
</section>
</section>
<section>
<h2><a name="Developer_Notes"></a>Developer Notes</h2>
<a name="DeveloperNotes"></a>
<p>
If a plugin class implements
<a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/Collection.html">Collection</a> or
<a class="javadoc" href="http://docs.oracle.com/javase/6/docs/api/java/util/Map.html">Map</a>, then no
factory method is used. Instead, the class is instantiated using the default constructor, and all child
configuration nodes are added to the Collection or Map.
</p>
</section>
</main>
</div>
</div>
<hr/>
<footer>
<div class="container-fluid">
<div class="row-fluid">
<p align="center">Copyright &copy; 1999-2020 <a class="external" href="http://www.apache.org">The Apache Software Foundation</a>. All Rights Reserved.<br>
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, and the Apache Logging project logo are trademarks of The Apache Software Foundation.</p>
</div>
</div>
</footer>
</body>
</html>