org.apache.flume.clients.log4jappender

## Class LoadBalancingLog4jAppender

- java.lang.Object
- - org.apache.log4j.AppenderSkeleton
  - - org.apache.flume.clients.log4jappender.Log4jAppender
    - - 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 = fooflumesource.com:25430 barflumesource.com:25430
       log4j.appender.out2.Selector = RANDOM
       log4j.logger.org.apache.flume.clients.log4jappender = DEBUG,out2

       log4j.appender.out2 = org.apache.flume.clients.log4jappender.LoadBalancingLog4jAppender
       log4j.appender.out2.Hosts = fooflumesource.com:25430 barflumesource.com:25430
       log4j.appender.out2.Selector = ROUND_ROBIN
       log4j.appender.out2.MaxBackoff = 60000
       log4j.logger.org.apache.flume.clients.log4jappender = 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 com.bar.foo are appending, the last line would be:

       log4j.logger.com.bar.foo = DEBUG,out2

- - ### Field Summary

    - ### Fields inherited from class org.apache.log4j.AppenderSkeleton

      `closed, errorHandler, headFilter, layout, name, tailFilter, threshold`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `LoadBalancingLog4jAppender()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `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

    - #### LoadBalancingLog4jAppender

          public LoadBalancingLog4jAppender()

  - ### Method Detail

    - #### setHosts

          public void setHosts(String hostNames)

    - #### setSelector

          public void setSelector(String selector)

    - #### setMaxBackoff

          public void setMaxBackoff(String maxBackoff)

    - #### append

          public void append(org.apache.log4j.spi.LoggingEvent event)

      Description copied from class: `Log4jAppender`
      Append the LoggingEvent, to send to the first Flume hop.
      Overrides:
        `append` in class `Log4jAppender`
      Parameters:
        `event` - The LoggingEvent to be appended to the flume.

    - #### activateOptions

          public void activateOptions()
                               throws FlumeException

      Activate the options set using `setHosts()`, `setSelector` and `setMaxBackoff`
      Specified by:
        `activateOptions` in interface `org.apache.log4j.spi.OptionHandler`
      Overrides:
        `activateOptions` in class `Log4jAppender`
      Throws:
        `FlumeException` - if the LoadBalancingRpcClient cannot be instantiated.

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