public class MongoDbManager extends org.apache.logging.log4j.core.appender.db.AbstractDatabaseManager
Warning: Because the MongoDB driver itself emits log messages, you
might cause recursion here that would lead to hangs and timeouts. The easiest
solution is to simply disable its logging via your Log4j configuration: just
set the org.mongodb.driver
logger to level Level.OFF
.
org.apache.logging.log4j.core.appender.db.AbstractDatabaseManager.AbstractFactoryData
count, LOGGER
Modifier | Constructor and Description |
---|---|
protected |
MongoDbManager(String name,
int bufferSize,
String uri,
com.mongodb.MongoClient client,
String databaseName,
String collectionName,
String writeConcernName) |
Modifier and Type | Method and Description |
---|---|
protected void |
commitAndClose() |
protected void |
connectAndStart() |
static MongoDbManager |
getMongoDbManager(String name,
int bufferSize,
String uri,
com.mongodb.MongoClient client,
String dbName,
String collectionName,
String writeConcernName)
Creates a MongoDB manager for use within the
MongoDbAppender , or
returns a suitable one if it already exists. |
protected void |
shutdownInternal() |
protected void |
startupInternal() |
protected void |
writeInternal(org.apache.logging.log4j.core.LogEvent event) |
flush, getManager, isRunning, releaseSub, shutdown, startup, toString, write
getContentFormat, getCount, getName, hasManager, release
public static MongoDbManager getMongoDbManager(String name, int bufferSize, String uri, com.mongodb.MongoClient client, String dbName, String collectionName, String writeConcernName)
MongoDbAppender
, 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.uri
- The MongoDB URI (see MongoClientURI
) (not used if "client"
is specified)client
- The MongoDB client (not used if "uri" is specified)dbName
- The MongoDB database namecollectionName
- The MongoDB collection namewriteConcernName
- The MongoDB write concern (see
WriteConcern.valueOf(String)
)protected void startupInternal() throws Exception
startupInternal
in class org.apache.logging.log4j.core.appender.db.AbstractDatabaseManager
Exception
protected void shutdownInternal() throws Exception
shutdownInternal
in class org.apache.logging.log4j.core.appender.db.AbstractDatabaseManager
Exception
protected void connectAndStart()
connectAndStart
in class org.apache.logging.log4j.core.appender.db.AbstractDatabaseManager
protected void writeInternal(org.apache.logging.log4j.core.LogEvent event)
writeInternal
in class org.apache.logging.log4j.core.appender.db.AbstractDatabaseManager
protected void commitAndClose()
commitAndClose
in class org.apache.logging.log4j.core.appender.db.AbstractDatabaseManager
Copyright © 2011-2016 Three Crickets LLC.