Class LoadBalancingLog4jAppender

  extended by org.apache.log4j.AppenderSkeleton
      extended by org.apache.flume.clients.log4jappender.Log4jAppender
          extended by org.apache.flume.clients.log4jappender.LoadBalancingLog4jAppender
All Implemented Interfaces:
org.apache.log4j.Appender, org.apache.log4j.spi.OptionHandler

public class LoadBalancingLog4jAppender
extends Log4jAppender

Appends Log4j Events to an external Flume client which is decribed by the Log4j configuration file. The appender takes the following required parameters:

Hosts : A space separated list of host:port of the first hop at which Flume (through an AvroSource) is listening for events.

Selector : Selection mechanism. Must be either ROUND_ROBIN, RANDOM or custom FQDN to class that inherits from LoadBalancingSelector. If empty defaults to ROUND_ROBIN

The appender also takes the following optional parameters:

MaxBackoff : A long value representing the maximum amount of time in milliseconds the Load balancing client will backoff from a node that has failed to consume an event

A sample log4j properties file which appends to a source would look like:

log4j.appender.out2 = org.apache.flume.clients.log4jappender.LoadBalancingLog4jAppender log4j.appender.out2.Hosts = log4j.appender.out2.Selector = RANDOM = DEBUG,out2


log4j.appender.out2 = org.apache.flume.clients.log4jappender.LoadBalancingLog4jAppender log4j.appender.out2.Hosts = log4j.appender.out2.Selector = ROUND_ROBIN log4j.appender.out2.MaxBackoff = 60000 = DEBUG,out2

Note: Change the last line to the package of the class(es), that will do the appending.For example if classes from the package are appending, the last line would be: = DEBUG,out2

Field Summary
Fields inherited from class org.apache.log4j.AppenderSkeleton
closed, errorHandler, headFilter, layout, name, tailFilter, threshold
Constructor Summary
Method Summary
 void activateOptions()
          Activate the options set using setHosts(), setSelector and setMaxBackoff
 void append(org.apache.log4j.spi.LoggingEvent event)
          Append the LoggingEvent, to send to the first Flume hop.
 void setHosts(String hostNames)
 void setMaxBackoff(String maxBackoff)
 void setSelector(String selector)
Methods inherited from class org.apache.flume.clients.log4jappender.Log4jAppender
close, getTimeout, getUnsafeMode, populateAvroHeaders, requiresLayout, setAvroReflectionEnabled, setAvroSchemaUrl, setHostname, setPort, setTimeout, setUnsafeMode
Methods inherited from class org.apache.log4j.AppenderSkeleton
addFilter, clearFilters, doAppend, finalize, getErrorHandler, getFilter, getFirstFilter, getLayout, getName, getThreshold, isAsSevereAsThreshold, setErrorHandler, setLayout, setName, setThreshold
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public LoadBalancingLog4jAppender()
Method Detail


public void setHosts(String hostNames)


public void setSelector(String selector)


public void setMaxBackoff(String maxBackoff)


public void append(org.apache.log4j.spi.LoggingEvent event)
Description copied from class: Log4jAppender
Append the LoggingEvent, to send to the first Flume hop.

append in class Log4jAppender
event - The LoggingEvent to be appended to the flume.


public void activateOptions()
                     throws FlumeException
Activate the options set using setHosts(), setSelector and setMaxBackoff

Specified by:
activateOptions in interface org.apache.log4j.spi.OptionHandler
activateOptions in class Log4jAppender
FlumeException - if the LoadBalancingRpcClient cannot be instantiated.

Copyright © 2009-2013 Apache Software Foundation. All Rights Reserved.