- java.lang.Object
-
- ch.qos.logback.core.spi.ContextAwareBase
-
- ch.qos.logback.core.UnsynchronizedAppenderBase<E>
-
- All Implemented Interfaces:
Appender<E>,ContextAware,FilterAttachable<E>,LifeCycle
- Direct Known Subclasses:
AsyncAppenderBase,OutputStreamAppender
public abstract class UnsynchronizedAppenderBase<E> extends ContextAwareBase implements Appender<E>
Similar toAppenderBaseexcept that derived appenders need to handle thread synchronization on their own.- Author:
- Ceki Gülcü, Ralph Goers
-
-
Field Summary
Fields Modifier and Type Field Description protected StringnameAppenders are named.protected booleanstarted-
Fields inherited from class ch.qos.logback.core.spi.ContextAwareBase
context
-
-
Constructor Summary
Constructors Constructor Description UnsynchronizedAppenderBase()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddFilter(Filter<E> newFilter)Add a filter.protected abstract voidappend(E eventObject)protected ReentryGuardbuildReentryGuard()Create aReentryGuardinstance used by this appender to prevent recursive/re-entrant calls todoAppend(Object).voidclearAllFilters()voiddoAppend(E eventObject)This is where an appender accomplishes its work: format and deliver the provided event to the appender's destination.List<Filter<E>>getCopyOfAttachedFiltersList()Get a copy of all the filters contained within this FilterAttachable object.FilterReplygetFilterChainDecision(E event)Loop through the filters in the chain.StringgetName()Get the name of this appender.booleanisStarted()voidsetName(String name)Set the name of this appender.voidstart()voidstop()StringtoString()-
Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ch.qos.logback.core.spi.ContextAware
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext
-
-
-
-
Constructor Detail
-
UnsynchronizedAppenderBase
public UnsynchronizedAppenderBase()
-
-
Method Detail
-
getName
public String getName()
Description copied from interface:AppenderGet the name of this appender. The name uniquely identifies the appender within its context and is used for configuration and lookup.
-
doAppend
public void doAppend(E eventObject)
Description copied from interface:AppenderThis is where an appender accomplishes its work: format and deliver the provided event to the appender's destination.Implementations should apply any configured filters before outputting the event. Implementations should avoid throwing runtime exceptions; if an error occurs that cannot be handled internally, a
LogbackException(or a subtype) may be thrown to indicate a failure during append.
-
buildReentryGuard
protected ReentryGuard buildReentryGuard()
Create aReentryGuardinstance used by this appender to prevent recursive/re-entrant calls todoAppend(Object).The default implementation returns a no-op guard produced by
ReentryGuardFactory.makeGuard(ch.qos.logback.core.util.ReentryGuardFactory.GuardType)usingGuardType.NOP. Subclasses that require actual re-entry protection (for example using a thread-local or lock-based guard) should override this method to return an appropriateReentryGuardimplementation.Contract/expectations:
- Called from
start()to initialize the appender's guard. - Implementations should be lightweight and thread-safe.
- Return value must not be
null.
- Returns:
- a non-null
ReentryGuardused to detect and prevent re-entrant appends. By default, this is a no-op guard. - Since:
- 1.5.21
- Called from
-
addFilter
public void addFilter(Filter<E> newFilter)
Description copied from interface:FilterAttachableAdd a filter.- Specified by:
addFilterin interfaceFilterAttachable<E>
-
clearAllFilters
public void clearAllFilters()
- Specified by:
clearAllFiltersin interfaceFilterAttachable<E>
-
getCopyOfAttachedFiltersList
public List<Filter<E>> getCopyOfAttachedFiltersList()
Description copied from interface:FilterAttachableGet a copy of all the filters contained within this FilterAttachable object.- Specified by:
getCopyOfAttachedFiltersListin interfaceFilterAttachable<E>- Returns:
- all attached filters as a list
-
getFilterChainDecision
public FilterReply getFilterChainDecision(E event)
Description copied from interface:FilterAttachableLoop through the filters in the chain. As soon as a filter decides on ACCEPT or DENY, then that value is returned. If all of the filters return NEUTRAL, then NEUTRAL is returned.- Specified by:
getFilterChainDecisionin interfaceFilterAttachable<E>
-
-