public abstract class AbstractAppender extends AbstractFilterable implements Appender, LocationAware
Modifier and Type | Class and Description |
---|---|
static class |
AbstractAppender.Builder<B extends AbstractAppender.Builder<B>>
Subclasses can extend this abstract Builder.
|
LifeCycle.State
DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT, LOGGER
ELEMENT_TYPE
Modifier | Constructor and Description |
---|---|
protected |
AbstractAppender(String name,
Filter filter,
Layout<? extends Serializable> layout)
Deprecated.
|
protected |
AbstractAppender(String name,
Filter filter,
Layout<? extends Serializable> layout,
boolean ignoreExceptions)
Deprecated.
|
protected |
AbstractAppender(String name,
Filter filter,
Layout<? extends Serializable> layout,
boolean ignoreExceptions,
Property[] properties)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
error(String msg)
Handle an error with a message using the
ErrorHandler configured for this Appender. |
void |
error(String msg,
LogEvent event,
Throwable t)
Handle an error with a message, exception, and a logging event, using the
ErrorHandler configured for
this Appender. |
void |
error(String msg,
Throwable t)
Handle an error with a message and an exception using the
ErrorHandler configured for this Appender. |
ErrorHandler |
getHandler()
Returns the ErrorHandler, if any.
|
Layout<? extends Serializable> |
getLayout()
Returns the Layout for the appender.
|
String |
getName()
Returns the name of the Appender.
|
boolean |
ignoreExceptions()
Some appenders need to propagate exceptions back to the application.
|
static int |
parseInt(String s,
int defaultValue) |
boolean |
requiresLocation() |
void |
setHandler(ErrorHandler handler)
The handler must be set before the appender is started.
|
protected Serializable |
toSerializable(LogEvent event)
Serializes the given event using the appender's layout if present.
|
String |
toString() |
addFilter, getFilter, getPropertyArray, hasFilter, isFiltered, removeFilter, start, stop, stop
equalsImpl, getState, getStatusLogger, hashCodeImpl, initialize, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStopping, stop, stop
@Deprecated protected AbstractAppender(String name, Filter filter, Layout<? extends Serializable> layout)
AbstractAppender(String, Filter, Layout, boolean, Property[])
.name
- The Appender name.filter
- The Filter to associate with the Appender.layout
- The layout to use to format the event.@Deprecated protected AbstractAppender(String name, Filter filter, Layout<? extends Serializable> layout, boolean ignoreExceptions)
AbstractAppender(String, Filter, Layout, boolean, Property[])
name
- The Appender name.filter
- The Filter to associate with the Appender.layout
- The layout to use to format the event.ignoreExceptions
- If true, exceptions will be logged and suppressed. If false errors will be logged and
then passed to the application.protected AbstractAppender(String name, Filter filter, Layout<? extends Serializable> layout, boolean ignoreExceptions, Property[] properties)
name
- The Appender name.filter
- The Filter to associate with the Appender.layout
- The layout to use to format the event.ignoreExceptions
- If true, exceptions will be logged and suppressed. If false errors will be logged and
then passed to the application.public boolean requiresLocation()
requiresLocation
in interface LocationAware
public void error(String msg)
ErrorHandler
configured for this Appender.msg
- The message.public void error(String msg, LogEvent event, Throwable t)
ErrorHandler
configured for
this Appender.msg
- The message.event
- The LogEvent.t
- The Throwable.public void error(String msg, Throwable t)
ErrorHandler
configured for this Appender.msg
- The message.t
- The Throwable.public ErrorHandler getHandler()
getHandler
in interface Appender
public Layout<? extends Serializable> getLayout()
public boolean ignoreExceptions()
ignoreExceptions
is
false
the AppenderControl will allow the exception to percolate.ignoreExceptions
in interface Appender
true
if exceptions will be logged but now thrown, false
otherwise.public void setHandler(ErrorHandler handler)
setHandler
in interface Appender
handler
- The ErrorHandler to use.protected Serializable toSerializable(LogEvent event)
event
- the event to serialize.Copyright © 1999-2021 The 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.