Index: log4j-nosql/src/main/java/org/apache/logging/log4j/nosql/appender/mongodb/MongoDbConnection.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- log4j-nosql/src/main/java/org/apache/logging/log4j/nosql/appender/mongodb/MongoDbConnection.java	(revision 8df207b9183339ec9c8bface521e3c6e8865d057)
+++ log4j-nosql/src/main/java/org/apache/logging/log4j/nosql/appender/mongodb/MongoDbConnection.java	(revision )
@@ -76,11 +76,7 @@
     @Override
     public void insertObject(final NoSqlObject<BasicDBObject> object) {
         try {
-            final WriteResult result = this.collection.insert(object.unwrap(), this.writeConcern);
-            if (Strings.isNotEmpty(result.getError())) {
-                throw new AppenderLoggingException("Failed to write log event to MongoDB due to error: " +
-                        result.getError() + '.');
-            }
+            this.collection.insert(object.unwrap(), this.writeConcern);
         } catch (final MongoException e) {
             throw new AppenderLoggingException("Failed to write log event to MongoDB due to error: " + e.getMessage(),
                     e);
@@ -96,32 +92,11 @@
 
     @Override
     public boolean isClosed() {
-        return !this.mongo.getConnector().isOpen();
-    }
-
-    /**
-     * To prevent class loading issues during plugin discovery, this code cannot live within MongoDbProvider. This
-     * is because of how Java treats references to Exception classes different from references to other classes. When
-     * Java loads a class, it normally won't load that class's dependent classes until and unless A) they are used, B)
-     * the class being loaded extends or implements those classes, or C) those classes are the types of static members
-     * in the class. However, exceptions that a class uses are always loaded when the class is loaded, even before
-     * they are actually used.
-     *
-     * @param database The database to authenticate
-     * @param username The username to authenticate with
-     * @param password The password to authenticate with
-     */
-    static void authenticate(final DB database, final String username, final String password) {
         try {
-            if (!database.authenticate(username, password.toCharArray())) {
-                LOGGER.error("Failed to authenticate against MongoDB server. Unknown error.");
+            collection.getDB().command("ping");
+        } catch (MongoException e) {
+            return true;
-            }
+        }
-        } catch (final MongoException e) {
-            LOGGER.error("Failed to authenticate against MongoDB: " + e.getMessage(), e);
-        } catch (final IllegalStateException e) {
-            LOGGER.error(
-                    "Factory-supplied MongoDB database connection already authenticated with different credentials but lost connection.",
-                    e);
-        }
+        return false;
     }
 }
Index: log4j-nosql/src/main/java/org/apache/logging/log4j/nosql/appender/mongodb/MongoDbProvider.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- log4j-nosql/src/main/java/org/apache/logging/log4j/nosql/appender/mongodb/MongoDbProvider.java	(revision 8df207b9183339ec9c8bface521e3c6e8865d057)
+++ log4j-nosql/src/main/java/org/apache/logging/log4j/nosql/appender/mongodb/MongoDbProvider.java	(revision )
@@ -18,12 +18,10 @@
 
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
+import java.util.Arrays;
 import java.util.List;
 
-import com.mongodb.DB;
-import com.mongodb.MongoClient;
-import com.mongodb.ServerAddress;
-import com.mongodb.WriteConcern;
+import com.mongodb.*;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.core.appender.AbstractAppender;
 import org.apache.logging.log4j.core.config.plugins.Plugin;
@@ -153,15 +151,26 @@
         } else if (databaseName != null && databaseName.length() > 0) {
             description = "database=" + databaseName;
             try {
+                ServerAddress serverAddress;
                 if (server != null && server.length() > 0) {
                     final int portInt = AbstractAppender.parseInt(port, 0);
                     description += ", server=" + server;
                     if (portInt > 0) {
                         description += ", port=" + portInt;
-                        database = new MongoClient(server, portInt).getDB(databaseName);
+                        serverAddress = new ServerAddress(server, portInt);
                     } else {
-                        database = new MongoClient(server).getDB(databaseName);
+                        serverAddress = new ServerAddress(server);
                     }
+                    if (username != null && username.length() > 0 && password != null && password.length() > 0) {
+                        description += ", username=" + username + ", passwordHash="
+                                + NameUtil.md5(password + MongoDbProvider.class.getName());
+                        MongoCredential credential = MongoCredential.createCredential(username,
+                                databaseName, password.toCharArray());
+                        database = new MongoClient(serverAddress, Arrays.asList(credential)).getDB(databaseName);
+                    }
+                    else{
+                        database = new MongoClient(serverAddress).getDB(databaseName);
+                    }
                 } else {
                     database = new MongoClient().getDB(databaseName);
                 }
@@ -175,19 +184,11 @@
             return null;
         }
 
-        if (!database.isAuthenticated()) {
-            if (username != null && username.length() > 0 && password != null && password.length() > 0) {
-                description += ", username=" + username + ", passwordHash="
-                        + NameUtil.md5(password + MongoDbProvider.class.getName());
-                MongoDbConnection.authenticate(database, username, password);
-            } else {
-                try {
-                    database.getCollectionNames(); // Check if the database actually requires authentication
-                } catch (Exception e) {
+        try {
+            database.getCollectionNames(); // Check if the database actually requires authentication
+        } catch (Exception e) {
-                    LOGGER.error("The database is not already authenticated so you must supply a username and password for the MongoDB provider.", e);
+            LOGGER.error("The database is not already authenticated", e);
-                    return null;
+            return null;
-                }
-            }
         }
 
         WriteConcern writeConcern;
