Package com.nuix.logging
Class LogEventCallbackAppender
- java.lang.Object
-
- org.apache.logging.log4j.core.AbstractLifeCycle
-
- org.apache.logging.log4j.core.filter.AbstractFilterable
-
- org.apache.logging.log4j.core.appender.AbstractAppender
-
- com.nuix.logging.LogEventCallbackAppender
-
- All Implemented Interfaces:
org.apache.logging.log4j.core.Appender
,org.apache.logging.log4j.core.filter.Filterable
,org.apache.logging.log4j.core.impl.LocationAware
,org.apache.logging.log4j.core.LifeCycle
,org.apache.logging.log4j.core.LifeCycle2
public class LogEventCallbackAppender extends org.apache.logging.log4j.core.appender.AbstractAppender
A custom log4j2 appender which forwardsLogEvent
objects to the provided consumer
-
-
Constructor Summary
Constructors Constructor Description LogEventCallbackAppender(java.lang.String name)
Creates a new instance with the given name and a filter that accepts ALL eventsLogEventCallbackAppender(java.lang.String name, java.util.function.Function<org.apache.logging.log4j.core.LogEvent,java.lang.Boolean> filteringFunction)
Creates a new instance with the given name and filterLogEventCallbackAppender(java.lang.String name, org.apache.logging.log4j.core.Filter filter)
Creates a new instance with the given name and filter
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
append(org.apache.logging.log4j.core.LogEvent event)
java.util.function.Consumer<org.apache.logging.log4j.core.LogEvent>
getEventConsumer()
Gets the Consumer that will be provided log eventsvoid
setEventConsumer(java.util.function.Consumer<org.apache.logging.log4j.core.LogEvent> eventConsumer)
Sets the consumer that will be provided log events-
Methods inherited from class org.apache.logging.log4j.core.appender.AbstractAppender
error, error, error, getHandler, getLayout, getName, ignoreExceptions, parseInt, requiresLocation, setHandler, toSerializable, toString
-
Methods inherited from class org.apache.logging.log4j.core.filter.AbstractFilterable
addFilter, getFilter, getPropertyArray, hasFilter, isFiltered, removeFilter, start, stop, stop
-
Methods inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
equalsImpl, getState, getStatusLogger, hashCodeImpl, initialize, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStopping, stop, stop
-
-
-
-
Constructor Detail
-
LogEventCallbackAppender
public LogEventCallbackAppender(java.lang.String name, org.apache.logging.log4j.core.Filter filter)
Creates a new instance with the given name and filter- Parameters:
name
- The name to assignfilter
- The filter to apply
-
LogEventCallbackAppender
public LogEventCallbackAppender(java.lang.String name, java.util.function.Function<org.apache.logging.log4j.core.LogEvent,java.lang.Boolean> filteringFunction)
Creates a new instance with the given name and filter- Parameters:
name
- The name to assignfilteringFunction
- A function which will be used to determine what events are filtered.
-
LogEventCallbackAppender
public LogEventCallbackAppender(java.lang.String name)
Creates a new instance with the given name and a filter that accepts ALL events- Parameters:
name
- The name to assign
-
-
Method Detail
-
append
public void append(org.apache.logging.log4j.core.LogEvent event)
- Parameters:
event
-
-
getEventConsumer
public java.util.function.Consumer<org.apache.logging.log4j.core.LogEvent> getEventConsumer()
Gets the Consumer that will be provided log events- Returns:
- The Consumer that will receive log events
-
setEventConsumer
public void setEventConsumer(java.util.function.Consumer<org.apache.logging.log4j.core.LogEvent> eventConsumer)
Sets the consumer that will be provided log events- Parameters:
eventConsumer
- The Consumer to receive log events
-
-