org.apache.logging.log4j.core.appender
Class SocketAppender

java.lang.Object
  extended by org.apache.logging.log4j.core.AbstractLifeCycle
      extended by org.apache.logging.log4j.core.filter.AbstractFilterable
          extended by org.apache.logging.log4j.core.appender.AbstractAppender
              extended by org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender<AbstractSocketManager>
                  extended by org.apache.logging.log4j.core.appender.SocketAppender
All Implemented Interfaces:
Appender, Filterable, LifeCycle
Direct Known Subclasses:
SyslogAppender

@Plugin(name="Socket",
        category="Core",
        elementType="appender",
        printObject=true)
public class SocketAppender
extends AbstractOutputStreamAppender<AbstractSocketManager>

An Appender that delivers events over socket connections. Supports both TCP and UDP.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.logging.log4j.core.LifeCycle
LifeCycle.State
 
Field Summary
 
Fields inherited from class org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender
immediateFlush
 
Fields inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
LOGGER
 
Constructor Summary
protected SocketAppender(String name, Layout<? extends Serializable> layout, Filter filter, AbstractSocketManager manager, boolean ignoreExceptions, boolean immediateFlush, Advertiser advertiser)
           
 
Method Summary
static SocketAppender createAppender(String host, String portNum, String protocolStr, SslConfiguration sslConfig, String delay, String immediateFail, String name, String immediateFlush, String ignore, Layout<? extends Serializable> layout, Filter filter, String advertise, Configuration config)
           
protected static AbstractSocketManager createSocketManager(String name, Protocol protocol, String host, int port, SslConfiguration sslConfig, int delay, boolean immediateFail, Layout<? extends Serializable> layout)
          Creates an AbstractSocketManager for TCP, UDP, and SSL.
 void stop()
          Cleanup the Filter.
 
Methods inherited from class org.apache.logging.log4j.core.appender.AbstractOutputStreamAppender
append, getManager, start
 
Methods inherited from class org.apache.logging.log4j.core.appender.AbstractAppender
error, error, error, getHandler, getLayout, getName, ignoreExceptions, parseInt, setHandler, toString
 
Methods inherited from class org.apache.logging.log4j.core.filter.AbstractFilterable
addFilter, getFilter, hasFilter, isFiltered, removeFilter
 
Methods inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
getState, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStopping
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.logging.log4j.core.LifeCycle
isStarted, isStopped
 

Constructor Detail

SocketAppender

protected SocketAppender(String name,
                         Layout<? extends Serializable> layout,
                         Filter filter,
                         AbstractSocketManager manager,
                         boolean ignoreExceptions,
                         boolean immediateFlush,
                         Advertiser advertiser)
Method Detail

stop

public void stop()
Description copied from class: AbstractFilterable
Cleanup the Filter.

Specified by:
stop in interface LifeCycle
Overrides:
stop in class AbstractOutputStreamAppender<AbstractSocketManager>

createAppender

@PluginFactory
public static SocketAppender createAppender(@PluginAttribute(value="host")
                                                          String host,
                                                          @PluginAttribute(value="port")
                                                          String portNum,
                                                          @PluginAttribute(value="protocol")
                                                          String protocolStr,
                                                          @PluginElement(value="SSL")
                                                          SslConfiguration sslConfig,
                                                          @PluginAttribute(value="reconnectionDelay")
                                                          String delay,
                                                          @PluginAttribute(value="immediateFail")
                                                          String immediateFail,
                                                          @PluginAttribute(value="name")
                                                          String name,
                                                          @PluginAttribute(value="immediateFlush")
                                                          String immediateFlush,
                                                          @PluginAttribute(value="ignoreExceptions")
                                                          String ignore,
                                                          @PluginElement(value="Layout")
                                                          Layout<? extends Serializable> layout,
                                                          @PluginElement(value="Filter")
                                                          Filter filter,
                                                          @PluginAttribute(value="advertise")
                                                          String advertise,
                                                          @PluginConfiguration
                                                          Configuration config)
Parameters:
host - The name of the host to connect to.
portNum - The port to connect to on the target host.
protocolStr - The Protocol to use.
sslConfig - The SSL configuration file for TCP/SSL, ignored for UPD.
delay - The interval in which failed writes should be retried.
immediateFail - True if the write should fail if no socket is immediately available.
name - The name of the Appender.
immediateFlush - "true" if data should be flushed on each write.
ignore - If "true" (default) exceptions encountered when appending events are logged; otherwise they are propagated to the caller.
layout - The layout to use (defaults to SerializedLayout).
filter - The Filter or null.
advertise - "true" if the appender configuration should be advertised, "false" otherwise.
config - The Configuration
Returns:
A SocketAppender.

createSocketManager

protected static AbstractSocketManager createSocketManager(String name,
                                                           Protocol protocol,
                                                           String host,
                                                           int port,
                                                           SslConfiguration sslConfig,
                                                           int delay,
                                                           boolean immediateFail,
                                                           Layout<? extends Serializable> layout)
Creates an AbstractSocketManager for TCP, UDP, and SSL.

Throws:
IllegalArgumentException - if the protocol cannot be handled.


Copyright © 1999-2014 Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.