Class Log4jNullAppender
- java.lang.Object
-
- org.apache.logging.log4j.core.AbstractLifeCycle
-
- org.apache.logging.log4j.core.filter.AbstractFilterable
-
- org.apache.logging.log4j.core.appender.AbstractAppender
-
- com.github.robtimus.junit.support.extension.testlogger.Log4jNullAppender
-
- All Implemented Interfaces:
Appender,Filterable,LocationAware,LifeCycle,LifeCycle2
public class Log4jNullAppender extends AbstractAppender
An appender that ignores events. This is much likeNullAppender, except thatappend(LogEvent)callsignore(LogEvent)with immutable events.- Author:
- Rob Spoor
- Since:
- 2.1
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLog4jNullAppender.BuilderA builder forLog4jNullAppenderinstances.-
Nested classes/interfaces inherited from interface org.apache.logging.log4j.core.LifeCycle
LifeCycle.State
-
-
Field Summary
-
Fields inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGER
-
Fields inherited from interface org.apache.logging.log4j.core.Appender
ELEMENT_TYPE, EMPTY_ARRAY
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedLog4jNullAppender(String name, Filter filter, Layout<? extends Serializable> layout, boolean ignoreExceptions, Property[] properties)Creates a new appender.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappend(LogEvent event)Delegates toignore(LogEvent)with the result of callingLogEvent.toImmutable()on the given event.static Log4jNullAppendercreate(String name)Creates a named appender.voidignore(LogEvent event)Ignores an event.-
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
-
Log4jNullAppender
protected Log4jNullAppender(String name, Filter filter, Layout<? extends Serializable> layout, boolean ignoreExceptions, Property[] properties)
Creates a new appender.- Parameters:
name- The appender name.filter- The filter to associate with the appender.layout- The layout to use to format the event.ignoreExceptions- Iftrue, exceptions will be logged and suppressed. Iffalseerrors will be logged and then passed to the application.properties- An array of properties for the appender.
-
-
Method Detail
-
append
public final void append(LogEvent event)
Delegates toignore(LogEvent)with the result of callingLogEvent.toImmutable()on the given event.
-
ignore
public void ignore(LogEvent event)
Ignores an event.- Parameters:
event- The event to ignore.
-
create
public static Log4jNullAppender create(String name)
Creates a named appender. This method does the same as callingnew Builder().setName(name).build().- Parameters:
name- The appender name.- Returns:
- The created appender.
-
-