Package org.apache.logging.log4j.mongodb
Class MongoDbProvider
- java.lang.Object
-
- org.apache.logging.log4j.mongodb.MongoDbProvider
-
- All Implemented Interfaces:
NoSqlProvider<MongoDbConnection>
@Plugin(name="MongoDb", category="Core", printObject=true) public final class MongoDbProvider extends java.lang.Object implements NoSqlProvider<MongoDbConnection>
The MongoDB implementation ofNoSqlProvider
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MongoDbProvider.Builder<B extends MongoDbProvider.Builder<B>>
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static MongoDbProvider
createNoSqlProvider(java.lang.String collectionName, java.lang.String writeConcernConstant, java.lang.String writeConcernConstantClassName, java.lang.String databaseName, java.lang.String server, java.lang.String port, java.lang.String userName, java.lang.String password, java.lang.String factoryClassName, java.lang.String factoryMethodName)
Deprecated.in 2.8; usenewBuilder()
instead.MongoDbConnection
getConnection()
Obtains a connection from this provider.static <B extends MongoDbProvider.Builder<B>>
BnewBuilder()
java.lang.String
toString()
All implementations must overrideObject.toString()
to provide information about the provider configuration (obscuring passwords with one-way hashes).
-
-
-
Method Detail
-
getConnection
public MongoDbConnection getConnection()
Description copied from interface:NoSqlProvider
Obtains a connection from this provider. The concept of a connection in this case is not strictly an active duplex UDP or TCP connection to the underlying database. It can be thought of more as a gateway, a path for inserting objects that may use a persistent connection or may use HTTP web service calls, etc.Where applicable, this method should return a connection from the connection pool as opposed to opening a brand new connection every time.
- Specified by:
getConnection
in interfaceNoSqlProvider<MongoDbConnection>
- Returns:
- a connection that can be used to create and persist objects to this database.
- See Also:
NoSqlConnection
-
toString
public java.lang.String toString()
Description copied from interface:NoSqlProvider
All implementations must overrideObject.toString()
to provide information about the provider configuration (obscuring passwords with one-way hashes).- Specified by:
toString
in interfaceNoSqlProvider<MongoDbConnection>
- Overrides:
toString
in classjava.lang.Object
- Returns:
- the string representation of this NoSQL provider.
-
createNoSqlProvider
@PluginFactory public static MongoDbProvider createNoSqlProvider(java.lang.String collectionName, java.lang.String writeConcernConstant, java.lang.String writeConcernConstantClassName, java.lang.String databaseName, java.lang.String server, java.lang.String port, java.lang.String userName, java.lang.String password, java.lang.String factoryClassName, java.lang.String factoryMethodName)
Deprecated.in 2.8; usenewBuilder()
instead.Factory method for creating a MongoDB provider within the plugin manager.- Parameters:
collectionName
- The name of the MongoDB collection to which log events should be written.writeConcernConstant
- TheWriteConcern
constant to control writing details, defaults toWriteConcern.ACKNOWLEDGED
.writeConcernConstantClassName
- The name of a class containing the aforementioned static WriteConcern constant. Defaults toWriteConcern
.databaseName
- The name of the MongoDB database containing the collection to which log events should be written. Mutually exclusive withfactoryClassName&factoryMethodName!=null
.server
- The host name of the MongoDB server, defaults to localhost and mutually exclusive withfactoryClassName&factoryMethodName!=null
.port
- The port the MongoDB server is listening on, defaults to the default MongoDB port and mutually exclusive withfactoryClassName&factoryMethodName!=null
.userName
- The username to authenticate against the MongoDB server with.password
- The password to authenticate against the MongoDB server with.factoryClassName
- A fully qualified class name containing a static factory method capable of returning aDB
or aMongoClient
.factoryMethodName
- The name of the public static factory method belonging to the aforementioned factory class.- Returns:
- a new MongoDB provider.
-
newBuilder
@PluginBuilderFactory public static <B extends MongoDbProvider.Builder<B>> B newBuilder()
-
-