Package com.dua3.utility.logging.log4j
Class LogAppenderLog4j
java.lang.Object
org.apache.logging.log4j.core.AbstractLifeCycle
org.apache.logging.log4j.core.filter.AbstractFilterable
org.apache.logging.log4j.core.appender.AbstractAppender
com.dua3.utility.logging.log4j.LogAppenderLog4j
- 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 LogAppenderLog4j
extends org.apache.logging.log4j.core.appender.AbstractAppender
This class is an implementation of the Log4j Appender and LogEntryHandlerPool interfaces.
It is used as an appender for log events and provides a mechanism for forwarding log4j log events to applications.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
This class represents an implementation of the LogEntryDispatcher interface using Log4J.Nested classes/interfaces inherited from class org.apache.logging.log4j.core.appender.AbstractAppender
org.apache.logging.log4j.core.appender.AbstractAppender.Builder<B extends org.apache.logging.log4j.core.appender.AbstractAppender.Builder<B>>
Nested classes/interfaces inherited from interface org.apache.logging.log4j.core.LifeCycle
org.apache.logging.log4j.core.LifeCycle.State
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The name of the appender class used in the log4j configuration.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
ConstructorsModifierConstructorDescriptionprotected
LogAppenderLog4j
(String name, @Nullable org.apache.logging.log4j.core.Filter filter, @Nullable org.apache.logging.log4j.core.Layout<? extends Serializable> layout, boolean ignoreExceptions) Constructs a new instance of LogAppenderLog4j with the specified parameters. -
Method Summary
Modifier and TypeMethodDescriptionvoid
append
(org.apache.logging.log4j.core.LogEvent event) Dispatches a log event to the list of log entry handlers.static LogAppenderLog4j
createAppender
(@Nullable String name, boolean ignoreExceptions, @Nullable org.apache.logging.log4j.core.Layout<? extends Serializable> layout, @Nullable org.apache.logging.log4j.core.Filter filter) Creates a LogAppenderLog4j object with the specified parameters.Returns the LogEntryDispatcher associated with the LogAppenderLog4j instance.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
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.logging.log4j.core.LifeCycle
getState, initialize, isStarted, isStopped, start, stop
-
Field Details
-
APPENDER_NAME
The name of the appender class used in the log4j configuration.This variable holds the simple name of the log4j appender class used in the application's log4j configuration.
-
-
Constructor Details
-
LogAppenderLog4j
protected LogAppenderLog4j(String name, @Nullable org.apache.logging.log4j.core.Filter filter, @Nullable org.apache.logging.log4j.core.Layout<? extends Serializable> layout, boolean ignoreExceptions) Constructs a new instance of LogAppenderLog4j with the specified parameters.- Parameters:
name
- the name of the appenderfilter
- the filter to be used for filtering log events (nullable)layout
- the layout to be used for formatting log events (nullable)ignoreExceptions
- specifies whether exceptions should be ignored or not
-
-
Method Details
-
createAppender
@PluginFactory public static LogAppenderLog4j createAppender(@PluginAttribute("name") @Nullable String name, @PluginAttribute("ignoreExceptions") boolean ignoreExceptions, @PluginElement("Layout") @Nullable org.apache.logging.log4j.core.Layout<? extends Serializable> layout, @PluginElement("Filters") @Nullable org.apache.logging.log4j.core.Filter filter) Creates a LogAppenderLog4j object with the specified parameters.- Parameters:
name
- the name of the appenderignoreExceptions
- whether to ignore exceptions thrown by the appenderlayout
- the layout for formatting log messagesfilter
- the filter for filtering log events- Returns:
- a LogAppenderLog4j object
-
append
public void append(org.apache.logging.log4j.core.LogEvent event) Dispatches a log event to the list of log entry handlers.This method iterates over the list of log entry handlers and invokes the `handleEntry` method on each not garbage collected handler.
If any garbage collected log entry handler is detected, the log entry list is cleaned up.
- Parameters:
event
- the log event to be appended
-
dispatcher
Returns the LogEntryDispatcher associated with the LogAppenderLog4j instance.- Returns:
- the LogEntryDispatcher
-