Class JpaAppender
java.lang.Object
org.apache.logging.log4j.core.AbstractLifeCycle
org.apache.logging.log4j.core.filter.AbstractFilterable
org.apache.logging.log4j.core.appender.AbstractAppender
org.apache.logging.log4j.core.appender.db.AbstractDatabaseAppender<JpaDatabaseManager>
org.apache.logging.log4j.core.appender.db.jpa.JpaAppender
- All Implemented Interfaces:
Appender
,Filterable
,LocationAware
,LifeCycle
,LifeCycle2
@Plugin(name="JPA",
category="Core",
elementType="appender",
printObject=true)
public final class JpaAppender
extends AbstractDatabaseAppender<JpaDatabaseManager>
This Appender writes logging events to a relational database using the Java Persistence API. It requires a
pre-configured JPA persistence unit and a concrete implementation of the abstract
AbstractLogEventWrapperEntity
class decorated with JPA annotations.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.logging.log4j.core.appender.db.AbstractDatabaseAppender
AbstractDatabaseAppender.Builder<B extends AbstractDatabaseAppender.Builder<B>>
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.appender.db.AbstractDatabaseAppender
DEFAULT_RECONNECT_INTERVAL_MILLIS
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
-
Method Summary
Modifier and TypeMethodDescriptionstatic JpaAppender
createAppender
(String name, String ignore, Filter filter, String bufferSize, String entityClassName, String persistenceUnitName) Factory method for creating a JPA appender within the plugin manager.toString()
Methods inherited from class org.apache.logging.log4j.core.appender.db.AbstractDatabaseAppender
append, getLayout, getManager, replaceManager, start, stop
Methods inherited from class org.apache.logging.log4j.core.appender.AbstractAppender
error, error, error, getHandler, getName, ignoreExceptions, parseInt, requiresLocation, setHandler, toSerializable
Methods inherited from class org.apache.logging.log4j.core.filter.AbstractFilterable
addFilter, getFilter, getPropertyArray, hasFilter, isFiltered, removeFilter, 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
-
Method Details
-
toString
- Overrides:
toString
in classAbstractAppender
-
createAppender
@PluginFactory public static JpaAppender createAppender(@PluginAttribute("name") String name, @PluginAttribute("ignoreExceptions") String ignore, @PluginElement("Filter") Filter filter, @PluginAttribute("bufferSize") String bufferSize, @PluginAttribute("entityClassName") String entityClassName, @PluginAttribute("persistenceUnitName") String persistenceUnitName) Factory method for creating a JPA appender within the plugin manager.- Parameters:
name
- The name of the appender.ignore
- If"true"
(default) exceptions encountered when appending events are logged; otherwise they are propagated to the caller.filter
- The filter, if any, to use.bufferSize
- If an integer greater than 0, this causes the appender to buffer log events and flush whenever the buffer reaches this size.entityClassName
- The fully qualified name of the concreteAbstractLogEventWrapperEntity
implementation that has JPA annotations mapping it to a database table.persistenceUnitName
- The name of the JPA persistence unit that should be used for persisting log events.- Returns:
- a new JPA appender.
-