You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2020/05/22 14:45:01 UTC
[logging-log4j2] branch release-2.x updated: [LOG4J2-2851] Drop
log4j-mongodb2 module.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/release-2.x by this push:
new 467cd10 [LOG4J2-2851] Drop log4j-mongodb2 module.
467cd10 is described below
commit 467cd103bae151b4e0b3be540a37927823f1380d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri May 22 10:44:54 2020 -0400
[LOG4J2-2851] Drop log4j-mongodb2 module.
An odd side-effect is log4j-core now needs an optional dependency on
slf4j for its Kafka appender to allow Maven to build.
---
log4j-core/pom.xml | 11 +-
log4j-mongodb2/pom.xml | 196 ------------
.../logging/log4j/mongodb2/MongoDbConnection.java | 103 ------
.../logging/log4j/mongodb2/MongoDbObject.java | 66 ----
.../logging/log4j/mongodb2/MongoDbProvider.java | 352 ---------------------
.../logging/log4j/mongodb2/package-info.java | 20 --
log4j-mongodb2/src/site/markdown/index.md.vm | 48 ---
log4j-mongodb2/src/site/site.xml | 52 ---
.../log4j/mongodb2/MongoDbAuthFailureTest.java | 76 -----
.../logging/log4j/mongodb2/MongoDbCappedTest.java | 78 -----
.../log4j/mongodb2/MongoDbMapMessageTest.java | 82 -----
.../apache/logging/log4j/mongodb2/MongoDbTest.java | 76 -----
.../logging/log4j/mongodb2/MongoDbTestRule.java | 184 -----------
.../log4j/mongodb2/MongoDbTestTestRuleTest.java | 68 ----
.../logging/log4j/mongodb2/TestConstants.java | 24 --
.../test/resources/log4j2-mongodb-auth-failure.xml | 31 --
.../src/test/resources/log4j2-mongodb-capped.xml | 31 --
.../test/resources/log4j2-mongodb-map-message.xml | 32 --
.../src/test/resources/log4j2-mongodb.xml | 31 --
pom.xml | 1 -
src/changes/changes.xml | 3 +
src/site/markdown/javadoc.md | 2 +-
src/site/site.xml | 2 -
src/site/xdoc/manual/appenders.xml | 139 +-------
src/site/xdoc/manual/messages.xml | 4 +-
25 files changed, 16 insertions(+), 1696 deletions(-)
diff --git a/log4j-core/pom.xml b/log4j-core/pom.xml
index dcb572f..95a301c 100644
--- a/log4j-core/pom.xml
+++ b/log4j-core/pom.xml
@@ -144,6 +144,12 @@
<artifactId>commons-csv</artifactId>
<optional>true</optional>
</dependency>
+ <!-- Kafka needs slf4j -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <optional>true</optional>
+ </dependency>
<!-- TEST DEPENDENCIES -->
@@ -177,11 +183,6 @@
<!-- SLF4J tests -->
<dependency>
<groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
<artifactId>slf4j-ext</artifactId>
<scope>test</scope>
</dependency>
diff --git a/log4j-mongodb2/pom.xml b/log4j-mongodb2/pom.xml
deleted file mode 100644
index 264d64e..0000000
--- a/log4j-mongodb2/pom.xml
+++ /dev/null
@@ -1,196 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to You under the Apache License, Version 2.0
- ~ (the "License"); you may not use this file except in compliance with
- ~ the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <parent>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>2.14.0-SNAPSHOT</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>log4j-mongodb2</artifactId>
- <name>Apache Log4j MongoDB 2</name>
- <description>
- MongoDB appender for Log4j using the MongoDB 2 driver API.
- </description>
- <properties>
- <log4jParentDir>${basedir}/..</log4jParentDir>
- <docLabel>MongoDB 2 Documentation</docLabel>
- <projectDir>/log4j-mongodb2</projectDir>
- <module.name>org.apache.logging.log4j.mongodb2</module.name>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.mongodb</groupId>
- <artifactId>mongo-java-driver</artifactId>
- </dependency>
- <!-- Test Dependencies -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-api</artifactId>
- <type>test-jar</type>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-core</artifactId>
- <type>test-jar</type>
- </dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-slf4j-impl</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>de.flapdoodle.embed</groupId>
- <artifactId>de.flapdoodle.embed.mongo</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <configuration>
- <instructions>
- <Fragment-Host>org.apache.logging.log4j.core</Fragment-Host>
- <Export-Package>*</Export-Package>
- </instructions>
- </configuration>
- </plugin>
- <!-- workaround flaky "Operation not permitted" failures when running tests in parallel -->
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <forkCount>1</forkCount>
- <reuseForks>false</reuseForks>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-changes-plugin</artifactId>
- <version>${changes.plugin.version}</version>
- <reportSets>
- <reportSet>
- <reports>
- <report>changes-report</report>
- </reports>
- </reportSet>
- </reportSets>
- <configuration>
- <issueLinkTemplate>%URL%/show_bug.cgi?id=%ISSUE%</issueLinkTemplate>
- <useJql>true</useJql>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <version>${checkstyle.plugin.version}</version>
- <configuration>
- <!--<propertiesLocation>${vfs.parent.dir}/checkstyle.properties</propertiesLocation> -->
- <configLocation>${log4jParentDir}/checkstyle.xml</configLocation>
- <suppressionsLocation>${log4jParentDir}/checkstyle-suppressions.xml</suppressionsLocation>
- <enableRulesSummary>false</enableRulesSummary>
- <propertyExpansion>basedir=${basedir}</propertyExpansion>
- <propertyExpansion>licensedir=${log4jParentDir}/checkstyle-header.txt</propertyExpansion>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>${javadoc.plugin.version}</version>
- <configuration>
- <bottom><![CDATA[<p align="center">Copyright © {inceptionYear}-{currentYear} {organizationName}. All Rights Reserved.<br />
- 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.</p>]]></bottom>
- <!-- module link generation is completely broken in the javadoc plugin for a multi-module non-aggregating
- project -->
- <detectOfflineLinks>false</detectOfflineLinks>
- <linksource>true</linksource>
- </configuration>
- <reportSets>
- <reportSet>
- <id>non-aggregate</id>
- <reports>
- <report>javadoc</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>findbugs-maven-plugin</artifactId>
- <version>${findbugs.plugin.version}</version>
- <configuration>
- <fork>true</fork>
- <jvmArgs>-Duser.language=en</jvmArgs>
- <threshold>Normal</threshold>
- <effort>Default</effort>
- <excludeFilterFile>${log4jParentDir}/findbugs-exclude-filter.xml</excludeFilterFile>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jxr-plugin</artifactId>
- <version>${jxr.plugin.version}</version>
- <reportSets>
- <reportSet>
- <id>non-aggregate</id>
- <reports>
- <report>jxr</report>
- </reports>
- </reportSet>
- <reportSet>
- <id>aggregate</id>
- <reports>
- <report>aggregate</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-pmd-plugin</artifactId>
- <version>${pmd.plugin.version}</version>
- <configuration>
- <targetJdk>${maven.compiler.target}</targetJdk>
- </configuration>
- </plugin>
- </plugins>
- </reporting>
-</project>
diff --git a/log4j-mongodb2/src/main/java/org/apache/logging/log4j/mongodb2/MongoDbConnection.java b/log4j-mongodb2/src/main/java/org/apache/logging/log4j/mongodb2/MongoDbConnection.java
deleted file mode 100644
index ec3b7dd..0000000
--- a/log4j-mongodb2/src/main/java/org/apache/logging/log4j/mongodb2/MongoDbConnection.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.mongodb2;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.appender.AppenderLoggingException;
-import org.apache.logging.log4j.core.appender.nosql.AbstractNoSqlConnection;
-import org.apache.logging.log4j.core.appender.nosql.NoSqlConnection;
-import org.apache.logging.log4j.core.appender.nosql.NoSqlObject;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.bson.BSON;
-import org.bson.Transformer;
-
-import com.mongodb.BasicDBObject;
-import com.mongodb.DB;
-import com.mongodb.DBCollection;
-import com.mongodb.Mongo;
-import com.mongodb.MongoException;
-import com.mongodb.WriteConcern;
-
-/**
- * The MongoDB implementation of {@link NoSqlConnection}.
- */
-public final class MongoDbConnection extends AbstractNoSqlConnection<BasicDBObject, MongoDbObject> {
-
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- static {
- BSON.addEncodingHook(Level.class, new Transformer() {
- @Override
- public Object transform(final Object o) {
- if (o instanceof Level) {
- return ((Level) o).name();
- }
- return o;
- }
- });
- }
-
- private final DBCollection collection;
- private final WriteConcern writeConcern;
-
- public MongoDbConnection(final DB database, final WriteConcern writeConcern, final String collectionName,
- final Boolean isCapped, final Integer collectionSize) {
- if (database.collectionExists(collectionName)) {
- LOGGER.debug("Gettting collection {}", collectionName);
- collection = database.getCollection(collectionName);
- } else {
- final BasicDBObject options = new BasicDBObject();
- options.put("capped", isCapped);
- options.put("size", collectionSize);
- LOGGER.debug("Creating collection {} (capped = {}, size = {})", collectionName, isCapped, collectionSize);
- this.collection = database.createCollection(collectionName, options);
- }
- this.writeConcern = writeConcern;
- }
-
- @Override
- public void closeImpl() {
- // LOG4J2-1196
- final Mongo mongo = this.collection.getDB().getMongo();
- LOGGER.debug("Closing {} client {}", mongo.getClass().getSimpleName(), mongo);
- mongo.close();
- }
-
- @Override
- public MongoDbObject[] createList(final int length) {
- return new MongoDbObject[length];
- }
-
- @Override
- public MongoDbObject createObject() {
- return new MongoDbObject();
- }
-
- @Override
- public void insertObject(final NoSqlObject<BasicDBObject> object) {
- try {
- final BasicDBObject unwrapped = object.unwrap();
- LOGGER.debug("Inserting object {}", unwrapped);
- this.collection.insert(unwrapped, this.writeConcern);
- } catch (final MongoException e) {
- throw new AppenderLoggingException("Failed to write log event to MongoDB due to error: " + e.getMessage(),
- e);
- }
- }
-
-}
diff --git a/log4j-mongodb2/src/main/java/org/apache/logging/log4j/mongodb2/MongoDbObject.java b/log4j-mongodb2/src/main/java/org/apache/logging/log4j/mongodb2/MongoDbObject.java
deleted file mode 100644
index 28a35cd..0000000
--- a/log4j-mongodb2/src/main/java/org/apache/logging/log4j/mongodb2/MongoDbObject.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.mongodb2;
-
-import java.util.Collections;
-
-import org.apache.logging.log4j.core.appender.nosql.NoSqlObject;
-
-import com.mongodb.BasicDBList;
-import com.mongodb.BasicDBObject;
-
-/**
- * The MongoDB implementation of {@link NoSqlObject}.
- */
-public final class MongoDbObject implements NoSqlObject<BasicDBObject> {
- private final BasicDBObject mongoObject;
-
- public MongoDbObject() {
- this.mongoObject = new BasicDBObject();
- }
-
- @Override
- public void set(final String field, final NoSqlObject<BasicDBObject> value) {
- this.mongoObject.append(field, value.unwrap());
- }
-
- @Override
- public void set(final String field, final NoSqlObject<BasicDBObject>[] values) {
- final BasicDBList list = new BasicDBList();
- for (final NoSqlObject<BasicDBObject> value : values) {
- list.add(value.unwrap());
- }
- this.mongoObject.append(field, list);
- }
-
- @Override
- public void set(final String field, final Object value) {
- this.mongoObject.append(field, value);
- }
-
- @Override
- public void set(final String field, final Object[] values) {
- final BasicDBList list = new BasicDBList();
- Collections.addAll(list, values);
- this.mongoObject.append(field, list);
- }
-
- @Override
- public BasicDBObject unwrap() {
- return this.mongoObject;
- }
-}
diff --git a/log4j-mongodb2/src/main/java/org/apache/logging/log4j/mongodb2/MongoDbProvider.java b/log4j-mongodb2/src/main/java/org/apache/logging/log4j/mongodb2/MongoDbProvider.java
deleted file mode 100644
index 06917b6..0000000
--- a/log4j-mongodb2/src/main/java/org/apache/logging/log4j/mongodb2/MongoDbProvider.java
+++ /dev/null
@@ -1,352 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.mongodb2;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.Core;
-import org.apache.logging.log4j.core.appender.nosql.NoSqlProvider;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginAliases;
-import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute;
-import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
-import org.apache.logging.log4j.core.config.plugins.convert.TypeConverters;
-import org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
-import org.apache.logging.log4j.core.config.plugins.validation.constraints.ValidHost;
-import org.apache.logging.log4j.core.config.plugins.validation.constraints.ValidPort;
-import org.apache.logging.log4j.core.filter.AbstractFilterable;
-import org.apache.logging.log4j.core.util.NameUtil;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.util.LoaderUtil;
-import org.apache.logging.log4j.util.Strings;
-
-import com.mongodb.DB;
-import com.mongodb.MongoClient;
-import com.mongodb.MongoCredential;
-import com.mongodb.ServerAddress;
-import com.mongodb.WriteConcern;
-
-/**
- * The MongoDB implementation of {@link NoSqlProvider} using the MongoDB driver version 2 API.
- */
-@Plugin(name = "MongoDb2", category = Core.CATEGORY_NAME, printObject = true)
-@PluginAliases("MongoDb") // Deprecated alias
-public final class MongoDbProvider implements NoSqlProvider<MongoDbConnection> {
-
- public static class Builder<B extends Builder<B>> extends AbstractFilterable.Builder<B>
- implements org.apache.logging.log4j.core.util.Builder<MongoDbProvider> {
-
- private static WriteConcern toWriteConcern(final String writeConcernConstant,
- final String writeConcernConstantClassName) {
- WriteConcern writeConcern;
- if (Strings.isNotEmpty(writeConcernConstant)) {
- if (Strings.isNotEmpty(writeConcernConstantClassName)) {
- try {
- final Class<?> writeConcernConstantClass = LoaderUtil.loadClass(writeConcernConstantClassName);
- final Field field = writeConcernConstantClass.getField(writeConcernConstant);
- writeConcern = (WriteConcern) field.get(null);
- } catch (final Exception e) {
- LOGGER.error("Write concern constant [{}.{}] not found, using default.",
- writeConcernConstantClassName, writeConcernConstant);
- writeConcern = DEFAULT_WRITE_CONCERN;
- }
- } else {
- writeConcern = WriteConcern.valueOf(writeConcernConstant);
- if (writeConcern == null) {
- LOGGER.warn("Write concern constant [{}] not found, using default.", writeConcernConstant);
- writeConcern = DEFAULT_WRITE_CONCERN;
- }
- }
- } else {
- writeConcern = DEFAULT_WRITE_CONCERN;
- }
- return writeConcern;
- }
-
- @PluginBuilderAttribute
- @ValidHost
- private String server = "localhost";
-
- @PluginBuilderAttribute
- @ValidPort
- private String port = "" + DEFAULT_PORT;
-
- @PluginBuilderAttribute
- @Required(message = "No database name provided")
- private String databaseName;
-
- @PluginBuilderAttribute
- @Required(message = "No collection name provided")
- private String collectionName;
-
- @PluginBuilderAttribute
- private String userName;
-
- @PluginBuilderAttribute(sensitive = true)
- private String password;
-
- @PluginBuilderAttribute("capped")
- private boolean isCapped = false;
-
- @PluginBuilderAttribute
- private int collectionSize = DEFAULT_COLLECTION_SIZE;
-
- @PluginBuilderAttribute
- private String factoryClassName;
-
- @PluginBuilderAttribute
- private String factoryMethodName;
-
- @PluginBuilderAttribute
- private String writeConcernConstantClassName;
-
- @PluginBuilderAttribute
- private String writeConcernConstant;
-
- @Override
- public MongoDbProvider build() {
- DB database;
- String description;
- if (Strings.isNotEmpty(factoryClassName) && Strings.isNotEmpty(factoryMethodName)) {
- try {
- final Class<?> factoryClass = LoaderUtil.loadClass(factoryClassName);
- final Method method = factoryClass.getMethod(factoryMethodName);
- final Object object = method.invoke(null);
-
- if (object instanceof DB) {
- database = (DB) object;
- } else if (object instanceof MongoClient) {
- if (Strings.isNotEmpty(databaseName)) {
- database = ((MongoClient) object).getDB(databaseName);
- } else {
- LOGGER.error("The factory method [{}.{}()] returned a MongoClient so the database name is "
- + "required.", factoryClassName, factoryMethodName);
- return null;
- }
- } else if (object == null) {
- LOGGER.error("The factory method [{}.{}()] returned null.", factoryClassName, factoryMethodName);
- return null;
- } else {
- LOGGER.error("The factory method [{}.{}()] returned an unsupported type [{}].", factoryClassName,
- factoryMethodName, object.getClass().getName());
- return null;
- }
-
- description = "database=" + database.getName();
- final List<ServerAddress> addresses = database.getMongo().getAllAddress();
- if (addresses.size() == 1) {
- description += ", server=" + addresses.get(0).getHost() + ", port=" + addresses.get(0).getPort();
- } else {
- description += ", servers=[";
- for (final ServerAddress address : addresses) {
- description += " { " + address.getHost() + ", " + address.getPort() + " } ";
- }
- description += "]";
- }
- } catch (final ClassNotFoundException e) {
- LOGGER.error("The factory class [{}] could not be loaded.", factoryClassName, e);
- return null;
- } catch (final NoSuchMethodException e) {
- LOGGER.error("The factory class [{}] does not have a no-arg method named [{}].", factoryClassName,
- factoryMethodName, e);
- return null;
- } catch (final Exception e) {
- LOGGER.error("The factory method [{}.{}()] could not be invoked.", factoryClassName, factoryMethodName,
- e);
- return null;
- }
- } else if (Strings.isNotEmpty(databaseName)) {
- final List<MongoCredential> credentials = new ArrayList<>();
- description = "database=" + databaseName;
- if (Strings.isNotEmpty(userName) && Strings.isNotEmpty(password)) {
- description += ", username=" + userName + ", passwordHash="
- + NameUtil.md5(password + MongoDbProvider.class.getName());
- credentials.add(MongoCredential.createCredential(userName, databaseName, password.toCharArray()));
- }
- try {
- final int portInt = TypeConverters.convert(port, int.class, DEFAULT_PORT);
- description += ", server=" + server + ", port=" + portInt;
- database = new MongoClient(new ServerAddress(server, portInt), credentials).getDB(databaseName);
- } catch (final Exception e) {
- LOGGER.error(
- "Failed to obtain a database instance from the MongoClient at server [{}] and " + "port [{}].",
- server, port);
- return null;
- }
- } else {
- LOGGER.error("No factory method was provided so the database name is required.");
- return null;
- }
-
- try {
- database.getCollectionNames(); // Check if the database actually requires authentication
- } catch (final Exception e) {
- LOGGER.error(
- "The database is not up, or you are not authenticated, try supplying a username and password to the MongoDB provider.",
- e);
- return null;
- }
-
- final WriteConcern writeConcern = toWriteConcern(writeConcernConstant, writeConcernConstantClassName);
-
- return new MongoDbProvider(database, writeConcern, collectionName, isCapped, collectionSize, description);
- }
-
- public B setCapped(final boolean isCapped) {
- this.isCapped = isCapped;
- return asBuilder();
- }
-
- public B setCollectionName(final String collectionName) {
- this.collectionName = collectionName;
- return asBuilder();
- }
-
- public B setCollectionSize(final int collectionSize) {
- this.collectionSize = collectionSize;
- return asBuilder();
- }
-
- public B setDatabaseName(final String databaseName) {
- this.databaseName = databaseName;
- return asBuilder();
- }
-
- public B setFactoryClassName(final String factoryClassName) {
- this.factoryClassName = factoryClassName;
- return asBuilder();
- }
-
- public B setFactoryMethodName(final String factoryMethodName) {
- this.factoryMethodName = factoryMethodName;
- return asBuilder();
- }
-
- public B setPassword(final String password) {
- this.password = password;
- return asBuilder();
- }
-
- public B setPort(final String port) {
- this.port = port;
- return asBuilder();
- }
-
- public B setServer(final String server) {
- this.server = server;
- return asBuilder();
- }
-
- public B setUserName(final String userName) {
- this.userName = userName;
- return asBuilder();
- }
-
- public B setWriteConcernConstant(final String writeConcernConstant) {
- this.writeConcernConstant = writeConcernConstant;
- return asBuilder();
- }
-
- public B setWriteConcernConstantClassName(final String writeConcernConstantClassName) {
- this.writeConcernConstantClassName = writeConcernConstantClassName;
- return asBuilder();
- }
- }
- private static final WriteConcern DEFAULT_WRITE_CONCERN = WriteConcern.ACKNOWLEDGED;
- private static final Logger LOGGER = StatusLogger.getLogger();
- private static final int DEFAULT_PORT = 27017;
-
- private static final int DEFAULT_COLLECTION_SIZE = 536870912;
- /**
- * Factory method for creating a MongoDB provider within the plugin manager.
- *
- * @param collectionName The name of the MongoDB collection to which log events should be written.
- * @param writeConcernConstant The {@link WriteConcern} constant to control writing details, defaults to
- * {@link WriteConcern#ACKNOWLEDGED}.
- * @param writeConcernConstantClassName The name of a class containing the aforementioned static WriteConcern
- * constant. Defaults to {@link WriteConcern}.
- * @param databaseName The name of the MongoDB database containing the collection to which log events should be
- * written. Mutually exclusive with {@code factoryClassName&factoryMethodName!=null}.
- * @param server The host name of the MongoDB server, defaults to localhost and mutually exclusive with
- * {@code factoryClassName&factoryMethodName!=null}.
- * @param port The port the MongoDB server is listening on, defaults to the default MongoDB port and mutually
- * exclusive with {@code factoryClassName&factoryMethodName!=null}.
- * @param userName The username to authenticate against the MongoDB server with.
- * @param password The password to authenticate against the MongoDB server with.
- * @param factoryClassName A fully qualified class name containing a static factory method capable of returning a
- * {@link DB} or a {@link MongoClient}.
- * @param factoryMethodName The name of the public static factory method belonging to the aforementioned factory
- * class.
- * @return a new MongoDB provider.
- * @deprecated in 2.8; use {@link #newBuilder()} instead.
- */
- @Deprecated
- public static MongoDbProvider createNoSqlProvider(
- final String collectionName,
- final String writeConcernConstant,
- final String writeConcernConstantClassName,
- final String databaseName,
- final String server,
- final String port,
- final String userName,
- final String password,
- final String factoryClassName,
- final String factoryMethodName) {
- LOGGER.info("createNoSqlProvider");
- return newBuilder().setCollectionName(collectionName).setWriteConcernConstant(writeConcernConstantClassName)
- .setWriteConcernConstant(writeConcernConstant).setDatabaseName(databaseName).setServer(server)
- .setPort(port).setUserName(userName).setPassword(password).setFactoryClassName(factoryClassName)
- .setFactoryMethodName(factoryMethodName).build();
- }
- @PluginBuilderFactory
- public static <B extends Builder<B>> B newBuilder() {
- return new Builder<B>().asBuilder();
- }
- private final String collectionName;
- private final DB database;
- private final String description;
-
- private final WriteConcern writeConcern;
-
- private final boolean isCapped;
-
- private final Integer collectionSize;
-
- private MongoDbProvider(final DB database, final WriteConcern writeConcern, final String collectionName,
- final boolean isCapped, final Integer collectionSize, final String description) {
- this.database = database;
- this.writeConcern = writeConcern;
- this.collectionName = collectionName;
- this.isCapped = isCapped;
- this.collectionSize = collectionSize;
- this.description = "mongoDb{ " + description + " }";
- }
-
- @Override
- public MongoDbConnection getConnection() {
- return new MongoDbConnection(this.database, this.writeConcern, this.collectionName, this.isCapped, this.collectionSize);
- }
-
- @Override
- public String toString() {
- return this.description;
- }
-}
diff --git a/log4j-mongodb2/src/main/java/org/apache/logging/log4j/mongodb2/package-info.java b/log4j-mongodb2/src/main/java/org/apache/logging/log4j/mongodb2/package-info.java
deleted file mode 100644
index bf111af..0000000
--- a/log4j-mongodb2/src/main/java/org/apache/logging/log4j/mongodb2/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-/**
- * The classes in this package contain the MongoDB provider for the NoSQL Appender.
- */
-package org.apache.logging.log4j.mongodb2;
diff --git a/log4j-mongodb2/src/site/markdown/index.md.vm b/log4j-mongodb2/src/site/markdown/index.md.vm
deleted file mode 100644
index 0d1eb7a..0000000
--- a/log4j-mongodb2/src/site/markdown/index.md.vm
+++ /dev/null
@@ -1,48 +0,0 @@
-<!-- vim: set syn=markdown : -->
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-#set($h1='#')
-#set($h2='##')
-## TODO: use properties for dynamic dependency versions
-
-$h1 MongoDB appender
-
-[MongoDB](http://www.mongodb.org/) is supported through the
-[Java MongoDB Driver](http://docs.mongodb.org/ecosystem/drivers/java/).
-
-```
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.mongodb</groupId>
- <artifactId>mongo-java-driver</artifactId>
- <version>2.14.3</version>
- </dependency>
- </dependencies>
- </dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.mongodb</groupId>
- <artifactId>mongo-java-driver</artifactId>
- </dependency>
- </dependencies>
-```
-
-$h2 Requirements
-
-The MongoDB Appender is dependent on the Log4j 2 API and implementation.
-For more information, see [Runtime Dependencies](../runtime-dependencies.html).
diff --git a/log4j-mongodb2/src/site/site.xml b/log4j-mongodb2/src/site/site.xml
deleted file mode 100644
index f5db26e..0000000
--- a/log4j-mongodb2/src/site/site.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<project name="Log4j MongoDB 2.x Appender"
- xmlns="http://maven.apache.org/DECORATION/1.4.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/DECORATION/1.4.0 http://maven.apache.org/xsd/decoration-1.4.0.xsd">
- <body>
- <links>
- <item name="Apache" href="http://www.apache.org/" />
- <item name="Logging Services" href="http://logging.apache.org/"/>
- <item name="Log4j" href="../index.html"/>
- </links>
-
- <!-- Component-specific reports -->
- <menu ref="reports"/>
-
- <!-- Overall Project Info -->
- <menu name="Log4j Project Information" img="icon-info-sign">
- <item name="Dependencies" href="../dependencies.html" />
- <item name="Dependency Convergence" href="../dependency-convergence.html" />
- <item name="Dependency Management" href="../dependency-management.html" />
- <item name="Project Team" href="../team-list.html" />
- <item name="Mailing Lists" href="../mail-lists.html" />
- <item name="Issue Tracking" href="../issue-tracking.html" />
- <item name="Project License" href="../license.html" />
- <item name="Source Repository" href="../source-repository.html" />
- <item name="Project Summary" href="../project-summary.html" />
- </menu>
-
- <menu name="Log4j Project Reports" img="icon-cog">
- <item name="Changes Report" href="../changes-report.html" />
- <item name="JIRA Report" href="../jira-report.html" />
- <item name="Surefire Report" href="../surefire-report.html" />
- <item name="RAT Report" href="../rat-report.html" />
- </menu>
- </body>
-</project>
diff --git a/log4j-mongodb2/src/test/java/org/apache/logging/log4j/mongodb2/MongoDbAuthFailureTest.java b/log4j-mongodb2/src/test/java/org/apache/logging/log4j/mongodb2/MongoDbAuthFailureTest.java
deleted file mode 100644
index 6e921cc..0000000
--- a/log4j-mongodb2/src/test/java/org/apache/logging/log4j/mongodb2/MongoDbAuthFailureTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.mongodb2;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.categories.Appenders;
-import org.apache.logging.log4j.junit.LoggerContextRule;
-import org.apache.logging.log4j.mongodb2.MongoDbTestRule.LoggingTarget;
-import org.apache.logging.log4j.test.AvailablePortSystemPropertyTestRule;
-import org.apache.logging.log4j.test.RuleChainFactory;
-import org.junit.Assert;
-import org.junit.ClassRule;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.RuleChain;
-
-import com.mongodb.DB;
-import com.mongodb.DBCollection;
-import com.mongodb.DBCursor;
-import com.mongodb.MongoClient;
-
-/**
- *
- *
- * TODO Set up the log4j user in MongoDB.
- */
-@Ignore("TODO Set up the log4j user in MongoDB")
-@Category(Appenders.MongoDb.class)
-public class MongoDbAuthFailureTest {
-
- private static LoggerContextRule loggerContextTestRule = new LoggerContextRule("log4j2-mongodb-auth-failure.xml");
-
- private static final AvailablePortSystemPropertyTestRule mongoDbPortTestRule = AvailablePortSystemPropertyTestRule
- .create(TestConstants.SYS_PROP_NAME_PORT);
-
- private static final MongoDbTestRule mongoDbTestRule = new MongoDbTestRule(mongoDbPortTestRule.getName(),
- LoggingTarget.NULL);
-
- @ClassRule
- public static RuleChain ruleChain = RuleChainFactory.create(mongoDbPortTestRule, mongoDbTestRule,
- loggerContextTestRule);
-
- @Test
- public void test() {
- final Logger logger = LogManager.getLogger();
- logger.info("Hello log");
- final MongoClient mongoClient = mongoDbTestRule.getMongoClient();
- try {
- final DB database = mongoClient.getDB("test");
- Assert.assertNotNull(database);
- final DBCollection collection = database.getCollection("applog");
- Assert.assertNotNull(collection);
- try (DBCursor cursor = collection.find()) {
- Assert.assertFalse(cursor.hasNext());
- }
- } finally {
- mongoClient.close();
- }
- }
-}
diff --git a/log4j-mongodb2/src/test/java/org/apache/logging/log4j/mongodb2/MongoDbCappedTest.java b/log4j-mongodb2/src/test/java/org/apache/logging/log4j/mongodb2/MongoDbCappedTest.java
deleted file mode 100644
index 7b900ae..0000000
--- a/log4j-mongodb2/src/test/java/org/apache/logging/log4j/mongodb2/MongoDbCappedTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.mongodb2;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.categories.Appenders;
-import org.apache.logging.log4j.junit.LoggerContextRule;
-import org.apache.logging.log4j.mongodb2.MongoDbTestRule.LoggingTarget;
-import org.apache.logging.log4j.test.AvailablePortSystemPropertyTestRule;
-import org.apache.logging.log4j.test.RuleChainFactory;
-import org.junit.Assert;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.RuleChain;
-
-import com.mongodb.DB;
-import com.mongodb.DBCollection;
-import com.mongodb.DBCursor;
-import com.mongodb.DBObject;
-import com.mongodb.MongoClient;
-
-/**
- *
- */
-@Category(Appenders.MongoDb.class)
-public class MongoDbCappedTest {
-
- private static LoggerContextRule loggerContextTestRule = new LoggerContextRule("log4j2-mongodb-capped.xml");
-
- private static final AvailablePortSystemPropertyTestRule mongoDbPortTestRule = AvailablePortSystemPropertyTestRule
- .create(TestConstants.SYS_PROP_NAME_PORT);
-
- private static final MongoDbTestRule mongoDbTestRule = new MongoDbTestRule(mongoDbPortTestRule.getName(),
- LoggingTarget.NULL);
-
- @ClassRule
- public static RuleChain ruleChain = RuleChainFactory.create(mongoDbPortTestRule, mongoDbTestRule,
- loggerContextTestRule);
-
- @Test
- public void test() {
- final Logger logger = LogManager.getLogger();
- logger.info("Hello log");
- final MongoClient mongoClient = mongoDbTestRule.getMongoClient();
- try {
- final DB database = mongoClient.getDB("test");
- Assert.assertNotNull(database);
- final DBCollection collection = database.getCollection("applog");
- Assert.assertNotNull(collection);
- try (DBCursor cursor = collection.find()) {
- Assert.assertTrue(cursor.hasNext());
- }
- try (DBCursor cursor = collection.find()) {
- final DBObject first = cursor.next();
- Assert.assertNotNull(first);
- Assert.assertEquals(first.toMap().toString(), "Hello log", first.get("message"));
- }
- } finally {
- mongoClient.close();
- }
- }
-}
diff --git a/log4j-mongodb2/src/test/java/org/apache/logging/log4j/mongodb2/MongoDbMapMessageTest.java b/log4j-mongodb2/src/test/java/org/apache/logging/log4j/mongodb2/MongoDbMapMessageTest.java
deleted file mode 100644
index 983db0e..0000000
--- a/log4j-mongodb2/src/test/java/org/apache/logging/log4j/mongodb2/MongoDbMapMessageTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.mongodb2;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.categories.Appenders;
-import org.apache.logging.log4j.junit.LoggerContextRule;
-import org.apache.logging.log4j.message.MapMessage;
-import org.apache.logging.log4j.mongodb2.MongoDbTestRule.LoggingTarget;
-import org.apache.logging.log4j.test.AvailablePortSystemPropertyTestRule;
-import org.apache.logging.log4j.test.RuleChainFactory;
-import org.junit.Assert;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.RuleChain;
-
-import com.mongodb.DB;
-import com.mongodb.DBCollection;
-import com.mongodb.DBCursor;
-import com.mongodb.DBObject;
-import com.mongodb.MongoClient;
-
-/**
- *
- */
-@Category(Appenders.MongoDb.class)
-public class MongoDbMapMessageTest {
-
- private static LoggerContextRule loggerContextTestRule = new LoggerContextRule("log4j2-mongodb-map-message.xml");
-
- private static final AvailablePortSystemPropertyTestRule mongoDbPortTestRule = AvailablePortSystemPropertyTestRule
- .create(TestConstants.SYS_PROP_NAME_PORT);
-
- private static final MongoDbTestRule mongoDbTestRule = new MongoDbTestRule(mongoDbPortTestRule.getName(),
- LoggingTarget.NULL);
-
- @ClassRule
- public static RuleChain ruleChain = RuleChainFactory.create(mongoDbPortTestRule, mongoDbTestRule,
- loggerContextTestRule);
-
- @Test
- public void test() {
- final Logger logger = LogManager.getLogger();
- final MapMessage<?, Object> mapMessage = new MapMessage<>();
- mapMessage.with("SomeName", "SomeValue");
- mapMessage.with("SomeInt", 1);
- logger.info(mapMessage);
- //
- final MongoClient mongoClient = mongoDbTestRule.getMongoClient();
- try {
- final DB database = mongoClient.getDB("test");
- Assert.assertNotNull(database);
- final DBCollection collection = database.getCollection("applog");
- Assert.assertNotNull(collection);
- try (DBCursor cursor = collection.find()) {
- final DBObject first = cursor.next();
- Assert.assertNotNull(first);
- final String firstMapString = first.toMap().toString();
- Assert.assertEquals(firstMapString, "SomeValue", first.get("SomeName"));
- Assert.assertEquals(firstMapString, Integer.valueOf(1), first.get("SomeInt"));
- }
- } finally {
- mongoClient.close();
- }
- }
-}
diff --git a/log4j-mongodb2/src/test/java/org/apache/logging/log4j/mongodb2/MongoDbTest.java b/log4j-mongodb2/src/test/java/org/apache/logging/log4j/mongodb2/MongoDbTest.java
deleted file mode 100644
index 06c9509..0000000
--- a/log4j-mongodb2/src/test/java/org/apache/logging/log4j/mongodb2/MongoDbTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-package org.apache.logging.log4j.mongodb2;
-
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.categories.Appenders;
-import org.apache.logging.log4j.junit.LoggerContextRule;
-import org.apache.logging.log4j.mongodb2.MongoDbTestRule.LoggingTarget;
-import org.apache.logging.log4j.test.AvailablePortSystemPropertyTestRule;
-import org.apache.logging.log4j.test.RuleChainFactory;
-import org.junit.Assert;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.RuleChain;
-
-import com.mongodb.DB;
-import com.mongodb.DBCollection;
-import com.mongodb.DBCursor;
-import com.mongodb.DBObject;
-import com.mongodb.MongoClient;
-
-/**
- *
- */
-@Category(Appenders.MongoDb.class)
-public class MongoDbTest {
-
- private static LoggerContextRule loggerContextTestRule = new LoggerContextRule("log4j2-mongodb.xml");
-
- private static final AvailablePortSystemPropertyTestRule mongoDbPortTestRule = AvailablePortSystemPropertyTestRule
- .create(TestConstants.SYS_PROP_NAME_PORT);
-
- private static final MongoDbTestRule mongoDbTestRule = new MongoDbTestRule(mongoDbPortTestRule.getName(),
- LoggingTarget.NULL);
-
- @ClassRule
- public static RuleChain ruleChain = RuleChainFactory.create(mongoDbPortTestRule, mongoDbTestRule,
- loggerContextTestRule);
-
- @Test
- public void test() {
- final Logger logger = LogManager.getLogger();
- logger.info("Hello log");
- final MongoClient mongoClient = mongoDbTestRule.getMongoClient();
- try {
- final DB database = mongoClient.getDB("test");
- Assert.assertNotNull(database);
- final DBCollection collection = database.getCollection("applog");
- Assert.assertNotNull(collection);
- try (DBCursor cursor = collection.find()) {
- final DBObject first = cursor.next();
- Assert.assertNotNull(first);
- Assert.assertEquals(first.toMap().toString(), "Hello log", first.get("message"));
- Assert.assertEquals(first.toMap().toString(), "INFO", first.get("level"));
- }
- } finally {
- mongoClient.close();
- }
- }
-}
diff --git a/log4j-mongodb2/src/test/java/org/apache/logging/log4j/mongodb2/MongoDbTestRule.java b/log4j-mongodb2/src/test/java/org/apache/logging/log4j/mongodb2/MongoDbTestRule.java
deleted file mode 100644
index 68416c2..0000000
--- a/log4j-mongodb2/src/test/java/org/apache/logging/log4j/mongodb2/MongoDbTestRule.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-
-package org.apache.logging.log4j.mongodb2;
-
-import java.util.Objects;
-
-import org.apache.commons.lang3.NotImplementedException;
-import org.junit.rules.TestRule;
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.mongodb.MongoClient;
-
-import de.flapdoodle.embed.mongo.Command;
-import de.flapdoodle.embed.mongo.MongodExecutable;
-import de.flapdoodle.embed.mongo.MongodProcess;
-import de.flapdoodle.embed.mongo.MongodStarter;
-import de.flapdoodle.embed.mongo.config.MongodConfigBuilder;
-import de.flapdoodle.embed.mongo.config.Net;
-import de.flapdoodle.embed.mongo.config.RuntimeConfigBuilder;
-import de.flapdoodle.embed.mongo.config.Timeout;
-import de.flapdoodle.embed.mongo.distribution.Version;
-import de.flapdoodle.embed.process.config.IRuntimeConfig;
-import de.flapdoodle.embed.process.config.io.ProcessOutput;
-import de.flapdoodle.embed.process.runtime.Network;
-
-/**
- * A JUnit test rule to manage a MongoDB embedded instance.
- *
- * TODO Move this class to Apache Commons Testing.
- */
-public class MongoDbTestRule implements TestRule {
-
- public enum LoggingTarget {
- NULL, CONSOLE
- }
-
- private static final int BUILDER_TIMEOUT_MILLIS = 30000;
-
- public static int getBuilderTimeoutMillis() {
- return BUILDER_TIMEOUT_MILLIS;
- }
-
- /**
- * Store {@link MongodStarter} (or RuntimeConfig) in a static final field if you want to use artifact store caching
- * (or else disable caching).
- * <p>
- * The test framework {@code de.flapdoodle.embed.mongo} requires Java 8.
- * </p>
- */
- protected final MongodStarter starter;
-
- protected final String portSystemPropertyName;
-
- protected MongoClient mongoClient;
- protected MongodExecutable mongodExecutable;
- protected MongodProcess mongodProcess;
- protected final LoggingTarget loggingTarget;
-
- /**
- * Constructs a new test rule.
- *
- * @param portSystemPropertyName
- * The system property name for the MongoDB port.
- * @param loggingTarget
- * The logging target
- */
- public MongoDbTestRule(final String portSystemPropertyName, final LoggingTarget loggingTarget) {
- this.portSystemPropertyName = Objects.requireNonNull(portSystemPropertyName, "portSystemPropertyName");
- this.loggingTarget = loggingTarget;
- this.starter = getMongodStarter(loggingTarget);
- }
-
- private static MongodStarter getMongodStarter(final LoggingTarget loggingTarget) {
- if (loggingTarget == null) {
- return MongodStarter.getDefaultInstance();
- }
- switch (loggingTarget) {
- case NULL:
- final Logger logger = LoggerFactory.getLogger(MongoDbTestRule.class.getName());
- final IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()
- // @formatter:off
- .defaultsWithLogger(Command.MongoD, logger)
- .processOutput(ProcessOutput.getDefaultInstanceSilent())
- .build();
- // @formatter:on
-
- return MongodStarter.getInstance(runtimeConfig);
- case CONSOLE:
- return MongodStarter.getDefaultInstance();
- default:
- throw new NotImplementedException(loggingTarget.toString());
- }
- }
-
- @Override
- public Statement apply(final Statement base, final Description description) {
- return new Statement() {
-
- @Override
- public void evaluate() throws Throwable {
- final String value = Objects.requireNonNull(System.getProperty(portSystemPropertyName),
- "System property '" + portSystemPropertyName + "' is null");
- final int port = Integer.parseInt(value);
- mongodExecutable = starter.prepare(
- // @formatter:off
- new MongodConfigBuilder()
- .version(Version.Main.PRODUCTION)
- .timeout(new Timeout(BUILDER_TIMEOUT_MILLIS))
- .net(
- new Net("localhost", port, Network.localhostIsIPv6()))
- .build());
- // @formatter:on
- mongodProcess = mongodExecutable.start();
- mongoClient = new MongoClient("localhost", port);
- try {
- base.evaluate();
- } finally {
- if (mongodProcess != null) {
- mongodProcess.stop();
- mongodProcess = null;
- }
- if (mongodExecutable != null) {
- mongodExecutable.stop();
- mongodExecutable = null;
- }
- }
- }
- };
- }
-
- public MongoClient getMongoClient() {
- return mongoClient;
- }
-
- public MongodExecutable getMongodExecutable() {
- return mongodExecutable;
- }
-
- public MongodProcess getMongodProcess() {
- return mongodProcess;
- }
-
- public MongodStarter getStarter() {
- return starter;
- }
-
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("MongoDbTestRule [starter=");
- builder.append(starter);
- builder.append(", portSystemPropertyName=");
- builder.append(portSystemPropertyName);
- builder.append(", mongoClient=");
- builder.append(mongoClient);
- builder.append(", mongodExecutable=");
- builder.append(mongodExecutable);
- builder.append(", mongodProcess=");
- builder.append(mongodProcess);
- builder.append(", loggingTarget=");
- builder.append(loggingTarget);
- builder.append("]");
- return builder.toString();
- }
-
-}
\ No newline at end of file
diff --git a/log4j-mongodb2/src/test/java/org/apache/logging/log4j/mongodb2/MongoDbTestTestRuleTest.java b/log4j-mongodb2/src/test/java/org/apache/logging/log4j/mongodb2/MongoDbTestTestRuleTest.java
deleted file mode 100644
index b8e15b4..0000000
--- a/log4j-mongodb2/src/test/java/org/apache/logging/log4j/mongodb2/MongoDbTestTestRuleTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-
-package org.apache.logging.log4j.mongodb2;
-
-import java.util.List;
-
-import org.apache.commons.lang3.JavaVersion;
-import org.apache.commons.lang3.SystemUtils;
-import org.apache.logging.log4j.mongodb2.MongoDbTestRule.LoggingTarget;
-import org.apache.logging.log4j.test.AvailablePortSystemPropertyTestRule;
-import org.apache.logging.log4j.test.RuleChainFactory;
-import org.junit.Assert;
-import org.junit.Assume;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.rules.RuleChain;
-
-/**
- * Tests {@link MongoDbTestRule}.
- */
-public class MongoDbTestTestRuleTest {
-
- private static final AvailablePortSystemPropertyTestRule mongoDbPortTestRule = AvailablePortSystemPropertyTestRule
- .create(TestConstants.SYS_PROP_NAME_PORT);
-
- private static final MongoDbTestRule mongoDbTestRule = new MongoDbTestRule(mongoDbPortTestRule.getName(), LoggingTarget.NULL);
-
- @ClassRule
- public static RuleChain mongoDbChain = RuleChainFactory.create(mongoDbPortTestRule, mongoDbTestRule);
-
- @BeforeClass
- public static void beforeClass() {
- Assume.assumeTrue(SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_8));
- }
-
- @Test
- public void testAccess() {
- final List<String> databaseNames = mongoDbTestRule.getMongoClient().getDatabaseNames();
- Assert.assertNotNull(databaseNames);
- Assert.assertFalse(databaseNames.isEmpty());
- Assert.assertNotNull(databaseNames.get(0));
- }
-
- @Test
- public void testMongoDbTestRule() {
- Assert.assertNotNull(mongoDbTestRule);
- Assert.assertNotNull(mongoDbTestRule.getStarter());
- Assert.assertNotNull(mongoDbTestRule.getMongoClient());
- Assert.assertNotNull(mongoDbTestRule.getMongodExecutable());
- Assert.assertNotNull(mongoDbTestRule.getMongodProcess());
- }
-}
diff --git a/log4j-mongodb2/src/test/java/org/apache/logging/log4j/mongodb2/TestConstants.java b/log4j-mongodb2/src/test/java/org/apache/logging/log4j/mongodb2/TestConstants.java
deleted file mode 100644
index 040209c..0000000
--- a/log4j-mongodb2/src/test/java/org/apache/logging/log4j/mongodb2/TestConstants.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-
-package org.apache.logging.log4j.mongodb2;
-
-public class TestConstants {
-
- public static final String SYS_PROP_NAME_PORT = "MongoDBTestPort";
-
-}
diff --git a/log4j-mongodb2/src/test/resources/log4j2-mongodb-auth-failure.xml b/log4j-mongodb2/src/test/resources/log4j2-mongodb-auth-failure.xml
deleted file mode 100644
index 43d7e37..0000000
--- a/log4j-mongodb2/src/test/resources/log4j2-mongodb-auth-failure.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<Configuration status="WARN">
- <Appenders>
- <NoSql name="MongoDbAppender">
- <MongoDb2 databaseName="test" collectionName="applog" server="localhost" userName="log4jUser" password="12345678"
- port="${sys:MongoDBTestPort:-27017}" />
- </NoSql>
- </Appenders>
- <Loggers>
- <Root level="ALL">
- <AppenderRef ref="MongoDbAppender" />
- </Root>
- </Loggers>
-</Configuration>
diff --git a/log4j-mongodb2/src/test/resources/log4j2-mongodb-capped.xml b/log4j-mongodb2/src/test/resources/log4j2-mongodb-capped.xml
deleted file mode 100644
index 7eda0ae..0000000
--- a/log4j-mongodb2/src/test/resources/log4j2-mongodb-capped.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<Configuration status="WARN">
- <Appenders>
- <NoSql name="MongoDbAppender">
- <MongoDb2 databaseName="test" collectionName="applog" server="localhost" capped="true" collectionSize="1073741824"
- port="${sys:MongoDBTestPort:-27017}" />
- </NoSql>
- </Appenders>
- <Loggers>
- <Root level="ALL">
- <AppenderRef ref="MongoDbAppender" />
- </Root>
- </Loggers>
-</Configuration>
diff --git a/log4j-mongodb2/src/test/resources/log4j2-mongodb-map-message.xml b/log4j-mongodb2/src/test/resources/log4j2-mongodb-map-message.xml
deleted file mode 100644
index 12f957a..0000000
--- a/log4j-mongodb2/src/test/resources/log4j2-mongodb-map-message.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<Configuration status="WARN">
- <Appenders>
- <NoSql name="MongoDbAppender">
- <MongoDb2 databaseName="test" collectionName="applog" server="localhost"
- port="${sys:MongoDBTestPort:-27017}" />
- <MessageLayout />
- </NoSql>
- </Appenders>
- <Loggers>
- <Root level="ALL">
- <AppenderRef ref="MongoDbAppender" />
- </Root>
- </Loggers>
-</Configuration>
diff --git a/log4j-mongodb2/src/test/resources/log4j2-mongodb.xml b/log4j-mongodb2/src/test/resources/log4j2-mongodb.xml
deleted file mode 100644
index 805c746..0000000
--- a/log4j-mongodb2/src/test/resources/log4j2-mongodb.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<Configuration status="WARN">
- <Appenders>
- <NoSql name="MongoDbAppender">
- <MongoDb2 databaseName="test" collectionName="applog" server="localhost"
- port="${sys:MongoDBTestPort:-27017}" />
- </NoSql>
- </Appenders>
- <Loggers>
- <Root level="ALL">
- <AppenderRef ref="MongoDbAppender" />
- </Root>
- </Loggers>
-</Configuration>
diff --git a/pom.xml b/pom.xml
index bb070e4..296b0e0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1398,7 +1398,6 @@
<module>log4j-jdbc-dbcp2</module>
<module>log4j-jpa</module>
<module>log4j-couchdb</module>
- <module>log4j-mongodb2</module>
<module>log4j-mongodb3</module>
<module>log4j-mongodb4</module>
<module>log4j-cassandra</module>
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index a87080e..6319f8d 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -36,6 +36,9 @@
<action issue="LOG4J2-2848" dev="ggregory" type="add">
Create module log4j-mongodb4 to use new major version 4 MongoDB driver.
</action>
+ <action issue="LOG4J2-2851" dev="ggregory" type="remove">
+ Drop log4j-mongodb2 module.
+ </action>
<action dev="ggregory" type="update">
Update MongoDB tests to require Java 8 unconditionally now that Log4j requires Java 8.
</action>
diff --git a/src/site/markdown/javadoc.md b/src/site/markdown/javadoc.md
index a8c1eba..86ebf51 100644
--- a/src/site/markdown/javadoc.md
+++ b/src/site/markdown/javadoc.md
@@ -48,6 +48,6 @@ Component | Description
[Log4j CouchDB Support](log4j-couchdb/apidocs/index.html) | Additional Appender for CouchDB.
[Log4j JDBC DBCP 2](log4j-jdbc-dbcp2/apidocs/index.html) | Connection source for the JDBC Appender using Apache Commons DBCP2.
[Log4j Liquibase Binding](log4j-liquibase/apidocs/index.html) | The Apache Log4j Liquibase binding to Log4j 2 Core.
-[Log4j MongoDB 2 Support](log4j-mongodb2/apidocs/index.html) | Additional Appender for MongoDB using the version 2 driver.
[Log4j MongoDB 3 Support](log4j-mongodb3/apidocs/index.html) | Additional Appender for MongoDB using the version 3 driver.
+[Log4j MongoDB 4 Support](log4j-mongodb4/apidocs/index.html) | Additional Appender for MongoDB using the version 4 driver.
[Log4j Cassandra Support](log4j-cassandra/apidocs/index.html) | Additional Appender for Cassandra.
diff --git a/src/site/site.xml b/src/site/site.xml
index e874168..1e62096 100644
--- a/src/site/site.xml
+++ b/src/site/site.xml
@@ -177,7 +177,6 @@
<item name="Memory Mapped File" href="/manual/appenders.html#MemoryMappedFileAppender"/>
<item name="NoSQL" href="/manual/appenders.html#NoSQLAppender"/>
<item name="NoSQL for MongoDB" href="/manual/appenders.html#NoSQLAppenderMongoDB"/>
- <item name="NoSQL for MongoDB 2" href="/manual/appenders.html#NoSQLAppenderMongoDB2"/>
<item name="NoSQL for MongoDB 3" href="/manual/appenders.html#NoSQLAppenderMongoDB3"/>
<item name="NoSQL for MongoDB 4" href="/manual/appenders.html#NoSQLAppenderMongoDB4"/>
<item name="NoSQL for CouchDB" href="/manual/appenders.html#NoSQLAppenderCouchDB"/>
@@ -318,7 +317,6 @@
<item name="Log4j Web Application Support" href="log4j-web/index.html"/>
<item name="Log4j Application Server Integration" href="log4j-appserver/index.html"/>
<item name="Log4j CouchDB appender" href="log4j-couchdb/index.html"/>
- <item name="Log4j MongoDB2 appender" href="log4j-mongodb2/index.html"/>
<item name="Log4j MongoDB3 appender" href="log4j-mongodb3/index.html"/>
<item name="Log4j MongoDB4 appender" href="log4j-mongodb4/index.html"/>
<item name="Log4j Cassandra appender" href="log4j-cassandra/index.html"/>
diff --git a/src/site/xdoc/manual/appenders.xml b/src/site/xdoc/manual/appenders.xml
index 336e5be..e78fa97 100644
--- a/src/site/xdoc/manual/appenders.xml
+++ b/src/site/xdoc/manual/appenders.xml
@@ -2341,12 +2341,12 @@ public class JpaLogEntity extends AbstractLogEventWrapperEntity {
<a name="NoSQLAppenderMongoDB"/>
<subsection name="NoSQLAppender for MongoDB">
<p>
- Starting with Log4 2.11.0, we provide two MongoDB modules:
+ Starting with Log4 2.11.0, we provide the following MongoDB modules:
</p>
<ul>
- <li>v2.11.0: <code>log4j-mongodb2</code> defines the configuration element <a href="#NoSQLAppenderMongoDB2"><code>MongoDb2</code></a> matching the MongoDB Driver version 2.</li>
- <li>v2.11.0: <code>log4j-mongodb3</code> defines the configuration element <a href="#NoSQLAppenderMongoDB3"><code>MongoDb3</code></a> matching the MongoDB Driver version 3.</li>
- <li>v2.14.0: <code>log4j-mongodb4</code> defines the configuration element <a href="#NoSQLAppenderMongoDB4"><code>MongoDb4</code></a> matching the MongoDB Driver version 4.</li>
+ <li>Added in v2.11.0, dropped in v2.14.0: <code>log4j-mongodb2</code> defines the configuration element <code>MongoDb2</code> matching the MongoDB Driver version 2.</li>
+ <li>Added in v2.11.0: <code>log4j-mongodb3</code> defines the configuration element <a href="#NoSQLAppenderMongoDB3"><code>MongoDb3</code></a> matching the MongoDB Driver version 3.</li>
+ <li>Added in v2.14.0: <code>log4j-mongodb4</code> defines the configuration element <a href="#NoSQLAppenderMongoDB4"><code>MongoDb4</code></a> matching the MongoDB Driver version 4.</li>
</ul>
<p>
We no longer provide the module <code>log4j-mongodb</code>.
@@ -2355,137 +2355,6 @@ public class JpaLogEntity extends AbstractLogEventWrapperEntity {
The module <code>log4j-mongodb2</code> aliases the old configuration element <code>MongoDb</code> to <a href="#NoSQLAppenderMongoDB2"><code>MongoDb2</code></a>.
</p>
</subsection>
- <a name="NoSQLAppenderMongoDB2"/>
- <subsection name="NoSQLAppender for MongoDB 2">
- <p>
- This section details specializations of the <a href="#NoSQLAppender">NoSQLAppender</a> provider for MongoDB using
- the MongoDB driver version 2. The NoSQLAppender Appender writes log events to a NoSQL database using an
- internal lightweight provider interface.
- </p>
- <table>
- <caption align="top">MongoDB2 Provider Parameters</caption>
- <tr>
- <th>Parameter Name</th>
- <th>Type</th>
- <th>Description</th>
- </tr>
- <tr>
- <td>collectionName</td>
- <td>String</td>
- <td><em>Required.</em> The name of the MongoDB collection to insert the events into.</td>
- </tr>
- <tr>
- <td>writeConcernConstant</td>
- <td>Field</td>
- <td>By default, the MongoDB provider inserts records with the instructions
- <code>com.mongodb.WriteConcern.ACKNOWLEDGED</code>. Use this optional attribute to specify the name of
- a constant other than <code>ACKNOWLEDGED</code>.</td>
- </tr>
- <tr>
- <td>writeConcernConstantClass</td>
- <td>Class</td>
- <td>If you specify <code>writeConcernConstant</code>, you can use this attribute to specify a class other
- than <code>com.mongodb.WriteConcern</code> to find the constant on (to create your own custom
- instructions).</td>
- </tr>
- <tr>
- <td>factoryClassName</td>
- <td>Class</td>
- <td>To provide a connection to the MongoDB database, you can use this attribute and
- <code>factoryMethodName</code> to specify a class and static method to get the connection from. The
- method must return a <code>com.mongodb.DB</code> or a <code>com.mongodb.MongoClient</code>. If the
- <code>DB</code> is not authenticated, you must also specify a <code>username</code> and
- <code>password</code>. If you use the factory method for providing a connection, you must not specify
- the <code>databaseName</code>, <code>server</code>, or <code>port</code> attributes.</td>
- </tr>
- <tr>
- <td>factoryMethodName</td>
- <td>Method</td>
- <td>See the documentation for attribute <code>factoryClassName</code>.</td>
- </tr>
- <tr>
- <td>databaseName</td>
- <td>String</td>
- <td>If you do not specify a <code>factoryClassName</code> and <code>factoryMethodName</code> for providing
- a MongoDB connection, you must specify a MongoDB database name using this attribute. You must also
- specify a <code>username</code> and <code>password</code>. You can optionally also specify a
- <code>server</code> (defaults to localhost), and a <code>port</code> (defaults to the default MongoDB
- port).</td>
- </tr>
- <tr>
- <td>server</td>
- <td>String</td>
- <td>See the documentation for attribute <code>databaseName</code>.</td>
- </tr>
- <tr>
- <td>port</td>
- <td>int</td>
- <td>See the documentation for attribute <code>databaseName</code>.</td>
- </tr>
- <tr>
- <td>username</td>
- <td>String</td>
- <td>See the documentation for attributes <code>databaseName</code> and <code>factoryClassName</code>.</td>
- </tr>
- <tr>
- <td>password</td>
- <td>String</td>
- <td>See the documentation for attributes <code>databaseName</code> and <code>factoryClassName</code>.</td>
- </tr>
- <tr>
- <td>capped</td>
- <td>boolean</td>
- <td>Enable support for <a href="https://docs.mongodb.com/manual/core/capped-collections/">capped collections</a></td>
- </tr>
- <tr>
- <td>collectionSize</td>
- <td>int</td>
- <td>Specify the size in bytes of the capped collection to use if enabled. The minimum size is 4096 bytes,
- and larger sizes will be increased to the nearest integer multiple of 256. See the capped collection documentation
- linked above for more information.</td>
- </tr>
- </table>
- <p>
- This appender is <a href="messages.html#MapMessage">MapMessage</a>-aware.
- </p>
- <p>
- Here are a few sample configurations for the NoSQLAppender and MongoDB2 provider:
- </p>
-
- <pre class="prettyprint linenums lang-xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<Configuration status="error">
- <Appenders>
- <NoSql name="databaseAppender">
- <MongoDb2 databaseName="applicationDb" collectionName="applicationLog" server="mongo.example.org"
- username="loggingUser" password="abc123" />
- </NoSql>
- </Appenders>
- <Loggers>
- <Root level="warn">
- <AppenderRef ref="databaseAppender"/>
- </Root>
- </Loggers>
-</Configuration>]]></pre>
-
- <pre class="prettyprint linenums lang-xml"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
-<Configuration status="error">
- <Appenders>
- <NoSql name="databaseAppender">
- <MongoDb2 collectionName="applicationLog" factoryClassName="org.example.db.ConnectionFactory"
- factoryMethodName="getNewMongoClient" />
- </NoSql>
- </Appenders>
- <Loggers>
- <Root level="warn">
- <AppenderRef ref="databaseAppender"/>
- </Root>
- </Loggers>
-</Configuration>]]></pre>
- <p>
- Starting in Log4j version 2.11.0, the provider element name is <code>MongoDb2</code>.
- The name <code>MongoDb</code> is now a deprecated alias for <code>MongoDb2</code>.
- </p>
- </subsection>
<a name="NoSQLAppenderMongoDB3"/>
<subsection name="NoSQLAppender for MongoDB 3">
<p>
diff --git a/src/site/xdoc/manual/messages.xml b/src/site/xdoc/manual/messages.xml
index 9eef316..e85b83c 100644
--- a/src/site/xdoc/manual/messages.xml
+++ b/src/site/xdoc/manual/messages.xml
@@ -218,8 +218,8 @@ public class MyApp {
<code>MapMessage</code> to values in a SQL INSERT statement.
</li>
<li>
- When a <a href="appenders.html#NoSQLAppenderMongoDB2">MongoDB2 Appender</a> or
- <a href="appenders.html#NoSQLAppenderMongoDB3">MongoDB3 Appender</a> is configured with a <code>MessageLayout</code>, it converts a Log4j
+ When a <a href="appenders.html#NoSQLAppenderMongoDB2">MongoDB3 Appender</a> or
+ <a href="appenders.html#NoSQLAppenderMongoDB3">MongoDB4 Appender</a> is configured with a <code>MessageLayout</code>, it converts a Log4j
<code>MapMessage</code> to fields in a MongoDB object.
</li>
</ul>