blob: 0d2bbed46cc5d42d9ee29212a6f525388f1a2a45 [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
| Generated by Apache Maven Doxia at Jun 9, 2012
| Rendered using Apache Maven Fluido Skin
-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>
Log4j 2 Appenders</title>
<link rel="stylesheet" href="../css/apache-maven-fluido.min.css" />
<link rel="stylesheet" href="../css/site.css" />
<link rel="stylesheet" href="../css/print.css" media="print" />
<script type="text/javascript" src="../js/apache-maven-fluido.min.js"></script>
<meta name="author" content="Ralph Goers" />
<meta name="Date-Revision-yyyymmdd" content="20120609" />
<meta http-equiv="Content-Language" content="en" />
</head>
<body class="topBarDisabled">
<div class="container-fluid">
<div id="banner">
<div class="pull-left">
<a href="../../../" id="bannerLeft">
<img src="../images/ls-logo.jpg" alt="Apache Logging Services™"/>
</a>
</div>
<div class="pull-right"> <div id="bannerRight">
<img src="../images/logo.jpg" />
</div>
</div>
<div class="clear"><hr/></div>
</div>
<div id="breadcrumbs">
<ul class="breadcrumb">
<li id="publishDate">Last Published: 2012-06-09</li>
<li class="divider">|</li> <li id="projectVersion">Version: 2.0-alpha1-SNAPSHOT</li>
<li class="pull-right"> <a href="http://wiki.apache.org/logging" class="externalLink" title="Logging Wiki">Logging Wiki</a>
</li>
<li class="divider pull-right">|</li>
<li class="pull-right"> <a href="http://www.apache.org/" class="externalLink" title="Apache">Apache</a>
</li>
<li class="divider pull-right">|</li>
<li class="pull-right"> <a href="../../../" title="Logging Services">Logging Services</a>
</li>
<li class="divider pull-right">|</li>
<li class="pull-right"> <a href="../../" title="Log4j">Log4j</a>
</li>
<li class="divider pull-right">|</li>
<li class="pull-right"> <a href="../../companions" title="Log4j Companions">Log4j Companions</a>
</li>
</ul>
</div>
<div class="row-fluid">
<div id="leftColumn" class="span3">
<div class="well sidebar-nav">
<h3>Apache Log4j™ 2</h3>
<ul>
<li class="none">
<a href="../index.html" title="About">About</a>
</li>
<li class="none">
<a href="../download.html" title="Download">Download</a>
</li>
<li class="none">
<a href="../build.html" title="Build and Install">Build and Install</a>
</li>
<li class="none">
<a href="../changelog.html" title="Changelog">Changelog</a>
</li>
</ul>
<h3>Manual</h3>
<ul>
<li class="none">
<a href="../manual/index.html" title="Introduction">Introduction</a>
</li>
<li class="none">
<a href="../manual/architecture.html" title="Architecture">Architecture</a>
</li>
<li class="collapsed">
<a href="../manual/api.html" title="API">API</a>
</li>
<li class="collapsed">
<a href="../manual/configuration.html" title="Configuration">Configuration</a>
</li>
<li class="collapsed">
<a href="../manual/plugins.html" title="Plugins">Plugins</a>
</li>
<li class="collapsed">
<a href="../manual/lookups.html" title="Lookups">Lookups</a>
</li>
<li class="expanded">
<strong>Appenders</strong>
<ul>
<li class="none">
<a href="../manual/appenders.html@ConsoleAppender" title="Console">Console</a>
</li>
<li class="none">
<a href="../manual/appenders.html@FailoverAppender" title="Failover">Failover</a>
</li>
<li class="none">
<a href="../manual/appenders.html#FileAppender" title="File">File</a>
</li>
<li class="none">
<a href="../manual/appenders.html#FlumeAvroAppender" title="Flume">Flume</a>
</li>
<li class="none">
<a href="../manual/appenders.html#JMSQueueAppender" title="JMSQueue">JMSQueue</a>
</li>
<li class="none">
<a href="../manual/appenders.html#JMSTopicAppender" title="JSMTopic">JSMTopic</a>
</li>
<li class="none">
<a href="../manual/appenders.html#OutputStreamAppender" title="OutputStream">OutputStream</a>
</li>
<li class="none">
<a href="../manual/appenders.html#RewriteAppender" title="Rewrite">Rewrite</a>
</li>
<li class="none">
<a href="../manual/appenders.html#RollingFileAppender" title="RollingFile">RollingFile</a>
</li>
<li class="none">
<a href="../manual/appenders.html#RoutingAppender" title="Routing">Routing</a>
</li>
<li class="none">
<a href="../manual/appenders.html#SocketAppender" title="Socket">Socket</a>
</li>
<li class="none">
<a href="../manual/appenders.html#SyslogAppender" title="Syslog">Syslog</a>
</li>
</ul>
</li>
<li class="collapsed">
<a href="../manual/layouts.html" title="Layouts">Layouts</a>
</li>
<li class="collapsed">
<a href="../manual/filters.html" title="Filters">Filters</a>
</li>
<li class="none">
<a href="../manual/jmx.html" title="JMX">JMX</a>
</li>
<li class="none">
<a href="../manual/logsep.html" title="Logging Separation">Logging Separation</a>
</li>
<li class="collapsed">
<a href="../manual/extending.html" title="Extending Log4j">Extending Log4j</a>
</li>
</ul>
<h3>Logging Adapters</h3>
<ul>
<li class="none">
<a href="../log4j12-api/api.html" title="Log4j 1.x API">Log4j 1.x API</a>
</li>
<li class="none">
<a href="../log4j2-jcl/api.html" title="Commons Logging">Commons Logging</a>
</li>
<li class="none">
<a href="../slf4j-impl/api.html" title="SLF4J">SLF4J</a>
</li>
</ul>
<h3>Components</h3>
<ul>
<li class="none">
<a href="../log4j-api/index.html" title="API">API</a>
</li>
<li class="none">
<a href="../log4j-core/index.html" title="Impl">Impl</a>
</li>
<li class="none">
<a href="../log4j12-api/index.html" title="Log4J 1.2 API">Log4J 1.2 API</a>
</li>
<li class="none">
<a href="../log4j-jcl/index.html" title="Commons Logging Bridge">Commons Logging Bridge</a>
</li>
<li class="none">
<a href="../slf4j-impl/index.html" title="SLF4J Binding">SLF4J Binding</a>
</li>
<li class="none">
<a href="../log4j-flume-og/index.html" title="Flume OG">Flume OG</a>
</li>
<li class="none">
<a href="../log4j-flume-ng/index.html" title="Flume NG">Flume NG</a>
</li>
</ul>
<h3>Project Documentation</h3>
<ul>
<li class="collapsed">
<a href="../project-info.html" title="Project Information">Project Information</a>
</li>
<li class="collapsed">
<a href="../project-reports.html" title="Project Reports">Project Reports</a>
</li>
</ul>
<hr class="divider" />
<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="poweredBy" alt="Built by Maven" src="../images/logos/maven-feather.png" />
</a>
</div>
</div>
</div>
<div id="bodyColumn" class="span9" >
<!-- Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. -->
<div class="section"><h2>Appenders<a name="Appenders"></a></h2>
<p>
Appenders are the component responsible for delivering LogEvents to their destination. Every Appender must
implement the <a href="../log4j2-core/apidocs/org/apache/logging/log4j/core/Appender.html">Appender</a>
interface. Most Appenders will extend
<a href="../log4j2-core/apidocs/org/apache/logging/log4j/core/appender/AppenderBase.html">AppenderBase</a>
which adds <a href="../log4j2-core/apidocs/org/apache/logging/log4j/core/Lifecycle.html">Lifecycle</a>
and <a href="../log4j2-core/apidocs/org/apache/logging/log4j/core/filter/Filterable">Filterable</a>
support. Lifecycle allows components to finish initialization after configuration has completed and to
perform cleanup during shutdown. Filterable allows the component to have Filters attached to it which are
evaluated during event processing.
</p>
<p>
Appenders usually are only responsible for writing the event data to the target destination. In most cases
they delegate responsibility for formatting the event to a <a href="../layouts.html">layout</a>. Some
appenders wrap other appenders so that they can modify the LogEvent, handle a failure in an Appender,
route the event to a subordinate Appender based on advanced Filter criteria or provide similar functionality
that does not directly format the event for viewing.
</p>
<p>
Appenders always have a name so that they can be referenced from Loggers.
</p>
<a name="ConsoleAppender"></a>
<div class="section"><h3>ConsoleAppender<a name="ConsoleAppender"></a></h3>
<p>
As one might expect, the ConsoleAppender writes its output to either System.err or System.out with System.err
being the default target. A Layout must be provided to format the LogEvent.
</p>
<table class="zebra-striped" border="1" width="100%"><caption align="top">ConsoleAppender Parameters</caption>
<tr class="a">
<th>Parameter Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr class="b">
<td>filter</td>
<td>Filter</td>
<td>A Filter to determine if the event should be handled by this Appender. More than one Filter
may be used by using a CompositeFilter.</td>
</tr>
<tr class="a">
<td>layout</td>
<td>Layout</td>
<td>The Layout to use to format the LogEvent. If no layout is supplied the default pattern layout
of &quot;%m%n&quot; will be used.</td>
</tr>
<tr class="b">
<td>name</td>
<td>String</td>
<td>The name of the Appender.</td>
</tr>
<tr class="a">
<td>suppressExceptions</td>
<td>boolean</td>
<td>The default is true, causing exceptions to be internally logged and then ignored. When set to
false exceptions will be percolated to the caller.</td>
</tr>
<tr class="b">
<td>target</td>
<td>String</td>
<td>Either &quot;SYSTEM_OUT&quot; or &quot;SYSTEM_ERR&quot;. The default is &quot;SYSTEM_ERR&quot;.</td>
</tr>
</table>
<p>
A typical Console configuration might look like:
</p><div class="source"><pre class="prettyprint">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;configuration status=&quot;warn&quot; name=&quot;MyApp&quot; packages=&quot;&quot;&gt;
&lt;appenders&gt;
&lt;Console name=&quot;STDOUT&quot; target=&quot;SYSTEM_OUT&quot;&gt;
&lt;PatternLayout pattern=&quot;%m%n&quot;/&gt;
&lt;/Console&gt;
&lt;/appenders&gt;
&lt;loggers&gt;
&lt;root level=&quot;error&quot;&gt;
&lt;appender-ref ref=&quot;STDOUT&quot;/&gt;
&lt;/root&gt;
&lt;/loggers&gt;
&lt;/configuration&gt;
</pre></div>
</div>
<a name="FailoverAppender"></a>
<div class="section"><h3>FailoverAppender<a name="FailoverAppender"></a></h3>
<p>The FailoverAppender wraps a set of appenders. If the primary Appender fails the secondary appenders will be
tried in order until one succeeds or there are no more secondaries to try.</p>
<table class="zebra-striped" border="1" width="100%"><caption align="top">FailoverAppender Parameters</caption>
<tr class="a">
<th>Parameter Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr class="b">
<td>filter</td>
<td>Filter</td>
<td>A Filter to determine if the event should be handled by this Appender. More than one Filter
may be used by using a CompositeFilter.</td>
</tr>
<tr class="a">
<td>primary</td>
<td>String</td>
<td>The name of the primary Appender to use.</td>
</tr>
<tr class="b">
<td>failovers</td>
<td>String[]</td>
<td>The names of the secondary Appenders to use.</td>
</tr>
<tr class="a">
<td>name</td>
<td>String</td>
<td>The name of the Appender.</td>
</tr>
<tr class="b">
<td>suppressExceptions</td>
<td>boolean</td>
<td>The default is true, causing exceptions to be internally logged and then ignored. When set to
false exceptions will be percolated to the caller.</td>
</tr>
<tr class="a">
<td>target</td>
<td>String</td>
<td>Either &quot;SYSTEM_OUT&quot; or &quot;SYSTEM_ERR&quot;. The default is &quot;SYSTEM_ERR&quot;.</td>
</tr>
</table>
<p>
A Failover configuration might look like:
</p><div class="source"><pre class="prettyprint">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;configuration status=&quot;warn&quot; name=&quot;MyApp&quot; packages=&quot;&quot;&gt;
&lt;appenders&gt;
&lt;RollingFile name=&quot;RollingFile&quot; fileName=&quot;logs/app.log&quot; filePattern=&quot;logs/app-%d{MM-dd-yyyy}.log.gz&quot;&gt;
&lt;PatternLayout&gt;
&lt;pattern&gt;%d %p %C{1.} [%t] %m%n&lt;/pattern&gt;
&lt;/PatternLayout&gt;
&lt;TimeBasedTriggeringPolicy /&gt;
&lt;/RollingFile&gt;
&lt;Console name=&quot;STDOUT&quot; target=&quot;SYSTEM_OUT&quot;&gt;
&lt;PatternLayout pattern=&quot;%m%n&quot;/&gt;
&lt;/Console&gt;
&lt;Failover name=&quot;Failover&quot; primary=&quot;RollingFile&quot; suppressExceptions=&quot;false&quot;&gt;
&lt;Failovers&gt;
&lt;appender-ref ref=&quot;Console&quot;/&gt;
&lt;/Failovers&gt;
&lt;/Failover&gt;
&lt;/appenders&gt;
&lt;loggers&gt;
&lt;root level=&quot;error&quot;&gt;
&lt;appender-ref ref=&quot;Failover&quot;/&gt;
&lt;/root&gt;
&lt;/loggers&gt;
&lt;/configuration&gt;
</pre></div>
</div>
<a name="FileAppender"></a>
<div class="section"><h3>FileAppender<a name="FileAppender"></a></h3>
<p>The FileAppender is an OutputStreamAppender that writes to the File named in the fileName parameter. The
FileAppender uses a FileManager (which extends OutputStreamManager) to actually perform the file I/O. While
FileAppenders from different Configurations cannot be shared, the FileManagers can be if the Manager is
accessible. For example, two webapps in a servlet container can have their own configuration and safely
write to the same file if Log4J is in a ClassLoader that is common to both of them.</p>
<table class="zebra-striped" border="1" width="100%"><caption align="top">FileAppender Parameters</caption>
<tr class="a">
<th>Parameter Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr class="b">
<td>append</td>
<td>boolean</td>
<td>When true - the default, records will be appended to the end of the file. When set to false,
the file will be cleared before new reocrds are written.</td>
</tr>
<tr class="a">
<td>bufferedIO</td>
<td>boolean</td>
<td>When true - the default, records will be written to a buffer and the data will be written to
disk when the buffer is full or, if immediateFlush is set, when the record is written.
File locking cannot be used with bufferedIO. Performance tests have shown that using buffered I/O
significantly improves performance, even if immediateFlush is enabled.</td>
</tr>
<tr class="b">
<td>filter</td>
<td>Filter</td>
<td>A Filter to determine if the event should be handled by this Appender. More than one Filter
may be used by using a CompositeFilter.</td>
</tr>
<tr class="a">
<td>fileName</td>
<td>String</td>
<td>The name of the file to write to. If the file, or any of its parent directories, do not exist,
they will be created.</td>
</tr>
<tr class="b">
<td>immediateFlush</td>
<td>boolean</td>
<td>When set to true, each write will be followed by a flush. This will guarantee the data is written
to disk but could impact performance.</td>
</tr>
<tr class="a">
<td>layout</td>
<td>Layout</td>
<td>The Layout to use to format the LogEvent</td>
</tr>
<tr class="b">
<td>locking</td>
<td>boolean</td>
<td>When set to true, I/O operations will occur only while the file lock is held allowing FileAppenders
in multiple JVMs and potentially multiple hosts to write to the same file simultaneously. This
will significantly impact performance so should be used carefully. Furthermore, on many systems
the file lock is &quot;advisory&quot; meaning that other applications can perform operations on the file
without acquiring a lock. The default value is false.</td>
</tr>
<tr class="a">
<td>name</td>
<td>String</td>
<td>The name of the Appender.</td>
</tr>
<tr class="b">
<td>suppressExceptions</td>
<td>boolean</td>
<td>The default is true, causing exceptions to be internally logged and then ignored. When set to
false exceptions will be percolated to the caller.</td>
</tr>
</table>
<p>
Here is a sample File configuration:
</p><div class="source"><pre class="prettyprint">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;configuration status=&quot;warn&quot; name=&quot;MyApp&quot; packages=&quot;&quot;&gt;
&lt;appenders&gt;
&lt;File name=&quot;MyFile&quot; fileName=&quot;logs/app.log&quot;&gt;
&lt;PatternLayout&gt;
&lt;pattern&gt;%d %p %C{1.} [%t] %m%n&lt;/pattern&gt;
&lt;/PatternLayout&gt;
&lt;/File&gt;
&lt;/appenders&gt;
&lt;loggers&gt;
&lt;root level=&quot;error&quot;&gt;
&lt;appender-ref ref=&quot;MyFile&quot;/&gt;
&lt;/root&gt;
&lt;/loggers&gt;
&lt;/configuration&gt;
</pre></div>
</div>
<a name="FlumeAvroAppender"></a>
<div class="section"><h3>FlumeAvroAppender<a name="FlumeAvroAppender"></a></h3>
<p><i>This is an optional component supplied in a separate jar.</i></p>
<p><a class="externalLink" href="http://incubator.apache.org/projects/flume.html">Apache Flume</a> is a distributed, reliable,
and available system for efficiently collecting, aggregating, and moving large amounts of log data
from many different sources to a centralized data store. The FlumeAppender takes LogEvents and sends
them to a Flume agent as serialized Avro events for consumption.</p>
<p>
There are two versions of the Flume Appender available. The first is for &quot;Flume OG&quot;, the original
version of Flume before it became an Apache project. The second is for &quot;Flume NG&quot;, which is
maintained by the Apache Flume project.
</p>
<table class="zebra-striped" border="1" width="100%"><caption align="top">FlumeAvroAppender Parameters</caption>
<tr class="a">
<th>Parameter Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr class="b">
<td>agents</td>
<td>Agent[]</td>
<td>An array of Agents to which the logging events should be sent. If more than one agent is specified
the first Agent will be the primary and subsequent Agents will be used in the order specified as
secondaries should the primary Agent fail. Each Agent definition supplies the Agents host and port.</td>
</tr>
<tr class="a">
<td>agentRetries</td>
<td>integer</td>
<td>The number of times the agent should be retried before failing to a secondary.</td>
</tr>
<tr class="b">
<td>batchSize</td>
<td>integer</td>
<td>Specifies the number of events that should be sent as a batch. The default is 1. <i>This
parameter only applies to the Flume NG Appender.</i></td>
</tr>
<tr class="a">
<td>compress</td>
<td>boolean</td>
<td>When set to true the message body will be compressed using gzip</td>
</tr>
<tr class="b">
<td>filter</td>
<td>Filter</td>
<td>A Filter to determine if the event should be handled by this Appender. More than one Filter
may be used by using a CompositeFilter.</td>
</tr>
<tr class="a">
<td>eventPrefix</td>
<td>String</td>
<td>The character string to prepend to each event attribute in order to distinguish it from MDC attributes.
The default is an empty string.</td>
</tr>
<tr class="b">
<td>flumeEventFactory</td>
<td>FlumeEventFactory</td>
<td>Factory that generates the Flume events from Log4j events. The default factory is the
FlumeAvroAppender itself.</td>
</tr>
<tr class="a">
<td>layout</td>
<td>Layout</td>
<td>The Layout to use to format the LogEvent. If no layout is specified RFC5424Layout will be used.</td>
</tr>
<tr class="b">
<td>mdcExcludes</td>
<td>String</td>
<td>A comma separated list of mdc keys that should be excluded from the FlumeEvent. This is mutually
exclusive with the mdcIncludes attribute.</td>
</tr>
<tr class="a">
<td>mdcIncludes</td>
<td>String</td>
<td>A comma separated list of mdc keys that should be included in the FlumeEvent. Any keys in the MDC
not found in the list will be excluded. This option is mutually exclusive with the mdcExcludes
attribute.</td>
</tr>
<tr class="b">
<td>mdcRequired</td>
<td>String</td>
<td>A comma separated list of mdc keys that must be present in the MDC. If a key is not present a
LoggingException will be thrown.</td>
</tr>
<tr class="a">
<td>mdcPrefix</td>
<td>String</td>
<td>A string that should be prepended to each MDC key in order to distinguish it from event attributes.
The default string is &quot;mdc:&quot;.</td>
</tr>
<tr class="b">
<td>name</td>
<td>String</td>
<td>The name of the Appender.</td>
</tr>
<tr class="a">
<td>reconnectionDelay</td>
<td>integer</td>
<td>The number of milliseconds the application should wait before trying again to connect to the
agent.</td>
</tr>
<tr class="b">
<td>suppressExceptions</td>
<td>boolean</td>
<td>The default is true, causing exceptions to be internally logged and then ignored. When set to
false exceptions will be percolated to the caller.</td>
</tr>
</table>
<p>
A sample FlumeAvroAppender configuration that is configured with a primary and a secondary agent,
compresses the body, and formats the body using the RFC5424Layout:
</p><div class="source"><pre class="prettyprint">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;configuration status=&quot;warn&quot; name=&quot;MyApp&quot; packages=&quot;&quot;&gt;
&lt;appenders&gt;
&lt;Flume name=&quot;eventLogger&quot; suppressExceptions=&quot;false&quot; compress=&quot;true&quot;&gt;
&lt;Agent host=&quot;192.168.10.101&quot; port=&quot;8800&quot;/&gt;
&lt;Agent host=&quot;192.168.10.102&quot; port=&quot;8800&quot;/&gt;
&lt;RFC5424Layout enterpriseNumber=&quot;18060&quot; includeMDC=&quot;true&quot; appName=&quot;MyApp&quot;/&gt;
&lt;/Flume&gt;
&lt;/appenders&gt;
&lt;loggers&gt;
&lt;root level=&quot;error&quot;&gt;
&lt;appender-ref ref=&quot;eventLogger&quot;/&gt;
&lt;/root&gt;
&lt;/loggers&gt;
&lt;/configuration&gt;
</pre></div>
</div>
<a name="JMSQueueAppender"></a>
<div class="section"><h3>JMSQueueAppender<a name="JMSQueueAppender"></a></h3>
<p>The JMSQueueAppender sends the formatted log event to a JMS Queue.</p>
<table class="zebra-striped" border="1" width="100%"><caption align="top">JMSQueueAppender Parameters</caption>
<tr class="a">
<th>Parameter Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr class="b">
<td>factoryBindingName</td>
<td>String</td>
<td>The name to locate in the Context that provides the
<a class="externalLink" href="http://download.oracle.com/javaee/5/api/javax/jms/QueueConnectionFactory.html">QueueConnectionFactory</a>.</td>
</tr>
<tr class="a">
<td>factoryName</td>
<td>String</td>
<td>The fully qualified class name that should be used to define the Initial Context Factory as
defined in <a class="externalLink" href="http://download.oracle.com/javase/6/docs/api/javax/naming/Context.html#INITIAL_CONTEXT_FACTORY">INITIAL_CONTEXT_FACTORY</a>.
If no value is provided the
default InitialContextFactory will be used. If a factoryName is specified without a providerURL
a warning message will be logged as this is likely to cause problems.</td>
</tr>
<tr class="b">
<td>filter</td>
<td>Filter</td>
<td>A Filter to determine if the event should be handled by this Appender. More than one Filter
may be used by using a CompositeFilter.</td>
</tr>
<tr class="a">
<td>layout</td>
<td>Layout</td>
<td>The Layout to use to format the LogEvent. If no layout is specified SerializedLayout will be used.</td>
</tr>
<tr class="b">
<td>name</td>
<td>String</td>
<td>The name of the Appender.</td>
</tr>
<tr class="a">
<td>password</td>
<td>String</td>
<td>The password to use to create the queue connection.</td>
</tr>
<tr class="b">
<td>providerURL</td>
<td>String</td>
<td>The URL of the provider to use as defined by
<a class="externalLink" href="http://download.oracle.com/javase/6/docs/api/javax/naming/Context.html#PROVIDER_URL">PROVIDER_URL</a>.
If this value is null the default system provider will be used.</td>
</tr>
<tr class="a">
<td>queueBindingName</td>
<td>String</td>
<td>The name to use to locate the <a class="externalLink" href="http://download.oracle.com/javaee/5/api/javax/jms/Queue.html">Queue</a>.</td>
</tr>
<tr class="b">
<td>securityPrincipalName</td>
<td>String</td>
<td>The name of the identity of the Principal as specified by
<a class="externalLink" href="http://download.oracle.com/javase/6/docs/api/javax/naming/Context.html#SECURITY_PRINCIPAL">SECURITY_PRINCIPAL</a>.
If a securityPrincipalName is specified without securityCredentials a warning message will be
logged as this is likely to cause problems.</td>
</tr>
<tr class="a">
<td>securityCredentials</td>
<td>String</td>
<td>The security credentials for the principal as specified by
<a class="externalLink" href="http://download.oracle.com/javase/6/docs/api/javax/naming/Context.html#SECURITY_CREDENTIALS">SECURITY_CREDENTIALS</a>.</td>
</tr>
<tr class="b">
<td>suppressExceptions</td>
<td>boolean</td>
<td>The default is true, causing exceptions to be internally logged and then ignored. When set to
false exceptions will be percolated to the caller.</td>
</tr>
<tr class="a">
<td>urlPkgPrefixes</td>
<td>String</td>
<td>A colon-separated list of package prefixes for the class name of the factory class that will create
a URL context factory as defined by
<a class="externalLink" href="http://download.oracle.com/javase/6/docs/api/javax/naming/Context.html#URL_PKG_PREFIXES">URL_PKG_PREFIXES</a>.</td>
</tr>
<tr class="b">
<td>userName</td>
<td>String</td>
<td>The user id used to create the queue connection.</td>
</tr>
</table>
<p>
Here is a sample JMSQueueAppender configuration:
</p><div class="source"><pre class="prettyprint">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;configuration status=&quot;warn&quot; name=&quot;MyApp&quot; packages=&quot;&quot;&gt;
&lt;appenders&gt;
&lt;JMSQueue name=&quot;jmsQueue&quot; queueBindingName=&quot;MyQueue&quot; factoryBindingName=&quot;MyQueueConnectionFactory&quot;/&gt;
&lt;/appenders&gt;
&lt;loggers&gt;
&lt;root level=&quot;error&quot;&gt;
&lt;appender-ref ref=&quot;jmsQueue&quot;/&gt;
&lt;/root&gt;
&lt;/loggers&gt;
&lt;/configuration&gt;
</pre></div>
</div>
<a name="JMSTopicAppender"></a>
<div class="section"><h3>JMSTopicAppender<a name="JMSTopicAppender"></a></h3>
<p>The JMSTopicAppender sends the formatted log event to a JMS Topic.</p>
<table class="zebra-striped" border="1" width="100%"><caption align="top">JMSTopicAppender Parameters</caption>
<tr class="a">
<th>Parameter Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr class="b">
<td>factoryBindingName</td>
<td>String</td>
<td>The name to locate in the Context that provides the
<a class="externalLink" href="http://download.oracle.com/javaee/5/api/javax/jms/TopicConnectionFactory.html">TopicConnectionFactory</a>.</td>
</tr>
<tr class="a">
<td>factoryName</td>
<td>String</td>
<td>The fully qualified class name that should be used to define the Initial Context Factory as
defined in <a class="externalLink" href="http://download.oracle.com/javase/6/docs/api/javax/naming/Context.html#INITIAL_CONTEXT_FACTORY">INITIAL_CONTEXT_FACTORY</a>.
If no value is provided the
default InitialContextFactory will be used. If a factoryName is specified without a providerURL
a warning message will be logged as this is likely to cause problems.</td>
</tr>
<tr class="b">
<td>filter</td>
<td>Filter</td>
<td>A Filter to determine if the event should be handled by this Appender. More than one Filter
may be used by using a CompositeFilter.</td>
</tr>
<tr class="a">
<td>layout</td>
<td>Layout</td>
<td>The Layout to use to format the LogEvent. If no layout is specified SerializedLayout will be used.</td>
</tr>
<tr class="b">
<td>name</td>
<td>String</td>
<td>The name of the Appender.</td>
</tr>
<tr class="a">
<td>password</td>
<td>String</td>
<td>The password to use to create the queue connection.</td>
</tr>
<tr class="b">
<td>providerURL</td>
<td>String</td>
<td>The URL of the provider to use as defined by
<a class="externalLink" href="http://download.oracle.com/javase/6/docs/api/javax/naming/Context.html#PROVIDER_URL">PROVIDER_URL</a>.
If this value is null the default system provider will be used.</td>
</tr>
<tr class="a">
<td>topicBindingName</td>
<td>String</td>
<td>The name to use to locate the
<a class="externalLink" href="http://download.oracle.com/javaee/5/api/javax/jms/Topic.html">Topic</a>.</td>
</tr>
<tr class="b">
<td>securityPrincipalName</td>
<td>String</td>
<td>The name of the identity of the Principal as specified by
<a class="externalLink" href="http://download.oracle.com/javase/6/docs/api/javax/naming/Context.html#SECURITY_PRINCIPAL">SECURITY_PRINCIPAL</a>.
If a securityPrincipalName is specified without securityCredentials a warning message will be
logged as this is likely to cause problems.</td>
</tr>
<tr class="a">
<td>securityCredentials</td>
<td>String</td>
<td>The security credentials for the principal as specified by
<a class="externalLink" href="http://download.oracle.com/javase/6/docs/api/javax/naming/Context.html#SECURITY_CREDENTIALS">SECURITY_CREDENTIALS</a>.</td>
</tr>
<tr class="b">
<td>suppressExceptions</td>
<td>boolean</td>
<td>The default is true, causing exceptions to be internally logged and then ignored. When set to
false exceptions will be percolated to the caller.</td>
</tr>
<tr class="a">
<td>urlPkgPrefixes</td>
<td>String</td>
<td>A colon-separated list of package prefixes for the class name of the factory class that will create
a URL context factory as defined by
<a class="externalLink" href="http://download.oracle.com/javase/6/docs/api/javax/naming/Context.html#URL_PKG_PREFIXES">URL_PKG_PREFIXES</a>.</td>
</tr>
<tr class="b">
<td>userName</td>
<td>String</td>
<td>The user id used to create the queue connection.</td>
</tr>
</table>
<p>
Here is a sample JMSTopicAppender configuration:
</p><div class="source"><pre class="prettyprint">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;configuration status=&quot;warn&quot; name=&quot;MyApp&quot; packages=&quot;&quot;&gt;
&lt;appenders&gt;
&lt;JMSTopic name=&quot;jmsTopic&quot; topicBindingName=&quot;MyTopic&quot; factoryBindingName=&quot;MyTopicConnectionFactory&quot;/&gt;
&lt;/appenders&gt;
&lt;loggers&gt;
&lt;root level=&quot;error&quot;&gt;
&lt;appender-ref ref=&quot;jmsQueue&quot;/&gt;
&lt;/root&gt;
&lt;/loggers&gt;
&lt;/configuration&gt;
</pre></div>
</div>
<a name="OutputStreamAppender"></a>
<div class="section"><h3>OutputStreamAppender<a name="OutputStreamAppender"></a></h3>
The OutputStreamAppender provides the base for many of the other Appenders such as the File and Socket
appenders that write the event to an Output Stream. It cannot be directly configured. Support for
immediateFlush and buffering is provided by the OutputStreamAppender. The OutputStreamAppender uses an
OutputStreamManager to handle the actual I/O, allowing the stream to be shared by Appenders in multiple
configurations.
</div>
<a name="RewriteAppender"></a>
<div class="section"><h3>RewriteAppender<a name="RewriteAppender"></a></h3>
<p>
The RewriteAppender allows the LogEvent to manipulated before it is processed by another Appender. This
can be used to mask sensitive information such as passwords or to inject information into each event.
The RewriteAppender must be configured with a <a href="RewritePolicy">RewritePolicy</a>.
</p>
<table class="zebra-striped" border="1" width="100%"><caption align="top">RewriteAppender Parameters</caption>
<tr class="a">
<th>Parameter Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr class="b">
<td>appender-ref</td>
<td>String</td>
<td>The name of the Appender to call after the LogEvent has been manipulated.</td>
</tr>
<tr class="a">
<td>filter</td>
<td>Filter</td>
<td>A Filter to determine if the event should be handled by this Appender. More than one Filter
may be used by using a CompositeFilter.</td>
</tr>
<tr class="b">
<td>name</td>
<td>String</td>
<td>The name of the Appender.</td>
</tr>
<tr class="a">
<td>rewritePolicy</td>
<td>RewritePolciy</td>
<td>The RewritePolicy that will manipulate the LogEvent.</td>
</tr>
<tr class="b">
<td>suppressExceptions</td>
<td>boolean</td>
<td>The default is true, causing exceptions to be internally logged and then ignored. When set to
false exceptions will be percolated to the caller.</td>
</tr>
</table>
<div class="section"><h4>RewritePolicy<a name="RewritePolicy"></a></h4>
<p>
RewritePolicy is an interface that allows implementations to inspect and possibly modify LogEvents
before they are passed to Appender. RewritePolicy declares a single method named rewrite that must
be implemented. The method is passed the LogEvent and can return the same event or create a new one.
</p>
<div class="section"><h5>MapRewritePolicy<a name="MapRewritePolicy"></a></h5>
<p>
MapRewritePolicy will evaluate LogEvents that contain a MapMessage and will add or update
elements of the Map.
</p>
<table class="zebra-striped" border="1" width="100%">
<tr class="a">
<th>Parameter Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr class="b">
<td>mode</td>
<td>String</td>
<td>&quot;Add&quot; or &quot;Update&quot;</td>
</tr>
<tr class="a">
<td>keyValuePair</td>
<td>KeyValuePair[]</td>
<td>An array of keys and their values.</td>
</tr>
</table>
<p>
The following configuration shows a RewriteAppender configured to add a product key and its value
to the MapMessage.:
</p><div class="source"><pre class="prettyprint">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;configuration status=&quot;warn&quot; name=&quot;MyApp&quot; packages=&quot;&quot;&gt;
&lt;appenders&gt;
&lt;Console name=&quot;STDOUT&quot; target=&quot;SYSTEM_OUT&quot;&gt;
&lt;PatternLayout pattern=&quot;%m%n&quot;/&gt;
&lt;/Console&gt;
&lt;Rewrite name=&quot;rewrite&quot;&gt;
&lt;appender-ref ref=&quot;STDOUT&quot;/&gt;
&lt;MapRewritePolicy mode=&quot;Add&quot;&gt;
&lt;KeyValuePair key=&quot;product&quot; value=&quot;TestProduct&quot;/&gt;
&lt;/MapRewritePolicy&gt;
&lt;/Rewrite&gt;
&lt;/appenders&gt;
&lt;loggers&gt;
&lt;root level=&quot;error&quot;&gt;
&lt;appender-ref ref=&quot;Rewrite&quot;/&gt;
&lt;/root&gt;
&lt;/loggers&gt;
&lt;/configuration&gt;
</pre></div>
</div></div></div>
<a name="RollingFileAppender"></a>
<div class="section"><h3>RollingFileAppender<a name="RollingFileAppender"></a></h3>
<p>The RollingFileAppender is an OutputStreamAppender that writes to the File named in the fileName parameter
and rolls the file over according the TriggeringPolicy and the RolloverPolicy. The
RollingFileAppender uses a RollingFileManager (which extends OutputStreamManager) to actually perform the
file I/O and perform the rollover. While RolloverFileAppenders from different Configurations cannot be
shared, the RollingFileManagers can be if the Manager is accessible. For example, two webapps in a
servlet container can have their own configuration and safely
write to the same file if Log4J is in a ClassLoader that is common to both of them.</p>
<p>
A RollingFileAppender requires a <a href="#TriggeringPolicies">TriggeringPolicy</a> and a
<a href="#RolloverStrategies">RolloverStrategy</a>. The triggering policy determines if a rollover should
be performed while the RolloverStrategy defines how the rollover should be done. If no RolloverStrategy
is configured, RollingFileAppender will use the <a href="DefaultRolloverStrategy">DefaultRolloverStrategy</a>.
</p>
<p>
File locking is not supported by the RollingFileAppender.
</p>
<table class="zebra-striped" border="1" width="100%"><caption align="top">RollingFileAppender Parameters</caption>
<tr class="a">
<th>Parameter Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr class="b">
<td>append</td>
<td>boolean</td>
<td>When true - the default, records will be appended to the end of the file. When set to false,
the file will be cleared before new reocrds are written.</td>
</tr>
<tr class="a">
<td>bufferedIO</td>
<td>boolean</td>
<td>When true - the default, records will be written to a buffer and the data will be written to
disk when the buffer is full or, if immediateFlush is set, when the record is written.
File locking cannot be used with bufferedIO. Performance tests have shown that using buffered I/O
significantly improves performance, even if immediateFlush is enabled.</td>
</tr>
<tr class="b">
<td>filter</td>
<td>Filter</td>
<td>A Filter to determine if the event should be handled by this Appender. More than one Filter
may be used by using a CompositeFilter.</td>
</tr>
<tr class="a">
<td>fileName</td>
<td>String</td>
<td>The name of the file to write to. If the file, or any of its parent directories, do not exist,
they will be created.</td>
</tr>
<tr class="b">
<td>filePattern</td>
<td>String</td>
<td>The pattern of the file name of the archived log file. The format of the pattern should is
dependent on the RolloverPolicy that is used. The DefaultRolloverPolicy will accept both
a date/time pattern compatible with
<a class="externalLink" href="http://download.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html">SimpleDateFormat</a>
and and/or a %i which represents an integer counter. The pattern also supports interpolation at
runtime so any of the Lookups (such as the <a href="./lookups.html#DateLookup">DateLookup</a> can
be included in the pattern.</td>
</tr>
<tr class="a">
<td>immediateFlush</td>
<td>boolean</td>
<td>When set to true, each write will be followed by a flush. This will guarantee the data is written
to disk but could impact performance.</td>
</tr>
<tr class="b">
<td>layout</td>
<td>Layout</td>
<td>The Layout to use to format the LogEvent</td>
</tr>
<tr class="a">
<td>name</td>
<td>String</td>
<td>The name of the Appender.</td>
</tr>
<tr class="b">
<td>policy</td>
<td>TriggeringPolicy</td>
<td>The policy to use to determine if a rollover should occur.</td>
</tr>
<tr class="a">
<td>strategy</td>
<td>RolloverStrategy</td>
<td>The strategy to use to determine the name and location of the archive file.</td>
</tr>
<tr class="b">
<td>suppressExceptions</td>
<td>boolean</td>
<td>The default is true, causing exceptions to be internally logged and then ignored. When set to
false exceptions will be percolated to the caller.</td>
</tr>
</table>
<a name="TriggeringPolicies"></a>
<div class="section"><h4>Triggering Policies<a name="Triggering_Policies"></a></h4>
<div class="section"><h5>Composite Triggering Policy<a name="Composite_Triggering_Policy"></a></h5>
<p>
The CompositeTriggeringPolicy combines multiple triggering policies and returns true if any
of the configured policies return true. The CompositeTriggeringPolicy is configured simply
by wrapping other policies in a &quot;Policies&quot; element.
</p>
</div><div class="section"><h5>OnStartup Triggering Policy<a name="OnStartup_Triggering_Policy"></a></h5>
<p>
The OnStartup policy takes no parameters and causes a rollover if the log file is older than the
current JVM's start time.
</p>
</div><div class="section"><h5>SizeBased Triggering Policy<a name="SizeBased_Triggering_Policy"></a></h5>
<p>
Causes a rollover once the file has reached the specified size. The size can be specified in bytes,
KB, MB or GB.
</p>
</div><div class="section"><h5>TimeBased Triggering Policy<a name="TimeBased_Triggering_Policy"></a></h5>
<p>
Causes a rollover once the date/time pattern no longer applies to the active file. This policy
takes no parameters.
</p>
<a name="RolloverStrategies"></a>
</div></div><div class="section"><h4>Rollover Strategies<a name="Rollover_Strategies"></a></h4>
<a name="DefaultRolloverStrategy"></a>
<div class="section"><h5>Default Rollover Strategy<a name="Default_Rollover_Strategy"></a></h5>
<p>
The default rollover strategy accepts both a date/time pattern and an integer. If the date/time pattern
is present it will be replaced with the current date and time values. If the pattern contains an integer
it will be incremented on each rollover. If the pattern contains both a date/time and integer
in the pattern the integer will be incremented until the result of the date/time pattern changes. If
the file pattern ends with &quot;.gz&quot; or &quot;.zip&quot; the resulting archive will be compressed using the
compression scheme that matches the suffix. The pattern may also contain lookup references that
can be resolved at runtime such as is shown in the example below.
</p>
<table class="zebra-striped" border="1" width="100%"><caption align="top">DefaultRolloverStrategy Parameters</caption>
<tr class="a">
<th>Parameter Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr class="b">
<td>min</td>
<td>integer</td>
<td>The minimum value of the counter. The default value is 1.</td>
</tr>
<tr class="a">
<td>max</td>
<td>integer</td>
<td>The maximum value of the counter. Once this values is reached. Older archives will be
deleted on subsequent rollovers.</td>
</tr>
</table>
<p>
Below is a sample configuration that uses a RollingFileAppender with both the time and size based
triggering policies, will create up to 7 archives on the same day (1-7) that are stored in a directory
based on the current year and month, and will compress each
archive using gzip:
</p><div class="source"><pre class="prettyprint">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;configuration status=&quot;warn&quot; name=&quot;MyApp&quot; packages=&quot;&quot;&gt;
&lt;appenders&gt;
&lt;RollingFile name=&quot;RollingFile&quot; fileName=&quot;logs/app.log&quot;
filePattern=&quot;logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log.gz&quot;&gt;
&lt;PatternLayout&gt;
&lt;pattern&gt;%d %p %C{1.} [%t] %m%n&lt;/pattern&gt;
&lt;/PatternLayout&gt;
&lt;Policies&gt;
&lt;TimeBasedTriggeringPolicy /&gt;
&lt;SizeBasedTriggeringPolicy size=&quot;250 MB&quot;/&gt;
&lt;/Policies&gt;
&lt;/RollingFile&gt;
&lt;/appenders&gt;
&lt;loggers&gt;
&lt;root level=&quot;error&quot;&gt;
&lt;appender-ref ref=&quot;RollingFile&quot;/&gt;
&lt;/root&gt;
&lt;/loggers&gt;
&lt;/configuration&gt;
</pre></div>
</div></div></div>
<a name="RoutingAppender"></a>
<div class="section"><h3>RoutingAppender<a name="RoutingAppender"></a></h3>
<p>
The RoutingAppender evaluates LogEvents and then routes them to a subordinate Appender. The target
Appender may be an appender previously configured and may be referenced by its name or the
Appender can be dynamically created as needed.
</p>
<table class="zebra-striped" border="1" width="100%"><caption align="top">RoutingAppender Parameters</caption>
<tr class="a">
<th>Parameter Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr class="b">
<td>filter</td>
<td>Filter</td>
<td>A Filter to determine if the event should be handled by this Appender. More than one Filter
may be used by using a CompositeFilter.</td>
</tr>
<tr class="a">
<td>name</td>
<td>String</td>
<td>The name of the Appender.</td>
</tr>
<tr class="b">
<td>rewritePolicy</td>
<td>RewritePolciy</td>
<td>The RewritePolicy that will manipulate the LogEvent.</td>
</tr>
<tr class="a">
<td>routes</td>
<td>Routes</td>
<td>Contains one or more Route declarations to identify the criteria for choosing Appenders.</td>
</tr>
<tr class="b">
<td>suppressExceptions</td>
<td>boolean</td>
<td>The default is true, causing exceptions to be internally logged and then ignored. When set to
false exceptions will be percolated to the caller.</td>
</tr>
</table>
<div class="section"><h4>Routes<a name="Routes"></a></h4>
<p>
The Routes element accepts a single, required attribute named &quot;pattern&quot;. The pattern is evaluated
against all the registered Lookups and the result is used to select a Route. Each Route may be
configured with a key. If the key matches the result of evaluating the pattern then that Route
will be selected. If no key is specified on a Route then that Route is the default. Only one Route
can be configured as the default.
</p>
<p>
Each Route must reference an Appender. If the Route contains an appender-ref attribute then the
Route will reference an Appender that was defined in the configuration. If the Route contains an
Appender definition then an Appender will be created within the context of the RoutingAppender and
will be reused each time a matching Appender name is referenced through a Route.
</p>
<p>
Below is a sample configuration that uses a RoutingAppender to route all Audit events to
a FlumeAppender and all other events will be routed to a RollingFileAppender that captures only
the specific event type. Note that the AuditAppender was predefined while the RollingFileAppenders
are created as needed.
</p><div class="source"><pre class="prettyprint">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;configuration status=&quot;warn&quot; name=&quot;MyApp&quot; packages=&quot;&quot;&gt;
&lt;appenders&gt;
&lt;Flume name=&quot;AuditLogger&quot; suppressExceptions=&quot;false&quot; compress=&quot;true&quot;&gt;
&lt;Agent host=&quot;192.168.10.101&quot; port=&quot;8800&quot;/&gt;
&lt;Agent host=&quot;192.168.10.102&quot; port=&quot;8800&quot;/&gt;
&lt;RFC5424Layout enterpriseNumber=&quot;18060&quot; includeMDC=&quot;true&quot; appName=&quot;MyApp&quot;/&gt;
&lt;/Flume&gt;
&lt;Routing name=&quot;Routing&quot;&gt;
&lt;Routes pattern=&quot;$${sd:type}&quot;&gt;
&lt;Route&gt;
&lt;RollingFile name=&quot;Rolling-${sd:type}&quot; fileName=&quot;${sd:type}.log&quot;
filePattern=&quot;${sd:type}.%i.log.gz&quot;&gt;
&lt;PatternLayout&gt;
&lt;pattern&gt;%d %p %C{1.} [%t] %m%n&lt;/pattern&gt;
&lt;/PatternLayout&gt;
&lt;SizeBasedTriggeringPolicy size=&quot;500&quot; /&gt;
&lt;/RollingFile&gt;
&lt;/Route&gt;
&lt;Route appender-ref=&quot;AuditLogger&quot; key=&quot;Audit&quot;/&gt;
&lt;/Routes&gt;
&lt;/Routing&gt;
&lt;/appenders&gt;
&lt;loggers&gt;
&lt;root level=&quot;error&quot;&gt;
&lt;appender-ref ref=&quot;Routing&quot;/&gt;
&lt;/root&gt;
&lt;/loggers&gt;
&lt;/configuration&gt;
</pre></div>
</div></div>
<a name="SocketAppender"></a>
<div class="section"><h3>SocketAppender<a name="SocketAppender"></a></h3>
<p>
The SocketAppender is an OutputStreamAppender that writes its output to a remote destination
specified by a host and port. The data can be sent over either TCP or UDP and can be sent in any format.
The default format is to send a Serialized LogEvent. Log4j 2 contains a SocketServer which is capable
of receiving serialized LogEvents and routing them through the logging system on the server.
</p>
<table class="zebra-striped" border="1" width="100%"><caption align="top">SocketAppender Parameters</caption>
<tr class="a">
<th>Parameter Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr class="b">
<td>filter</td>
<td>Filter</td>
<td>A Filter to determine if the event should be handled by this Appender. More than one Filter
may be used by using a CompositeFilter.</td>
</tr>
<tr class="a">
<td>host</td>
<td>String</td>
<td>The name or address of the system that is listening for log events. This parameter is required.</td>
</tr>
<tr class="b">
<td>immediateFlush</td>
<td>boolean</td>
<td>When set to true, each write will be followed by a flush. This will guarantee the data is written
to disk but could impact performance.</td>
</tr>
<tr class="a">
<td>layout</td>
<td>Layout</td>
<td>The Layout to use to format the LogEvent. The default is SerializedLayout.</td>
</tr>
<tr class="b">
<td>name</td>
<td>String</td>
<td>The name of the Appender.</td>
</tr>
<tr class="a">
<td>port</td>
<td>integer</td>
<td>The port on the host that is listening for log events. This parameter must be specified.</td>
</tr>
<tr class="b">
<td>protocol</td>
<td>String</td>
<td>&quot;TCP&quot; or &quot;UDP&quot;. This parameter is required.</td>
</tr>
<tr class="a">
<td>reconnectionDelay</td>
<td>integer</td>
<td>If set to a value greater than 0, after an error the SocketManager will attempt to reconnect to
the server after waiting the specified number of milliseconds. If the reconnect fails then
an exception will be thrown (which can be caught by the application if suppressExceptions is
set to false).</td>
</tr>
<tr class="b">
<td>suppressExceptions</td>
<td>boolean</td>
<td>The default is true, causing exceptions to be internally logged and then ignored. When set to
false exceptions will be percolated to the caller.</td>
</tr>
</table>
</div>
<a name="SyslogAppender"></a>
<div class="section"><h3>SyslogAppender<a name="SyslogAppender"></a></h3>
<p>
The SyslogAppender is a SocketAppender that writes its output to a remote destination
specified by a host and port in a format that conforms with either the BSD Syslog format or the RFC 5424
format. The data can be sent over either TCP or UDP.
</p>
<table class="zebra-striped" border="1" width="100%"><caption align="top">SyslogAppender Parameters</caption>
<tr class="a">
<th>Parameter Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr class="b">
<td>appName</td>
<td>String</td>
<td>The value to use as the APP-NAME in the RFC 5424 syslog record.</td>
</tr>
<tr class="a">
<td>charset</td>
<td>String</td>
<td>The character set to use when converting the syslog String to a byte array. The String must be
a valid <a class="externalLink" href="http://download.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html">Charset</a>.
If not specified, the default system Charset will be used.</td>
</tr>
<tr class="b">
<td>enterpriseNumber</td>
<td>integer</td>
<td>The IANA enterprise number as described in
<a class="externalLink" href="http://tools.ietf.org/html/rfc5424#section-7.2.2">RFC 5424</a></td>
</tr>
<tr class="a">
<td>filter</td>
<td>Filter</td>
<td>A Filter to determine if the event should be handled by this Appender. More than one Filter
may be used by using a CompositeFilter.</td>
</tr>
<tr class="b">
<td>facility</td>
<td>String</td>
<td>The facility is used to try to classify the message. The facility option must be set to one of
&quot;KERN&quot;, &quot;USER&quot;, &quot;MAIL&quot;, &quot;DAEMON&quot;, &quot;AUTH&quot;, &quot;SYSLOG&quot;, &quot;LPR&quot;, &quot;NEWS&quot;, &quot;UUCP&quot;, &quot;CRON&quot;, &quot;AUTHPRIV&quot;,
&quot;FTP&quot;, &quot;NTP&quot;, &quot;AUDIT&quot;, &quot;ALERT&quot;, &quot;CLOCK&quot;, &quot;LOCAL0&quot;, &quot;LOCAL1&quot;, &quot;LOCAL2&quot;, &quot;LOCAL3&quot;, &quot;LOCAL4&quot;, &quot;LOCAL5&quot;,
&quot;LOCAL6&quot;, or &quot;LOCAL7&quot;. These values may be specified as upper or lower case characters.</td>
</tr>
<tr class="a">
<td>format</td>
<td>String</td>
<td>If set to &quot;RFC5424&quot; the data will be formatted in accordance with RFC 5424. Otherwise, it will
be formatted as a BSD Syslog record. Note that although BSD Syslog records are required to be
1024 bytes or shorter the SyslogLayout does not truncate them. The RFC5424Layout also does not
truncate records since the receiver must accept records of up to 2048 bytes and may accept records
that are longer.</td>
</tr>
<tr class="b">
<td>host</td>
<td>String</td>
<td>The name or address of the system that is listening for log events. This parameter is required.</td>
</tr>
<tr class="a">
<td>id</td>
<td>String</td>
<td>The default structured data id to use when formatting according to RFC 5424. If the LogEvent contains
a StructuredDataMessage the id from the Message will be used instead of this value.</td>
</tr>
<tr class="b">
<td>immediateFlush</td>
<td>boolean</td>
<td>When set to true, each write will be followed by a flush. This will guarantee the data is written
to disk but could impact performance.</td>
</tr>
<tr class="a">
<td>includeMDC</td>
<td>boolean</td>
<td>Indicates whether data from the ThreadContextMap will be included in the RFC 5424 Syslog record.
Defaults to true.</td>
</tr>
<tr class="b">
<td>mdcExcludes</td>
<td>String</td>
<td>A comma separated list of mdc keys that should be excluded from the LogEvent. This is mutually
exclusive with the mdcIncludes attribute. This attribute only applies to RFC 5424 syslog records.</td>
</tr>
<tr class="a">
<td>mdcIncludes</td>
<td>String</td>
<td>A comma separated list of mdc keys that should be included in the FlumeEvent. Any keys in the MDC
not found in the list will be excluded. This option is mutually exclusive with the mdcExcludes
attribute. This attribute only applies to RFC 5424 syslog records.</td>
</tr>
<tr class="b">
<td>mdcRequired</td>
<td>String</td>
<td>A comma separated list of mdc keys that must be present in the MDC. If a key is not present a
LoggingException will be thrown. This attribute only applies to RFC 5424 syslog records.</td>
</tr>
<tr class="a">
<td>mdcPrefix</td>
<td>String</td>
<td>A string that should be prepended to each MDC key in order to distinguish it from event attributes.
The default string is &quot;mdc:&quot;. This attribute only applies to RFC 5424 syslog records.</td>
</tr>
<tr class="b">
<td>messageId</td>
<td>String</td>
<td>The default value to be used in the MSGID field of RFC 5424 syslog records. </td>
</tr>
<tr class="a">
<td>name</td>
<td>String</td>
<td>The name of the Appender.</td>
</tr>
<tr class="b">
<td>newLine</td>
<td>boolean</td>
<td>If true, a newline will be appended to the end of the syslog record. The default is false.</td>
</tr>
<tr class="a">
<td>port</td>
<td>integer</td>
<td>The port on the host that is listening for log events. This parameter must be specified.</td>
</tr>
<tr class="b">
<td>protocol</td>
<td>String</td>
<td>&quot;TCP&quot; or &quot;UDP&quot;. This parameter is required.</td>
</tr>
<tr class="a">
<td>reconnectionDelay</td>
<td>integer</td>
<td>If set to a value greater than 0, after an error the SocketManager will attempt to reconnect to
the server after waiting the specified number of milliseconds. If the reconnect fails then
an exception will be thrown (which can be caught by the application if suppressExceptions is
set to false).</td>
</tr>
<tr class="b">
<td>suppressExceptions</td>
<td>boolean</td>
<td>The default is true, causing exceptions to be internally logged and then ignored. When set to
false exceptions will be percolated to the caller.</td>
</tr>
</table>
<p>
A sample syslogAppender configuration that is configured with two SyslogAppenders, one using the BSD
format and one using RFC 5424.
</p><div class="source"><pre class="prettyprint">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;configuration status=&quot;warn&quot; name=&quot;MyApp&quot; packages=&quot;&quot;&gt;
&lt;appenders&gt;
&lt;Syslog name=&quot;bsd&quot; host=&quot;localhost&quot; port=&quot;514&quot; protocol=&quot;TCP&quot;/&gt;
&lt;Syslog name=&quot;RFC5424&quot; format=&quot;RFC5424&quot; host=&quot;localhost&quot; port=&quot;8514&quot; protocol=&quot;TCP&quot; appName=&quot;MyApp&quot; includeMDC=&quot;true&quot;
facility=&quot;LOCAL0&quot; enterpriseNumber=&quot;18060&quot; newLine=&quot;true&quot; messageId=&quot;Audit&quot; id=&quot;App&quot;/&gt;
&lt;/appenders&gt;
&lt;loggers&gt;
&lt;logger name=&quot;com.mycorp&quot; level=&quot;error&quot;&gt;
&lt;appender-ref ref=&quot;RFC5424&quot;/&gt;
&lt;/logger&gt;
&lt;root level=&quot;error&quot;&gt;
&lt;appender-ref ref=&quot;bsd&quot;/&gt;
&lt;/root&gt;
&lt;/loggers&gt;
&lt;/configuration&gt;
</pre></div>
</div>
</div>
</div>
</div>
<hr/>
<footer>
<div class="container-fluid">
<div class="row span16">Copyright &copy; 1999-2012
<a href="http://www.apache.org">Apache Software Foundation</a>.
All Rights Reserved.
</div>
</div>
</footer>
</body>
</html>