org.apache.logging.log4j.nosql.appender.mongodb

Class MongoDbProvider

  • java.lang.Object
    • org.apache.logging.log4j.nosql.appender.mongodb.MongoDbProvider
    • 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 interface NoSqlProvider<MongoDbConnection>
        Returns:
        a connection that can be used to create and persist objects to this database.
        See Also:
        NoSqlConnection
      • createNoSqlProvider

        @PluginFactory
        public static MongoDbProvider createNoSqlProvider(@PluginAttribute(value="collectionName")
                                                        String collectionName,
                                                        @PluginAttribute(value="writeConcernConstant")
                                                        String writeConcernConstant,
                                                        @PluginAttribute(value="writeConcernConstantClass")
                                                        String writeConcernConstantClassName,
                                                        @PluginAttribute(value="databaseName")
                                                        String databaseName,
                                                        @PluginAttribute(value="server",defaultString="localhost")@ValidHost
                                                        String server,
                                                        @PluginAttribute(value="port",defaultString="27017")@ValidPort
                                                        String port,
                                                        @PluginAttribute(value="userName")
                                                        String userName,
                                                        @PluginAttribute(value="password",sensitive=true)
                                                        String password,
                                                        @PluginAttribute(value="factoryClassName")
                                                        String factoryClassName,
                                                        @PluginAttribute(value="factoryMethodName")
                                                        String factoryMethodName)
        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 - The WriteConcern constant to control writing details, defaults to WriteConcern.ACKNOWLEDGED.
        writeConcernConstantClassName - The name of a class containing the aforementioned static WriteConcern constant. Defaults to WriteConcern.
        databaseName - The name of the MongoDB database containing the collection to which log events should be written. Mutually exclusive with factoryClassName&factoryMethodName!=null.
        server - The host name of the MongoDB server, defaults to localhost and mutually exclusive with factoryClassName&factoryMethodName!=null.
        port - The port the MongoDB server is listening on, defaults to the default MongoDB port and mutually exclusive with factoryClassName&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 a DB or a MongoClient.
        factoryMethodName - The name of the public static factory method belonging to the aforementioned factory class.
        Returns:
        a new MongoDB provider.

Copyright © 1999-2017 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.