public final class JdbcDatabaseManager extends AbstractDatabaseManager
AbstractDatabaseManager
implementation for relational databases accessed via JDBC.AbstractDatabaseManager.AbstractFactoryData
count, LOGGER
Modifier and Type | Method and Description |
---|---|
protected void |
closeResources(boolean logExceptions) |
protected boolean |
commitAndClose()
Commits any active transaction (if applicable) and disconnects from the database (returns the connection to the
connection pool).
|
protected void |
connectAndStart()
Connects to the database and starts a transaction (if applicable).
|
ConnectionSource |
getConnectionSource() |
static JdbcDatabaseManager |
getJDBCDatabaseManager(String name,
int bufferSize,
ConnectionSource connectionSource,
String tableName,
ColumnConfig[] columnConfigs)
|
static JdbcDatabaseManager |
getManager(String name,
int bufferSize,
Layout<? extends Serializable> layout,
ConnectionSource connectionSource,
String tableName,
ColumnConfig[] columnConfigs,
ColumnMapping[] columnMappings)
Deprecated.
|
static JdbcDatabaseManager |
getManager(String name,
int bufferSize,
Layout<? extends Serializable> layout,
ConnectionSource connectionSource,
String tableName,
ColumnConfig[] columnConfigs,
ColumnMapping[] columnMappings,
boolean immediateFail,
long reconnectIntervalMillis)
|
static JdbcDatabaseManager |
getManager(String name,
int bufferSize,
Layout<? extends Serializable> layout,
ConnectionSource connectionSource,
String tableName,
ColumnConfig[] columnConfigs,
ColumnMapping[] columnMappings,
boolean immediateFail,
long reconnectIntervalMillis,
boolean truncateStrings)
Creates a JDBC manager for use within the
JdbcAppender , or returns a suitable one if it already exists. |
String |
getSqlStatement() |
String |
getTableName() |
protected boolean |
shutdownInternal()
Implementations should implement this method to perform any proprietary disconnection / shutdown operations.
|
protected void |
startupInternal()
Implementations should implement this method to perform any proprietary startup operations.
|
protected void |
writeInternal(LogEvent event,
Serializable serializable)
Performs the actual writing of the event in an implementation-specific way.
|
protected void |
writeThrough(LogEvent event,
Serializable serializable) |
buffer, flush, getManager, isBuffered, isRunning, releaseSub, shutdown, startup, toString, write, write, writeInternal
close, getContentFormat, getCount, getLoggerContext, getName, hasManager, log, logDebug, logError, logger, logWarn, narrow, release, stop, updateData
@Deprecated public static JdbcDatabaseManager getJDBCDatabaseManager(String name, int bufferSize, ConnectionSource connectionSource, String tableName, ColumnConfig[] columnConfigs)
getManager(String, int, Layout, ConnectionSource, String, ColumnConfig[], ColumnMapping[], boolean, long)
JdbcAppender
, or returns a suitable one if it already exists.name
- The name of the manager, which should include connection details and hashed passwords where possible.bufferSize
- The size of the log event buffer.connectionSource
- The source for connections to the database.tableName
- The name of the database table to insert log events into.columnConfigs
- Configuration information about the log table columns.@Deprecated public static JdbcDatabaseManager getManager(String name, int bufferSize, Layout<? extends Serializable> layout, ConnectionSource connectionSource, String tableName, ColumnConfig[] columnConfigs, ColumnMapping[] columnMappings)
JdbcAppender
, or returns a suitable one if it already exists.name
- The name of the manager, which should include connection details and hashed passwords where possible.bufferSize
- The size of the log event buffer.layout
- The Appender-level layoutconnectionSource
- The source for connections to the database.tableName
- The name of the database table to insert log events into.columnConfigs
- Configuration information about the log table columns.columnMappings
- column mapping configuration (including type conversion).@Deprecated public static JdbcDatabaseManager getManager(String name, int bufferSize, Layout<? extends Serializable> layout, ConnectionSource connectionSource, String tableName, ColumnConfig[] columnConfigs, ColumnMapping[] columnMappings, boolean immediateFail, long reconnectIntervalMillis)
getManager(String, int, Layout, ConnectionSource, String, ColumnConfig[], ColumnMapping[], boolean, long)
JdbcAppender
, or returns a suitable one if it already exists.name
- The name of the manager, which should include connection details and hashed passwords where possible.bufferSize
- The size of the log event buffer.layout
- connectionSource
- The source for connections to the database.tableName
- The name of the database table to insert log events into.columnConfigs
- Configuration information about the log table columns.columnMappings
- column mapping configuration (including type conversion).reconnectIntervalMillis
- immediateFail
- public static JdbcDatabaseManager getManager(String name, int bufferSize, Layout<? extends Serializable> layout, ConnectionSource connectionSource, String tableName, ColumnConfig[] columnConfigs, ColumnMapping[] columnMappings, boolean immediateFail, long reconnectIntervalMillis, boolean truncateStrings)
JdbcAppender
, or returns a suitable one if it already exists.name
- The name of the manager, which should include connection details and hashed passwords where possible.bufferSize
- The size of the log event buffer.layout
- The Appender-level layoutconnectionSource
- The source for connections to the database.tableName
- The name of the database table to insert log events into.columnConfigs
- Configuration information about the log table columns.columnMappings
- column mapping configuration (including type conversion).immediateFail
- Whether or not to fail immediately with a AppenderLoggingException
when connecting
to JDBC fails.reconnectIntervalMillis
- How often to reconnect to the database when a SQL exception is detected.truncateStrings
- Whether or not to truncate strings to match column metadata.protected void closeResources(boolean logExceptions)
protected boolean commitAndClose()
AbstractDatabaseManager
AbstractDatabaseManager.writeInternal(org.apache.logging.log4j.core.LogEvent)
. With buffering disabled, this is called immediately after every invocation of
AbstractDatabaseManager.writeInternal(org.apache.logging.log4j.core.LogEvent)
.commitAndClose
in class AbstractDatabaseManager
protected void connectAndStart()
AbstractDatabaseManager
AbstractDatabaseManager.writeInternal(org.apache.logging.log4j.core.LogEvent)
. With buffering disabled, this is
called immediately before every invocation of AbstractDatabaseManager.writeInternal(org.apache.logging.log4j.core.LogEvent)
.connectAndStart
in class AbstractDatabaseManager
public ConnectionSource getConnectionSource()
public String getSqlStatement()
public String getTableName()
protected boolean shutdownInternal()
AbstractDatabaseManager
AbstractDatabaseManager.startupInternal()
. It is safe to throw any exceptions from this method. This method does not
necessarily disconnect from the database for the same reasons outlined in AbstractDatabaseManager.startupInternal()
.shutdownInternal
in class AbstractDatabaseManager
protected void startupInternal() throws Exception
AbstractDatabaseManager
startupInternal
in class AbstractDatabaseManager
Exception
protected void writeInternal(LogEvent event, Serializable serializable)
AbstractDatabaseManager
AbstractDatabaseManager.write(LogEvent, Serializable)
if buffering is off, or from AbstractDatabaseManager.flush()
if the buffer has reached its limit.writeInternal
in class AbstractDatabaseManager
event
- The event to write to the database.protected void writeThrough(LogEvent event, Serializable serializable)
writeThrough
in class AbstractDatabaseManager
Copyright © 1999-2020 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.