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, org.apache.logging.log4j.core.LogEvent

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

Class that is both a Flume and Log4j Event.

See Also:
Serialized Form

Constructor Summary
FlumeEvent(org.apache.logging.log4j.core.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 addMapData(String prefix, Map<String,String> fields, org.apache.logging.log4j.message.MapMessage msg)
           
protected  void addStructuredData(String prefix, Map<String,String> fields, org.apache.logging.log4j.message.StructuredDataMessage msg)
           
 Map<String,String> getContextMap()
          Returns a copy of the context Map.
 org.apache.logging.log4j.ThreadContext.ContextStack getContextStack()
          Returns a copy of the context stack.
 org.apache.logging.log4j.Level getLevel()
          Returns the logging Level.
 String getLoggerFqcn()
          Get the Frequently Qualified Class Name.
 String getLoggerName()
          Returns the logger name.
 org.apache.logging.log4j.Marker getMarker()
          Returns the Marker.
 org.apache.logging.log4j.message.Message getMessage()
          Returns the Message.
 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.
 org.apache.logging.log4j.core.impl.ThrowableProxy getThrownProxy()
          Returns the Throwable associated with the event, if any.
 long getTimeMillis()
          Returns the event timestamp.
 boolean isEndOfBatch()
           
 boolean isIncludeLocation()
           
 void setBody(byte[] body)
          Set the body in the event.
 void setEndOfBatch(boolean endOfBatch)
           
 void setIncludeLocation(boolean includeLocation)
           
 
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(org.apache.logging.log4j.core.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,
                                 org.apache.logging.log4j.message.StructuredDataMessage msg)

addMapData

protected void addMapData(String prefix,
                          Map<String,String> fields,
                          org.apache.logging.log4j.message.MapMessage msg)

addContextData

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

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.

getLoggerFqcn

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

Specified by:
getLoggerFqcn in interface org.apache.logging.log4j.core.LogEvent
Returns:
the FQCN String.

getLevel

public org.apache.logging.log4j.Level getLevel()
Returns the logging Level.

Specified by:
getLevel in interface org.apache.logging.log4j.core.LogEvent
Returns:
the Level.

getLoggerName

public String getLoggerName()
Returns the logger name.

Specified by:
getLoggerName in interface org.apache.logging.log4j.core.LogEvent
Returns:
the logger name.

getSource

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

Specified by:
getSource in interface org.apache.logging.log4j.core.LogEvent
Returns:
the StackTraceElement of the caller.

getMessage

public org.apache.logging.log4j.message.Message getMessage()
Returns the Message.

Specified by:
getMessage in interface org.apache.logging.log4j.core.LogEvent
Returns:
the Message.

getMarker

public org.apache.logging.log4j.Marker getMarker()
Returns the Marker.

Specified by:
getMarker in interface org.apache.logging.log4j.core.LogEvent
Returns:
the Marker.

getThreadName

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

Specified by:
getThreadName in interface org.apache.logging.log4j.core.LogEvent
Returns:
the name of the Thread.

getTimeMillis

public long getTimeMillis()
Returns the event timestamp.

Specified by:
getTimeMillis in interface org.apache.logging.log4j.core.LogEvent
Returns:
the event timestamp.

getThrown

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

Specified by:
getThrown in interface org.apache.logging.log4j.core.LogEvent
Returns:
the Throwable.

getThrownProxy

public org.apache.logging.log4j.core.impl.ThrowableProxy getThrownProxy()
Returns the Throwable associated with the event, if any.

Specified by:
getThrownProxy in interface org.apache.logging.log4j.core.LogEvent
Returns:
the Throwable.

getContextMap

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

Specified by:
getContextMap in interface org.apache.logging.log4j.core.LogEvent
Returns:
a copy of the context Map.

getContextStack

public org.apache.logging.log4j.ThreadContext.ContextStack getContextStack()
Returns a copy of the context stack.

Specified by:
getContextStack in interface org.apache.logging.log4j.core.LogEvent
Returns:
a copy of the context stack.

isIncludeLocation

public boolean isIncludeLocation()
Specified by:
isIncludeLocation in interface org.apache.logging.log4j.core.LogEvent

setIncludeLocation

public void setIncludeLocation(boolean includeLocation)
Specified by:
setIncludeLocation in interface org.apache.logging.log4j.core.LogEvent

isEndOfBatch

public boolean isEndOfBatch()
Specified by:
isEndOfBatch in interface org.apache.logging.log4j.core.LogEvent

setEndOfBatch

public void setEndOfBatch(boolean endOfBatch)
Specified by:
setEndOfBatch in interface org.apache.logging.log4j.core.LogEvent


Copyright © 1999-2015 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.