org.apache.logging.log4j.flume.appender
Class FlumeEvent

java.lang.Object
  extended by org.apache.flume.event.SimpleEvent
      extended by org.apache.logging.log4j.flume.appender.FlumeEvent
All Implemented Interfaces:
Serializable, org.apache.flume.Event, LogEvent

public class FlumeEvent
extends org.apache.flume.event.SimpleEvent
implements LogEvent

Class that is both a Flume and Log4j Event.

See Also:
Serialized Form

Constructor Summary
FlumeEvent(LogEvent event, String includes, String excludes, String required, String mdcPrefix, String eventPrefix, boolean compress)
          Construct the FlumeEvent.
 
Method Summary
protected  void addContextData(String prefix, Map<String,String> fields, Map<String,String> context)
           
protected  void addGuid(Map<String,String> fields)
           
protected  void addMapData(String prefix, Map<String,String> fields, MapMessage msg)
           
protected  void addStructuredData(String prefix, Map<String,String> fields, StructuredDataMessage msg)
           
 Map<String,String> getContextMap()
          Returns a copy of the context Map.
 ThreadContext.ContextStack getContextStack()
          Returns a copy of the context stack.
 String getFQCN()
          Get the Frequently Qualified Class Name.
 Level getLevel()
          Returns the logging Level.
 String getLoggerName()
          Returns the logger name.
 Marker getMarker()
          Returns the Marker.
 Message getMessage()
          Returns the Message.
 long getMillis()
          Returns the event timestamp.
 StackTraceElement getSource()
          Returns the StackTraceElement for the caller of the logging API.
 String getThreadName()
          Returns the name of the Thread.
 Throwable getThrown()
          Returns the Throwable associated with the event, if any.
 void setBody(byte[] body)
          Set the body in the event.
 
Methods inherited from class org.apache.flume.event.SimpleEvent
getBody, getHeaders, setHeaders, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FlumeEvent

public FlumeEvent(LogEvent event,
                  String includes,
                  String excludes,
                  String required,
                  String mdcPrefix,
                  String eventPrefix,
                  boolean compress)
Construct the FlumeEvent.

Parameters:
event - The Log4j LogEvent.
includes - A comma separated list of MDC elements to include.
excludes - A comma separated list of MDC elements to exclude.
required - A comma separated list of MDC elements that are required to be defined.
mdcPrefix - The value to prefix to MDC keys.
eventPrefix - The value to prefix to event keys.
compress - If true the event body should be compressed.
Method Detail

addStructuredData

protected void addStructuredData(String prefix,
                                 Map<String,String> fields,
                                 StructuredDataMessage msg)

addMapData

protected void addMapData(String prefix,
                          Map<String,String> fields,
                          MapMessage msg)

addContextData

protected void addContextData(String prefix,
                              Map<String,String> fields,
                              Map<String,String> context)

addGuid

protected void addGuid(Map<String,String> fields)

setBody

public void setBody(byte[] body)
Set the body in the event.

Specified by:
setBody in interface org.apache.flume.Event
Overrides:
setBody in class org.apache.flume.event.SimpleEvent
Parameters:
body - The body to add to the event.

getFQCN

public String getFQCN()
Get the Frequently Qualified Class Name.

Specified by:
getFQCN in interface LogEvent
Returns:
the FQCN String.

getLevel

public Level getLevel()
Returns the logging Level.

Specified by:
getLevel in interface LogEvent
Returns:
the Level.

getLoggerName

public String getLoggerName()
Returns the logger name.

Specified by:
getLoggerName in interface LogEvent
Returns:
the logger name.

getSource

public StackTraceElement getSource()
Returns the StackTraceElement for the caller of the logging API.

Specified by:
getSource in interface LogEvent
Returns:
the StackTraceElement of the caller.

getMessage

public Message getMessage()
Returns the Message.

Specified by:
getMessage in interface LogEvent
Returns:
the Message.

getMarker

public Marker getMarker()
Returns the Marker.

Specified by:
getMarker in interface LogEvent
Returns:
the Marker.

getThreadName

public String getThreadName()
Returns the name of the Thread.

Specified by:
getThreadName in interface LogEvent
Returns:
the name of the Thread.

getMillis

public long getMillis()
Returns the event timestamp.

Specified by:
getMillis in interface LogEvent
Returns:
the event timestamp.

getThrown

public Throwable getThrown()
Returns the Throwable associated with the event, if any.

Specified by:
getThrown in interface LogEvent
Returns:
the Throwable.

getContextMap

public Map<String,String> getContextMap()
Returns a copy of the context Map.

Specified by:
getContextMap in interface LogEvent
Returns:
a copy of the context Map.

getContextStack

public ThreadContext.ContextStack getContextStack()
Returns a copy of the context stack.

Specified by:
getContextStack in interface LogEvent
Returns:
a copy of the context stack.


Copyright © 1999-2012 Apache Software Foundation. All Rights Reserved.