You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by pk...@apache.org on 2024/09/02 11:11:50 UTC
(logging-log4j2) branch feature/main/1914_log4j_jdbc_jndi created (now 2b799a8444)
This is an automated email from the ASF dual-hosted git repository.
pkarwasz pushed a change to branch feature/main/1914_log4j_jdbc_jndi
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
at 2b799a8444 Move JNDI `DataSource` to separate module
This branch includes the following new commits:
new 2b799a8444 Move JNDI `DataSource` to separate module
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(logging-log4j2) 01/01: Move JNDI `DataSource` to separate module
Posted by pk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
pkarwasz pushed a commit to branch feature/main/1914_log4j_jdbc_jndi
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
commit 2b799a84440585cd1a3b21879d36178b635eca02
Author: Piotr P. Karwasz <pi...@karwasz.org>
AuthorDate: Mon Sep 2 13:11:34 2024 +0200
Move JNDI `DataSource` to separate module
We move the [`DataSource` connection source](https://logging.staged.apache.org/log4j/3.x/manual/appenders/database.html#DataSourceConnectionSource)
to a new module `log4j-jdbc-jndi`.
The main rationale for this change is to remove the **optional** dependency
on `log4j-jndi` from `log4j-jdbc`.
This change forces users to opt-in for the JNDI `DataSource` by adding `log4j-jdbc-jndi` to their classpath.
After this change, the `log4j-jdbc` artifact contains:
* the `JDBC` Appender,
* a connection source based on `DriverManager`,
* a connection source based on a static factory method.
Closes #1914
---
log4j-jdbc-dbcp2/pom.xml | 2 +-
log4j-jdbc-jndi/.log4j-plugin-processing-activator | 1 +
{log4j-jdbc => log4j-jdbc-jndi}/pom.xml | 115 +++++++++++----------
.../jdbc/jndi}/DataSourceConnectionSource.java | 32 ++++--
.../jndi}/AbstractJdbcAppenderDataSourceTest.java | 16 +--
.../jdbc/jndi}/DataSourceConnectionSourceTest.java | 19 ++--
.../jdbc/jndi}/JdbcAppenderH2DataSourceTest.java | 6 +-
.../jndi}/JdbcAppenderHsqldbDataSourceTest.java | 3 +-
.../JdbcAppenderMapMessageDataSourceTest.java | 8 +-
.../logging/log4j/jdbc/jndi/JdbcH2TestHelper.java | 32 +++---
.../apache/logging/log4j/jdbc/jndi/JdbcRule.java | 90 ++++++++++++++++
.../AbstractJdbcAppenderDataSourceTest.xml | 9 +-
.../resources/DataSourceConnectionSourceTest.xml | 20 ++--
.../JdbcAppenderMapMessageDataSourceTest.xml | 9 +-
log4j-jdbc/pom.xml | 88 +++++++++-------
.../log4j/jdbc/appender/internal/JndiUtil.java | 57 ----------
.../AbstractJdbcAppenderFactoryMethodTest.java | 3 +-
.../FactoryMethodConnectionSourceTest.java | 2 +-
.../JdbcAppenderColumnMappingLiteralTest.java | 5 +-
.../JdbcAppenderColumnMappingPatternTest.java | 5 +-
.../appender/JdbcAppenderH2FactoryMethodTest.java | 3 -
.../JdbcAppenderHsqldbFactoryMethodTest.java | 3 -
.../JdbcAppenderStringSubstitutionTest.java | 3 +-
...y.xml => FactoryMethodConnectionSourceTest.xml} | 20 ++--
...ml => JdbcAppenderColumnMappingLiteralTest.xml} | 7 +-
...ml => JdbcAppenderColumnMappingPatternTest.xml} | 7 +-
...hod.xml => JdbcAppenderH2FactoryMethodTest.xml} | 23 +++--
...xml => JdbcAppenderHsqldbFactoryMethodTest.xml} | 7 +-
....xml => JdbcAppenderStringSubstitutionTest.xml} | 7 +-
pom.xml | 7 ++
.../1914_split_JDBC_JNDI_connection_source.xml | 8 ++
src/site/antora/modules/ROOT/pages/components.adoc | 17 +++
.../ROOT/pages/manual/appenders/database.adoc | 18 ++--
.../modules/ROOT/pages/plugin-reference.adoc | 14 +--
.../ROOT/partials/components/log4j-jdbc-jndi.adoc | 41 ++++++++
35 files changed, 417 insertions(+), 290 deletions(-)
diff --git a/log4j-jdbc-dbcp2/pom.xml b/log4j-jdbc-dbcp2/pom.xml
index 70882c37f0..f0854bf429 100644
--- a/log4j-jdbc-dbcp2/pom.xml
+++ b/log4j-jdbc-dbcp2/pom.xml
@@ -27,7 +27,7 @@
</parent>
<artifactId>log4j-jdbc-dbcp2</artifactId>
- <name>Apache Log4j JDBC DBCP 2</name>
+ <name>Apache Log4j JDBC: DBCP 2 datasource</name>
<description>Connection source for the JDBC Appender using Apache Commons DBCP2.</description>
<properties>
diff --git a/log4j-jdbc-jndi/.log4j-plugin-processing-activator b/log4j-jdbc-jndi/.log4j-plugin-processing-activator
new file mode 100644
index 0000000000..ba133f3696
--- /dev/null
+++ b/log4j-jdbc-jndi/.log4j-plugin-processing-activator
@@ -0,0 +1 @@
+This file is here to activate the `plugin-processing` Maven profile.
diff --git a/log4j-jdbc/pom.xml b/log4j-jdbc-jndi/pom.xml
similarity index 64%
copy from log4j-jdbc/pom.xml
copy to log4j-jdbc-jndi/pom.xml
index ebfd698839..17d7170c00 100644
--- a/log4j-jdbc/pom.xml
+++ b/log4j-jdbc-jndi/pom.xml
@@ -16,9 +16,7 @@
~ 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">
-
<modelVersion>4.0.0</modelVersion>
-
<parent>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j</artifactId>
@@ -26,112 +24,119 @@
<relativePath>../log4j-parent</relativePath>
</parent>
- <artifactId>log4j-jdbc</artifactId>
- <name>Apache Log4j JDBC</name>
- <description>Apache Log4j Java Database Connectivity (JDBC).</description>
+ <artifactId>log4j-jdbc-jndi</artifactId>
+ <name>Apache Log4j JDBC: JNDI datasource</name>
+ <description>Connection source for the JDBC Appender using JNDI.</description>
- <properties>
- <log4jParentDir>${basedir}/..</log4jParentDir>
+ <dependencies>
- <!--
- ~ OSGi and JPMS options
- -->
- <bnd-extra-package-options>
- <!-- `log4j-jndi` is optional -->
- org.apache.logging.log4j.jndi;resolution:=optional
- </bnd-extra-package-options>
- </properties>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ </dependency>
- <dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-jdbc</artifactId>
+ </dependency>
+
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jndi</artifactId>
- <optional>true</optional>
</dependency>
+
<dependency>
<groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-api-test</artifactId>
- <scope>test</scope>
+ <artifactId>log4j-plugins</artifactId>
</dependency>
+
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core-test</artifactId>
<scope>test</scope>
+ <!--
+ ~ Exclude some unused dependencies of `log4j-core-test`.
+ -->
+ <exclusions>
+ <exclusion>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-migrationsupport</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-params</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-model</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
+
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jndi-test</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <scope>test</scope>
- </dependency>
+
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <scope>test</scope>
- </dependency>
+
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest</artifactId>
- <scope>test</scope>
- </dependency>
+
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-engine</artifactId>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
+
<!-- Mocking framework for use with JUnit -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
- </dependencies>
- <build>
- <plugins>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <executions>
- <execution>
- <id>default-testJar</id>
- <goals>
- <goal>test-jar</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- </plugins>
- </build>
+ </dependencies>
</project>
diff --git a/log4j-jdbc/src/main/java/org/apache/logging/log4j/jdbc/appender/DataSourceConnectionSource.java b/log4j-jdbc-jndi/src/main/java/org/apache/logging/log4j/jdbc/jndi/DataSourceConnectionSource.java
similarity index 66%
rename from log4j-jdbc/src/main/java/org/apache/logging/log4j/jdbc/appender/DataSourceConnectionSource.java
rename to log4j-jdbc-jndi/src/main/java/org/apache/logging/log4j/jdbc/jndi/DataSourceConnectionSource.java
index 333a20ca40..422aba34a1 100644
--- a/log4j-jdbc/src/main/java/org/apache/logging/log4j/jdbc/appender/DataSourceConnectionSource.java
+++ b/log4j-jdbc-jndi/src/main/java/org/apache/logging/log4j/jdbc/jndi/DataSourceConnectionSource.java
@@ -14,13 +14,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.logging.log4j.jdbc.appender;
+package org.apache.logging.log4j.jdbc.jndi;
import java.sql.Connection;
import java.sql.SQLException;
+import javax.naming.NamingException;
import javax.sql.DataSource;
import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.jdbc.appender.internal.JndiUtil;
+import org.apache.logging.log4j.jdbc.appender.AbstractConnectionSource;
+import org.apache.logging.log4j.jndi.JndiManager;
import org.apache.logging.log4j.plugins.Configurable;
import org.apache.logging.log4j.plugins.Plugin;
import org.apache.logging.log4j.plugins.PluginAttribute;
@@ -29,11 +31,14 @@ import org.apache.logging.log4j.status.StatusLogger;
import org.apache.logging.log4j.util.Strings;
/**
- * A {@link JdbcAppender} connection source that uses a {@link DataSource} to connect to the database.
+ * A {@link org.apache.logging.log4j.jdbc.appender.JdbcAppender} connection source that uses a {@link DataSource} to connect to the database.
*/
@Configurable(elementType = "connectionSource", printObject = true)
@Plugin("DataSource")
public final class DataSourceConnectionSource extends AbstractConnectionSource {
+ private static final String DOC_URL =
+ "https://logging.staged.apache.org/log4j/3.x/manual/systemproperties.html#properties-jndi-support";
+ static final String JNDI_MANAGER_NAME = "org.apache.logging.log4j.jdbc.jndi.DataSourceConnectionSource";
private static final Logger LOGGER = StatusLogger.getLogger();
private final DataSource dataSource;
@@ -62,8 +67,10 @@ public final class DataSourceConnectionSource extends AbstractConnectionSource {
*/
@PluginFactory
public static DataSourceConnectionSource createConnectionSource(@PluginAttribute final String jndiName) {
- if (!JndiUtil.isJndiJdbcEnabled()) {
- LOGGER.error("JNDI must be enabled by setting log4j2.enableJndiJdbc=true");
+ if (!JndiManager.isJndiJdbcEnabled()) {
+ LOGGER.error(
+ "JNDI must be enabled by setting `log4j.jndi.enableJdbc=\"true\"`\nSee {} for more details.",
+ DOC_URL);
return null;
}
if (Strings.isEmpty(jndiName)) {
@@ -71,11 +78,16 @@ public final class DataSourceConnectionSource extends AbstractConnectionSource {
return null;
}
- final DataSource dataSource = JndiUtil.getDataSource(jndiName);
- if (dataSource == null) {
- return null;
+ try {
+ final DataSource dataSource =
+ JndiManager.getDefaultManager(JNDI_MANAGER_NAME).lookup(jndiName);
+ if (dataSource != null) {
+ return new DataSourceConnectionSource(jndiName, dataSource);
+ }
+ LOGGER.error("Failed to retrieve JNDI data source with name {}.", jndiName);
+ } catch (final NamingException e) {
+ LOGGER.error("Failed to retrieve JNDI data source with name {}.", jndiName, e);
}
-
- return new DataSourceConnectionSource(jndiName, dataSource);
+ return null;
}
}
diff --git a/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/AbstractJdbcAppenderDataSourceTest.java b/log4j-jdbc-jndi/src/test/java/org/apache/logging/log4j/jdbc/jndi/AbstractJdbcAppenderDataSourceTest.java
similarity index 89%
rename from log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/AbstractJdbcAppenderDataSourceTest.java
rename to log4j-jdbc-jndi/src/test/java/org/apache/logging/log4j/jdbc/jndi/AbstractJdbcAppenderDataSourceTest.java
index 33e0f4dc5b..92bd0780aa 100644
--- a/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/AbstractJdbcAppenderDataSourceTest.java
+++ b/log4j-jdbc-jndi/src/test/java/org/apache/logging/log4j/jdbc/jndi/AbstractJdbcAppenderDataSourceTest.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.logging.log4j.jdbc.appender;
+package org.apache.logging.log4j.jdbc.jndi;
import static org.apache.logging.log4j.core.test.TestConstants.JNDI_ENABLE_JDBC;
import static org.junit.Assert.assertEquals;
@@ -34,14 +34,12 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
import org.apache.logging.log4j.core.util.Throwables;
-import org.apache.logging.log4j.jdbc.appender.internal.JndiUtil;
import org.apache.logging.log4j.jndi.test.junit.JndiRule;
import org.h2.util.IOUtils;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.RuleChain;
-import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
/**
@@ -62,23 +60,19 @@ public abstract class AbstractJdbcAppenderDataSourceTest {
protected AbstractJdbcAppenderDataSourceTest(final JdbcRule jdbcRule) {
this.rules = RuleChain.emptyRuleChain()
.around(new JndiRule(
- JndiUtil.JNDI_MANAGER_NAME,
+ DataSourceConnectionSource.JNDI_MANAGER_NAME,
"java:/comp/env/jdbc/TestDataSourceAppender",
createMockDataSource()))
.around(jdbcRule)
- .around(new LoggerContextRule("org/apache/logging/log4j/jdbc/appender/log4j2-data-source.xml"));
+ .around(new LoggerContextRule("AbstractJdbcAppenderDataSourceTest.xml"));
this.jdbcRule = jdbcRule;
}
private DataSource createMockDataSource() {
try {
final DataSource dataSource = mock(DataSource.class);
- given(dataSource.getConnection()).willAnswer(new Answer<Connection>() {
- @Override
- public Connection answer(final InvocationOnMock invocation) throws Throwable {
- return jdbcRule.getConnectionSource().getConnection();
- }
- });
+ given(dataSource.getConnection()).willAnswer((Answer<Connection>)
+ invocation -> jdbcRule.getConnectionSource().getConnection());
return dataSource;
} catch (final SQLException e) {
Throwables.rethrow(e);
diff --git a/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/DataSourceConnectionSourceTest.java b/log4j-jdbc-jndi/src/test/java/org/apache/logging/log4j/jdbc/jndi/DataSourceConnectionSourceTest.java
similarity index 85%
rename from log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/DataSourceConnectionSourceTest.java
rename to log4j-jdbc-jndi/src/test/java/org/apache/logging/log4j/jdbc/jndi/DataSourceConnectionSourceTest.java
index eb949024aa..ba5d5b0741 100644
--- a/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/DataSourceConnectionSourceTest.java
+++ b/log4j-jdbc-jndi/src/test/java/org/apache/logging/log4j/jdbc/jndi/DataSourceConnectionSourceTest.java
@@ -14,21 +14,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.logging.log4j.jdbc.appender;
+package org.apache.logging.log4j.jdbc.jndi;
-import static org.apache.logging.log4j.core.test.TestConstants.JNDI_ENABLE_JDBC;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.Mockito.mock;
+import static org.apache.logging.log4j.core.test.TestConstants.*;
+import static org.junit.Assert.*;
+import static org.mockito.BDDMockito.*;
+import static org.mockito.Mockito.*;
import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
-import org.apache.logging.log4j.jdbc.appender.internal.JndiUtil;
import org.apache.logging.log4j.jndi.test.junit.JndiRule;
import org.junit.Rule;
import org.junit.Test;
@@ -45,7 +41,7 @@ public class DataSourceConnectionSourceTest {
return new Object[][] {{"java:/comp/env/jdbc/Logging01"}, {"java:/comp/env/jdbc/Logging02"}};
}
- private static final String CONFIG = "log4j-fatalOnly.xml";
+ private static final String CONFIG = "DataSourceConnectionSourceTest.xml";
@Rule
public final RuleChain rules;
@@ -54,7 +50,8 @@ public class DataSourceConnectionSourceTest {
private final String jndiURL;
public DataSourceConnectionSourceTest(final String jndiURL) {
- this.rules = RuleChain.outerRule(new JndiRule(JndiUtil.JNDI_MANAGER_NAME, jndiURL, dataSource))
+ this.rules = RuleChain.outerRule(
+ new JndiRule(DataSourceConnectionSource.JNDI_MANAGER_NAME, jndiURL, dataSource))
.around(new LoggerContextRule(CONFIG));
this.jndiURL = jndiURL;
}
diff --git a/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderH2DataSourceTest.java b/log4j-jdbc-jndi/src/test/java/org/apache/logging/log4j/jdbc/jndi/JdbcAppenderH2DataSourceTest.java
similarity index 95%
copy from log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderH2DataSourceTest.java
copy to log4j-jdbc-jndi/src/test/java/org/apache/logging/log4j/jdbc/jndi/JdbcAppenderH2DataSourceTest.java
index 8046fa51d0..1a94e94910 100644
--- a/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderH2DataSourceTest.java
+++ b/log4j-jdbc-jndi/src/test/java/org/apache/logging/log4j/jdbc/jndi/JdbcAppenderH2DataSourceTest.java
@@ -14,12 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.logging.log4j.jdbc.appender;
+package org.apache.logging.log4j.jdbc.jndi;
-/**
- *
- */
public class JdbcAppenderH2DataSourceTest extends AbstractJdbcAppenderDataSourceTest {
+
public JdbcAppenderH2DataSourceTest() {
super(new JdbcRule(
JdbcH2TestHelper.TEST_CONFIGURATION_SOURCE_MEM,
diff --git a/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderHsqldbDataSourceTest.java b/log4j-jdbc-jndi/src/test/java/org/apache/logging/log4j/jdbc/jndi/JdbcAppenderHsqldbDataSourceTest.java
similarity index 93%
rename from log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderHsqldbDataSourceTest.java
rename to log4j-jdbc-jndi/src/test/java/org/apache/logging/log4j/jdbc/jndi/JdbcAppenderHsqldbDataSourceTest.java
index 4bc68c5f73..c5a6ff0756 100644
--- a/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderHsqldbDataSourceTest.java
+++ b/log4j-jdbc-jndi/src/test/java/org/apache/logging/log4j/jdbc/jndi/JdbcAppenderHsqldbDataSourceTest.java
@@ -14,11 +14,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.logging.log4j.jdbc.appender;
+package org.apache.logging.log4j.jdbc.jndi;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
+import org.apache.logging.log4j.jdbc.appender.AbstractConnectionSource;
/**
*
diff --git a/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderMapMessageDataSourceTest.java b/log4j-jdbc-jndi/src/test/java/org/apache/logging/log4j/jdbc/jndi/JdbcAppenderMapMessageDataSourceTest.java
similarity index 95%
rename from log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderMapMessageDataSourceTest.java
rename to log4j-jdbc-jndi/src/test/java/org/apache/logging/log4j/jdbc/jndi/JdbcAppenderMapMessageDataSourceTest.java
index 125a17db70..f57b1e1c8a 100644
--- a/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderMapMessageDataSourceTest.java
+++ b/log4j-jdbc-jndi/src/test/java/org/apache/logging/log4j/jdbc/jndi/JdbcAppenderMapMessageDataSourceTest.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.logging.log4j.jdbc.appender;
+package org.apache.logging.log4j.jdbc.jndi;
import static org.apache.logging.log4j.core.test.TestConstants.JNDI_ENABLE_JDBC;
import static org.junit.Assert.assertFalse;
@@ -34,7 +34,6 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
import org.apache.logging.log4j.core.util.Throwables;
-import org.apache.logging.log4j.jdbc.appender.internal.JndiUtil;
import org.apache.logging.log4j.jndi.test.junit.JndiRule;
import org.apache.logging.log4j.message.MapMessage;
import org.junit.Assert;
@@ -73,12 +72,11 @@ public class JdbcAppenderMapMessageDataSourceTest {
// @formatter:off
this.rules = RuleChain.emptyRuleChain()
.around(new JndiRule(
- JndiUtil.JNDI_MANAGER_NAME,
+ DataSourceConnectionSource.JNDI_MANAGER_NAME,
"java:/comp/env/jdbc/TestDataSourceAppender",
createMockDataSource()))
.around(jdbcRule)
- .around(new LoggerContextRule(
- "org/apache/logging/log4j/jdbc/appender/log4j2-data-source-map-message.xml"));
+ .around(new LoggerContextRule("JdbcAppenderMapMessageDataSourceTest.xml"));
// @formatter:on
this.jdbcRule = jdbcRule;
}
diff --git a/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderH2DataSourceTest.java b/log4j-jdbc-jndi/src/test/java/org/apache/logging/log4j/jdbc/jndi/JdbcH2TestHelper.java
similarity index 51%
rename from log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderH2DataSourceTest.java
rename to log4j-jdbc-jndi/src/test/java/org/apache/logging/log4j/jdbc/jndi/JdbcH2TestHelper.java
index 8046fa51d0..7e2a7220c8 100644
--- a/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderH2DataSourceTest.java
+++ b/log4j-jdbc-jndi/src/test/java/org/apache/logging/log4j/jdbc/jndi/JdbcH2TestHelper.java
@@ -14,18 +14,24 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.logging.log4j.jdbc.appender;
+package org.apache.logging.log4j.jdbc.jndi;
-/**
- *
- */
-public class JdbcAppenderH2DataSourceTest extends AbstractJdbcAppenderDataSourceTest {
- public JdbcAppenderH2DataSourceTest() {
- super(new JdbcRule(
- JdbcH2TestHelper.TEST_CONFIGURATION_SOURCE_MEM,
- "CREATE TABLE dsLogEntry ("
- + "id INTEGER GENERATED BY DEFAULT AS IDENTITY, eventDate DATETIME, literalColumn VARCHAR(255), level NVARCHAR(10), "
- + "logger NVARCHAR(255), message VARCHAR(1024), exception NCLOB, anotherDate TIMESTAMP" + ")",
- "DROP TABLE IF EXISTS dsLogEntry"));
- }
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import org.apache.logging.log4j.jdbc.appender.AbstractConnectionSource;
+import org.apache.logging.log4j.jdbc.appender.ConnectionSource;
+
+public class JdbcH2TestHelper {
+
+ private static final String CONNECTION_STRING = "jdbc:h2:mem:Log4j";
+ private static final String USERNAME = "sa";
+ private static final String PASSWORD = "";
+
+ public static ConnectionSource TEST_CONFIGURATION_SOURCE_MEM = new AbstractConnectionSource() {
+ @Override
+ public Connection getConnection() throws SQLException {
+ return DriverManager.getConnection(CONNECTION_STRING, USERNAME, PASSWORD);
+ }
+ };
}
diff --git a/log4j-jdbc-jndi/src/test/java/org/apache/logging/log4j/jdbc/jndi/JdbcRule.java b/log4j-jdbc-jndi/src/test/java/org/apache/logging/log4j/jdbc/jndi/JdbcRule.java
new file mode 100644
index 0000000000..8f833d5027
--- /dev/null
+++ b/log4j-jdbc-jndi/src/test/java/org/apache/logging/log4j/jdbc/jndi/JdbcRule.java
@@ -0,0 +1,90 @@
+/*
+ * 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.jdbc.jndi;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Objects;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
+import org.apache.logging.log4j.jdbc.appender.ConnectionSource;
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+
+/**
+ * JUnit rule to set up a database. This will create a table using the configure creation statement on startup, run its
+ * wrapped test(s), then execute a drop table statement on shutdown, and finally will attempt execute a {@code SHUTDOWN}
+ * command afterward (e.g., for H2, HSQLDB). When used in integration tests, this rule should be the outer rule in a
+ * chain with {@link LoggerContextRule}.
+ *
+ * @since 2.8
+ */
+public class JdbcRule implements TestRule {
+
+ private final ConnectionSource connectionSource;
+ private final String createTableStatement;
+ private final String dropTableStatement;
+
+ /**
+ * Creates a JdbcRule using a {@link ConnectionSource} and a table creation statement.
+ *
+ * @param connectionSource a required source for obtaining a Connection.
+ * @param createTableStatement an optional SQL DDL statement to create a table for use in a JUnit test.
+ * @param dropTableStatement an optional SQL DDL statement to drop the created table.
+ */
+ public JdbcRule(
+ final ConnectionSource connectionSource,
+ final String createTableStatement,
+ final String dropTableStatement) {
+ this.connectionSource = Objects.requireNonNull(connectionSource, "connectionSource");
+ this.createTableStatement = createTableStatement;
+ this.dropTableStatement = dropTableStatement;
+ }
+
+ @Override
+ public org.junit.runners.model.Statement apply(
+ final org.junit.runners.model.Statement base, final Description description) {
+ return new org.junit.runners.model.Statement() {
+ @Override
+ public void evaluate() throws Throwable {
+ try (final Connection connection = getConnection();
+ final Statement statement = connection.createStatement()) {
+ try {
+ if (StringUtils.isNotEmpty(createTableStatement)) {
+ statement.executeUpdate(createTableStatement);
+ }
+ base.evaluate();
+ } finally {
+ if (StringUtils.isNotEmpty(dropTableStatement)) {
+ statement.executeUpdate(dropTableStatement);
+ }
+ statement.execute("SHUTDOWN");
+ }
+ }
+ }
+ };
+ }
+
+ public Connection getConnection() throws SQLException {
+ return connectionSource.getConnection();
+ }
+
+ public ConnectionSource getConnectionSource() {
+ return connectionSource;
+ }
+}
diff --git a/log4j-jdbc/src/test/resources/org/apache/logging/log4j/jdbc/appender/log4j2-data-source.xml b/log4j-jdbc-jndi/src/test/resources/AbstractJdbcAppenderDataSourceTest.xml
similarity index 81%
rename from log4j-jdbc/src/test/resources/org/apache/logging/log4j/jdbc/appender/log4j2-data-source.xml
rename to log4j-jdbc-jndi/src/test/resources/AbstractJdbcAppenderDataSourceTest.xml
index c589410db4..1b6cd3f182 100644
--- a/log4j-jdbc/src/test/resources/org/apache/logging/log4j/jdbc/appender/log4j2-data-source.xml
+++ b/log4j-jdbc-jndi/src/test/resources/AbstractJdbcAppenderDataSourceTest.xml
@@ -15,8 +15,11 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<Configuration status="OFF">
-
+<Configuration xmlns="https://logging.apache.org/xml/ns"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ https://logging.apache.org/xml/ns
+ https://logging.apache.org/xml/ns/log4j-config-3.xsd">
<Appenders>
<Console name="STDOUT">
<PatternLayout pattern="%C{1.} %m %level MDC%X%n"/>
@@ -33,7 +36,7 @@
</Appenders>
<Loggers>
- <Logger name="org.apache.logging.log4j.jdbc.appender" level="debug" additivity="false">
+ <Logger name="org.apache.logging.log4j.jdbc.jndi" level="debug" additivity="false">
<AppenderRef ref="databaseAppender" />
</Logger>
diff --git a/log4j-jdbc/src/test/resources/log4j-fatalOnly.xml b/log4j-jdbc-jndi/src/test/resources/DataSourceConnectionSourceTest.xml
similarity index 73%
copy from log4j-jdbc/src/test/resources/log4j-fatalOnly.xml
copy to log4j-jdbc-jndi/src/test/resources/DataSourceConnectionSourceTest.xml
index b3e386f33e..95ac8003f8 100644
--- a/log4j-jdbc/src/test/resources/log4j-fatalOnly.xml
+++ b/log4j-jdbc-jndi/src/test/resources/DataSourceConnectionSourceTest.xml
@@ -15,19 +15,13 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<Configuration status="OFF" name="Log4jTest">
-
- <Appenders>
- <Console name="STDOUT">
- <PatternLayout pattern="%m%n"/>
- </Console>
- </Appenders>
-
+<Configuration xmlns="https://logging.apache.org/xml/ns"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ https://logging.apache.org/xml/ns
+ https://logging.apache.org/xml/ns/log4j-config-3.xsd">
+ <Appenders/>
<Loggers>
-
- <Root level="fatal">
- <AppenderRef ref="STDOUT"/>
- </Root>
+ <Root level="OFF"/>
</Loggers>
-
</Configuration>
diff --git a/log4j-jdbc/src/test/resources/org/apache/logging/log4j/jdbc/appender/log4j2-data-source-map-message.xml b/log4j-jdbc-jndi/src/test/resources/JdbcAppenderMapMessageDataSourceTest.xml
similarity index 79%
rename from log4j-jdbc/src/test/resources/org/apache/logging/log4j/jdbc/appender/log4j2-data-source-map-message.xml
rename to log4j-jdbc-jndi/src/test/resources/JdbcAppenderMapMessageDataSourceTest.xml
index 0d2a9e2487..b3926b2e5e 100644
--- a/log4j-jdbc/src/test/resources/org/apache/logging/log4j/jdbc/appender/log4j2-data-source-map-message.xml
+++ b/log4j-jdbc-jndi/src/test/resources/JdbcAppenderMapMessageDataSourceTest.xml
@@ -15,8 +15,11 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<Configuration status="ERROR">
-
+<Configuration xmlns="https://logging.apache.org/xml/ns"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ https://logging.apache.org/xml/ns
+ https://logging.apache.org/xml/ns/log4j-config-3.xsd">
<Appenders>
<Console name="STDOUT">
<PatternLayout pattern="%C{1.} %m %level MDC%X%n"/>
@@ -31,7 +34,7 @@
</Appenders>
<Loggers>
- <Logger name="org.apache.logging.log4j.jdbc.appender" level="debug" additivity="false">
+ <Logger name="org.apache.logging.log4j.jdbc.jndi" level="debug" additivity="false">
<AppenderRef ref="databaseAppender" />
</Logger>
diff --git a/log4j-jdbc/pom.xml b/log4j-jdbc/pom.xml
index ebfd698839..03b8238ed4 100644
--- a/log4j-jdbc/pom.xml
+++ b/log4j-jdbc/pom.xml
@@ -30,89 +30,99 @@
<name>Apache Log4j JDBC</name>
<description>Apache Log4j Java Database Connectivity (JDBC).</description>
- <properties>
- <log4jParentDir>${basedir}/..</log4jParentDir>
-
- <!--
- ~ OSGi and JPMS options
- -->
- <bnd-extra-package-options>
- <!-- `log4j-jndi` is optional -->
- org.apache.logging.log4j.jndi;resolution:=optional
- </bnd-extra-package-options>
- </properties>
-
<dependencies>
+
<dependency>
<groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-core</artifactId>
+ <artifactId>log4j-api</artifactId>
</dependency>
+
<dependency>
<groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-jndi</artifactId>
- <optional>true</optional>
+ <artifactId>log4j-core</artifactId>
</dependency>
+
<dependency>
<groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-api-test</artifactId>
- <scope>test</scope>
+ <artifactId>log4j-plugins</artifactId>
</dependency>
+
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core-test</artifactId>
<scope>test</scope>
+ <!--
+ ~ Exclude some unused dependencies of `log4j-core-test`.
+ -->
+ <exclusions>
+ <exclusion>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-engine</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-migrationsupport</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-params</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-model</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
- <dependency>
- <groupId>org.apache.logging.log4j</groupId>
- <artifactId>log4j-jndi-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <scope>test</scope>
- </dependency>
+
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <scope>test</scope>
- </dependency>
+
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest</artifactId>
- <scope>test</scope>
- </dependency>
+
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-engine</artifactId>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
+
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
+
<!-- Mocking framework for use with JUnit -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
+
</dependencies>
<build>
diff --git a/log4j-jdbc/src/main/java/org/apache/logging/log4j/jdbc/appender/internal/JndiUtil.java b/log4j-jdbc/src/main/java/org/apache/logging/log4j/jdbc/appender/internal/JndiUtil.java
deleted file mode 100644
index 9eca48f064..0000000000
--- a/log4j-jdbc/src/main/java/org/apache/logging/log4j/jdbc/appender/internal/JndiUtil.java
+++ /dev/null
@@ -1,57 +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.jdbc.appender.internal;
-
-import javax.naming.NamingException;
-import javax.sql.DataSource;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.jdbc.appender.DataSourceConnectionSource;
-import org.apache.logging.log4j.jndi.JndiManager;
-import org.apache.logging.log4j.status.StatusLogger;
-
-/**
- * This class is solely for the purpose of keeping DataSourceConnectionSource from getting a NoClassDefFoundError.
- */
-public final class JndiUtil {
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- /**
- * Manager name used for accessing the {@link JndiManager} instance.
- */
- public static final String JNDI_MANAGER_NAME = DataSourceConnectionSource.class.getCanonicalName();
-
- private JndiUtil() {}
-
- public static DataSource getDataSource(final String jndiName) {
- try {
- final DataSource dataSource =
- JndiManager.getDefaultManager(JNDI_MANAGER_NAME).lookup(jndiName);
- if (dataSource == null) {
- LOGGER.error("No data source found with JNDI name [" + jndiName + "].");
- return null;
- }
- return dataSource;
- } catch (final NamingException e) {
- LOGGER.error(e.getMessage(), e);
- return null;
- }
- }
-
- public static boolean isJndiJdbcEnabled() {
- return JndiManager.isJndiJdbcEnabled();
- }
-}
diff --git a/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/AbstractJdbcAppenderFactoryMethodTest.java b/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/AbstractJdbcAppenderFactoryMethodTest.java
index 2b1e58c3e4..69b5bf88fa 100644
--- a/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/AbstractJdbcAppenderFactoryMethodTest.java
+++ b/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/AbstractJdbcAppenderFactoryMethodTest.java
@@ -50,8 +50,7 @@ public abstract class AbstractJdbcAppenderFactoryMethodTest {
protected AbstractJdbcAppenderFactoryMethodTest(final JdbcRule jdbcRule, final String databaseType) {
this.rules = RuleChain.emptyRuleChain()
.around(jdbcRule)
- .around(new LoggerContextRule(
- "org/apache/logging/log4j/jdbc/appender/log4j2-" + databaseType + "-factory-method.xml"));
+ .around(new LoggerContextRule(getClass().getSimpleName() + ".xml"));
this.jdbcRule = jdbcRule;
}
diff --git a/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/FactoryMethodConnectionSourceTest.java b/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/FactoryMethodConnectionSourceTest.java
index b67b71aa8a..b2a9189dc8 100644
--- a/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/FactoryMethodConnectionSourceTest.java
+++ b/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/FactoryMethodConnectionSourceTest.java
@@ -33,7 +33,7 @@ import org.junit.Test;
public class FactoryMethodConnectionSourceTest {
private static final ThreadLocal<Object> holder = new ThreadLocal<>();
- private static final String CONFIG = "log4j-fatalOnly.xml";
+ private static final String CONFIG = "FactoryMethodConnectionSourceTest.xml";
@ClassRule
public static LoggerContextRule ctx = new LoggerContextRule(CONFIG);
diff --git a/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderColumnMappingLiteralTest.java b/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderColumnMappingLiteralTest.java
index 132eed8b91..6273ab9f7d 100644
--- a/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderColumnMappingLiteralTest.java
+++ b/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderColumnMappingLiteralTest.java
@@ -50,9 +50,8 @@ public class JdbcAppenderColumnMappingLiteralTest {
}
protected JdbcAppenderColumnMappingLiteralTest(final JdbcRule jdbcRule) {
- this.rules = RuleChainFactory.create(
- jdbcRule,
- new LoggerContextRule("org/apache/logging/log4j/jdbc/appender/log4j2-dm-column-mapping-literal.xml"));
+ this.rules =
+ RuleChainFactory.create(jdbcRule, new LoggerContextRule("JdbcAppenderColumnMappingLiteralTest.xml"));
this.jdbcRule = jdbcRule;
}
diff --git a/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderColumnMappingPatternTest.java b/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderColumnMappingPatternTest.java
index 781bbf163b..9526272a99 100644
--- a/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderColumnMappingPatternTest.java
+++ b/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderColumnMappingPatternTest.java
@@ -49,9 +49,8 @@ public class JdbcAppenderColumnMappingPatternTest {
}
protected JdbcAppenderColumnMappingPatternTest(final JdbcRule jdbcRule) {
- this.rules = RuleChainFactory.create(
- jdbcRule,
- new LoggerContextRule("org/apache/logging/log4j/jdbc/appender/log4j2-dm-column-mapping-pattern.xml"));
+ this.rules =
+ RuleChainFactory.create(jdbcRule, new LoggerContextRule("JdbcAppenderColumnMappingPatternTest.xml"));
this.jdbcRule = jdbcRule;
}
diff --git a/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderH2FactoryMethodTest.java b/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderH2FactoryMethodTest.java
index cace44dd1a..6782639c0a 100644
--- a/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderH2FactoryMethodTest.java
+++ b/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderH2FactoryMethodTest.java
@@ -19,9 +19,6 @@ package org.apache.logging.log4j.jdbc.appender;
import java.sql.Connection;
import java.sql.SQLException;
-/**
- *
- */
public class JdbcAppenderH2FactoryMethodTest extends AbstractJdbcAppenderFactoryMethodTest {
public JdbcAppenderH2FactoryMethodTest() {
super(
diff --git a/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderHsqldbFactoryMethodTest.java b/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderHsqldbFactoryMethodTest.java
index c0e9cada5b..f2d23cb5c2 100644
--- a/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderHsqldbFactoryMethodTest.java
+++ b/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderHsqldbFactoryMethodTest.java
@@ -20,9 +20,6 @@ import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
-/**
- *
- */
public class JdbcAppenderHsqldbFactoryMethodTest extends AbstractJdbcAppenderFactoryMethodTest {
public JdbcAppenderHsqldbFactoryMethodTest() {
diff --git a/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderStringSubstitutionTest.java b/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderStringSubstitutionTest.java
index 81da06c4e9..b2e3788e3f 100644
--- a/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderStringSubstitutionTest.java
+++ b/log4j-jdbc/src/test/java/org/apache/logging/log4j/jdbc/appender/JdbcAppenderStringSubstitutionTest.java
@@ -38,8 +38,7 @@ public class JdbcAppenderStringSubstitutionTest {
}
@Rule
- public final LoggerContextRule rule =
- new LoggerContextRule("org/apache/logging/log4j/jdbc/appender/log4j2-jdbc-string-substitution.xml");
+ public final LoggerContextRule rule = new LoggerContextRule("JdbcAppenderStringSubstitutionTest.xml");
@Test
public void test() throws Exception {
diff --git a/log4j-jdbc/src/test/resources/log4j-fatalOnly.xml b/log4j-jdbc/src/test/resources/FactoryMethodConnectionSourceTest.xml
similarity index 73%
rename from log4j-jdbc/src/test/resources/log4j-fatalOnly.xml
rename to log4j-jdbc/src/test/resources/FactoryMethodConnectionSourceTest.xml
index b3e386f33e..95ac8003f8 100644
--- a/log4j-jdbc/src/test/resources/log4j-fatalOnly.xml
+++ b/log4j-jdbc/src/test/resources/FactoryMethodConnectionSourceTest.xml
@@ -15,19 +15,13 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<Configuration status="OFF" name="Log4jTest">
-
- <Appenders>
- <Console name="STDOUT">
- <PatternLayout pattern="%m%n"/>
- </Console>
- </Appenders>
-
+<Configuration xmlns="https://logging.apache.org/xml/ns"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ https://logging.apache.org/xml/ns
+ https://logging.apache.org/xml/ns/log4j-config-3.xsd">
+ <Appenders/>
<Loggers>
-
- <Root level="fatal">
- <AppenderRef ref="STDOUT"/>
- </Root>
+ <Root level="OFF"/>
</Loggers>
-
</Configuration>
diff --git a/log4j-jdbc/src/test/resources/org/apache/logging/log4j/jdbc/appender/log4j2-dm-column-mapping-literal.xml b/log4j-jdbc/src/test/resources/JdbcAppenderColumnMappingLiteralTest.xml
similarity index 85%
rename from log4j-jdbc/src/test/resources/org/apache/logging/log4j/jdbc/appender/log4j2-dm-column-mapping-literal.xml
rename to log4j-jdbc/src/test/resources/JdbcAppenderColumnMappingLiteralTest.xml
index 1a2debfb19..4f8a994d87 100644
--- a/log4j-jdbc/src/test/resources/org/apache/logging/log4j/jdbc/appender/log4j2-dm-column-mapping-literal.xml
+++ b/log4j-jdbc/src/test/resources/JdbcAppenderColumnMappingLiteralTest.xml
@@ -15,8 +15,11 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<Configuration status="ERROR">
-
+<Configuration xmlns="https://logging.apache.org/xml/ns"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ https://logging.apache.org/xml/ns
+ https://logging.apache.org/xml/ns/log4j-config-3.xsd">
<Appenders>
<Console name="STDOUT">
<PatternLayout pattern="%C{1.} %m %level MDC%X%n"/>
diff --git a/log4j-jdbc/src/test/resources/org/apache/logging/log4j/jdbc/appender/log4j2-dm-column-mapping-pattern.xml b/log4j-jdbc/src/test/resources/JdbcAppenderColumnMappingPatternTest.xml
similarity index 85%
rename from log4j-jdbc/src/test/resources/org/apache/logging/log4j/jdbc/appender/log4j2-dm-column-mapping-pattern.xml
rename to log4j-jdbc/src/test/resources/JdbcAppenderColumnMappingPatternTest.xml
index 47116a69e0..2901bd18a2 100644
--- a/log4j-jdbc/src/test/resources/org/apache/logging/log4j/jdbc/appender/log4j2-dm-column-mapping-pattern.xml
+++ b/log4j-jdbc/src/test/resources/JdbcAppenderColumnMappingPatternTest.xml
@@ -15,8 +15,11 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<Configuration status="OFF">
-
+<Configuration xmlns="https://logging.apache.org/xml/ns"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ https://logging.apache.org/xml/ns
+ https://logging.apache.org/xml/ns/log4j-config-3.xsd">
<Appenders>
<Console name="STDOUT">
<PatternLayout pattern="%C{1.} %m %level MDC%X%n"/>
diff --git a/log4j-jdbc/src/test/resources/org/apache/logging/log4j/jdbc/appender/log4j2-h2-factory-method.xml b/log4j-jdbc/src/test/resources/JdbcAppenderH2FactoryMethodTest.xml
similarity index 75%
rename from log4j-jdbc/src/test/resources/org/apache/logging/log4j/jdbc/appender/log4j2-h2-factory-method.xml
rename to log4j-jdbc/src/test/resources/JdbcAppenderH2FactoryMethodTest.xml
index faa16cfbea..d1fa5e6a89 100644
--- a/log4j-jdbc/src/test/resources/org/apache/logging/log4j/jdbc/appender/log4j2-h2-factory-method.xml
+++ b/log4j-jdbc/src/test/resources/JdbcAppenderH2FactoryMethodTest.xml
@@ -15,28 +15,31 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<Configuration status="OFF">
-
+<Configuration xmlns="https://logging.apache.org/xml/ns"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ https://logging.apache.org/xml/ns
+ https://logging.apache.org/xml/ns/log4j-config-3.xsd">
<Appenders>
<Console name="STDOUT">
<PatternLayout pattern="%C{1.} %m %level MDC%X%n"/>
</Console>
<Jdbc name="databaseAppender" tableName="fmLogEntry" ignoreExceptions="false">
<ConnectionFactory class="org.apache.logging.log4j.jdbc.appender.JdbcAppenderH2FactoryMethodTest"
- method="getConnection" />
- <Column name="eventDate" isEventTimestamp="true" />
- <Column name="literalColumn" literal="'Some Other Literal Value'" />
- <Column name="level" pattern="%level" />
- <Column name="logger" pattern="%logger" />
- <Column name="message" pattern="%message" isUnicode="false" />
- <Column name="exception" pattern="%ex{full}" isClob="true" />
+ method="getConnection"/>
+ <Column name="eventDate" isEventTimestamp="true"/>
+ <Column name="literalColumn" literal="'Some Other Literal Value'"/>
+ <Column name="level" pattern="%level"/>
+ <Column name="logger" pattern="%logger"/>
+ <Column name="message" pattern="%message" isUnicode="false"/>
+ <Column name="exception" pattern="%ex{full}" isClob="true"/>
<ColumnMapping name="anotherDate" type="java.sql.Timestamp"/>
</Jdbc>
</Appenders>
<Loggers>
<Logger name="org.apache.logging.log4j.jdbc.appender" level="debug" additivity="false">
- <AppenderRef ref="databaseAppender" />
+ <AppenderRef ref="databaseAppender"/>
</Logger>
<Root level="fatal">
diff --git a/log4j-jdbc/src/test/resources/org/apache/logging/log4j/jdbc/appender/log4j2-hsqldb-factory-method.xml b/log4j-jdbc/src/test/resources/JdbcAppenderHsqldbFactoryMethodTest.xml
similarity index 87%
rename from log4j-jdbc/src/test/resources/org/apache/logging/log4j/jdbc/appender/log4j2-hsqldb-factory-method.xml
rename to log4j-jdbc/src/test/resources/JdbcAppenderHsqldbFactoryMethodTest.xml
index 1a8f53a9a0..3271556cc2 100644
--- a/log4j-jdbc/src/test/resources/org/apache/logging/log4j/jdbc/appender/log4j2-hsqldb-factory-method.xml
+++ b/log4j-jdbc/src/test/resources/JdbcAppenderHsqldbFactoryMethodTest.xml
@@ -15,8 +15,11 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<Configuration status="OFF">
-
+<Configuration xmlns="https://logging.apache.org/xml/ns"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ https://logging.apache.org/xml/ns
+ https://logging.apache.org/xml/ns/log4j-config-3.xsd">
<Appenders>
<Console name="STDOUT">
<PatternLayout pattern="%C{1.} %m %level MDC%X%n"/>
diff --git a/log4j-jdbc/src/test/resources/org/apache/logging/log4j/jdbc/appender/log4j2-jdbc-string-substitution.xml b/log4j-jdbc/src/test/resources/JdbcAppenderStringSubstitutionTest.xml
similarity index 86%
rename from log4j-jdbc/src/test/resources/org/apache/logging/log4j/jdbc/appender/log4j2-jdbc-string-substitution.xml
rename to log4j-jdbc/src/test/resources/JdbcAppenderStringSubstitutionTest.xml
index 25f41f48ed..4546884f7e 100644
--- a/log4j-jdbc/src/test/resources/org/apache/logging/log4j/jdbc/appender/log4j2-jdbc-string-substitution.xml
+++ b/log4j-jdbc/src/test/resources/JdbcAppenderStringSubstitutionTest.xml
@@ -15,8 +15,11 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<Configuration status="ERROR">
-
+<Configuration xmlns="https://logging.apache.org/xml/ns"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ https://logging.apache.org/xml/ns
+ https://logging.apache.org/xml/ns/log4j-config-3.xsd">
<Appenders>
<Console name="STDOUT">
<PatternLayout pattern="%C{1.} %m %level MDC%X%n"/>
diff --git a/pom.xml b/pom.xml
index 1931478e9f..8c30047410 100644
--- a/pom.xml
+++ b/pom.xml
@@ -244,6 +244,7 @@
<module>log4j-jctools</module>
<module>log4j-jdbc</module>
<module>log4j-jdbc-dbcp2</module>
+ <module>log4j-jdbc-jndi</module>
<module>log4j-jndi</module>
<module>log4j-jndi-test</module>
<module>log4j-jpl</module>
@@ -454,6 +455,12 @@
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-jdbc-jndi</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jndi</artifactId>
diff --git a/src/changelog/.3.x.x/1914_split_JDBC_JNDI_connection_source.xml b/src/changelog/.3.x.x/1914_split_JDBC_JNDI_connection_source.xml
new file mode 100644
index 0000000000..0da26553ec
--- /dev/null
+++ b/src/changelog/.3.x.x/1914_split_JDBC_JNDI_connection_source.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<entry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="https://logging.apache.org/xml/ns"
+ xsi:schemaLocation="https://logging.apache.org/xml/ns https://logging.apache.org/xml/ns/log4j-changelog-0.xsd"
+ type="added">
+ <issue id="1914" link="https://github.com/apache/logging-log4j2/issues/1914"/>
+ <description format="asciidoc">Split off JDBC `DataSource` connection source into a new `log4j-jdbc-jndi` module.</description>
+</entry>
diff --git a/src/site/antora/modules/ROOT/pages/components.adoc b/src/site/antora/modules/ROOT/pages/components.adoc
index b354b6b91f..830ecc40b5 100644
--- a/src/site/antora/modules/ROOT/pages/components.adoc
+++ b/src/site/antora/modules/ROOT/pages/components.adoc
@@ -224,6 +224,23 @@ include::partial$components/log4j-jdbc.adoc[]
The `log4j-jdbc-dbcp2` artifact contains a data source for the
xref:manual/appenders/database.adoc#JdbcAppender[JDBC Appender]
that uses
+https://docs.oracle.com/javase/tutorial/jndi/overview/index.html[JNDI].
+
+See xref:manual/appenders/database.adoc#DataSourceConnectionSource[`DataSource` connection source] for more details.
+
+include::partial$components/log4j-jdbc-jndi.adoc[]
+
+[#log4j-jdbc-jndi]
+== `log4j-jdbc-jndi`
+
+|===
+| JPMS module
+| `org.apache.logging.log4j.jdbc.jndi`
+|===
+
+The `log4j-jdbc-jndi` artifact contains a data source for the
+xref:manual/appenders/database.adoc#JdbcAppender[JDBC Appender]
+that uses
https://commons.apache.org/proper/commons-dbcp/[Apache Commons DBCP].
See xref:manual/appenders/database.adoc#PoolingDriverConnectionSource[`PoolingDriver` connection source] for more details.
diff --git a/src/site/antora/modules/ROOT/pages/manual/appenders/database.adoc b/src/site/antora/modules/ROOT/pages/manual/appenders/database.adoc
index 43b692bdc1..079891da04 100644
--- a/src/site/antora/modules/ROOT/pages/manual/appenders/database.adoc
+++ b/src/site/antora/modules/ROOT/pages/manual/appenders/database.adoc
@@ -311,7 +311,7 @@ See <<JdbcAppender-MapMessage>> for more details.
|===
-xref:plugin-reference.adoc#org-apache-logging-log4j_log4j-core_org-apache-logging-log4j-core-appender-db-jdbc-JdbcAppender[{plugin-reference-marker} Plugin reference for `JDBC`]
+xref:plugin-reference.adoc#org-apache-logging-log4j_log4j-jdbc_org-apache-logging-log4j-jdbc-appender-JdbcAppender[{plugin-reference-marker} Plugin reference for `JDBC`]
Additional runtime dependencies are required to use the JDBC Appender:
@@ -325,7 +325,7 @@ link:../../javadoc/log4j-core/org/apache/logging/log4j/core/appender/db/jdbc/Con
that the appender will use to get
https://docs.oracle.com/javase/8/docs/api/java/sql/Connection.html[`Connection`] objects.
-xref:plugin-reference.adoc#org-apache-logging-log4j_log4j-core_org-apache-logging-log4j-core-appender-db-jdbc-ConnectionSource[{plugin-reference-marker} Plugin reference for `ConnectionSource`]
+xref:plugin-reference.adoc#org-apache-logging-log4j_log4j-jdbc_org-apache-logging-log4j-jdbc-appender-ConnectionSource[{plugin-reference-marker} Plugin reference for `ConnectionSource`]
The following connection sources are available out-of-the-box:
@@ -362,9 +362,9 @@ Only the `java:` JNDI protocol is supported.
Additional runtime dependencies are required to use `DataSource`:
-include::partial$components/log4j-jndi.adoc[]
+include::partial$components/log4j-jdbc-jndi.adoc[]
-xref:plugin-reference.adoc#org-apache-logging-log4j_log4j-core_org-apache-logging-log4j-core-appender-db-jdbc-DataSourceConnectionSource[{plugin-reference-marker} Plugin reference for `DataSource`]
+xref:plugin-reference.adoc#org-apache-logging-log4j_log4j-jdbc-jndi_org-apache-logging-log4j-jdbc-jndi-DataSourceConnectionSource[{plugin-reference-marker} Plugin reference for `DataSource`]
[#FactoryMethodConnectionSource]
==== `ConnectionFactory`
@@ -402,7 +402,7 @@ The name of the factory method.
**Required**
|===
-xref:plugin-reference.adoc#org-apache-logging-log4j_log4j-core_org-apache-logging-log4j-core-appender-db-jdbc-FactoryMethodConnectionSource[{plugin-reference-marker} Plugin reference for `ConnectionFactory`]
+xref:plugin-reference.adoc#org-apache-logging-log4j_log4j-jdbc_org-apache-logging-log4j-jdbc-appender-FactoryMethodConnectionSource[{plugin-reference-marker} Plugin reference for `ConnectionFactory`]
[#DriverManagerConnectionSource]
==== `DriverManager`
@@ -472,7 +472,7 @@ A list of key/value pairs to pass to `DriverManager`.
If supplied, the <<DriverManagerConnectionSource-attr-userName,`userName`>> and <<DriverManagerConnectionSource-attr-password,`password`>> attributes will be ignored.
|===
-xref:plugin-reference.adoc#org-apache-logging-log4j_log4j-core_org-apache-logging-log4j-core-appender-db-jdbc-DriverManagerConnectionSource[{plugin-reference-marker} Plugin reference for `DriverManager`]
+xref:plugin-reference.adoc#org-apache-logging-log4j_log4j-jdbc_org-apache-logging-log4j-jdbc-appender-DriverManagerConnectionSource[{plugin-reference-marker} Plugin reference for `DriverManager`]
[#PoolingDriverConnectionSource]
==== `PoolingDriver`
@@ -538,7 +538,7 @@ A list of key/value pairs to pass to `DriverManager`.
If supplied, the <<DriverManagerConnectionSource-attr-userName,`userName`>> and <<DriverManagerConnectionSource-attr-password,`password`>> attributes will be ignored.
-| [[PoolingDriverConnectionSource-element-PoolingConnectionFactoryConfig]]xref:plugin-reference.adoc#org-apache-logging-log4j_log4j-jdbc-dbcp2_org-apache-logging-log4j-core-appender-db-jdbc-PoolableConnectionFactoryConfig[`PoolableConnectionFactory`]
+| [[PoolingDriverConnectionSource-element-PoolingConnectionFactoryConfig]]xref:plugin-reference.adoc#org-apache-logging-log4j_log4j-jdbc-dbcp2_org-apache-logging-log4j-dbcp2-appender-PoolableConnectionFactoryConfig[`PoolableConnectionFactory`]
| zero or one
|
Allows finely tuning the configuration of the DBCP 2 connection pool.
@@ -546,14 +546,14 @@ The available parameters are the same as those provided by DBCP 2.
See
https://commons.apache.org/proper/commons-dbcp/configuration.html[DBCP 2 configuration] for more details.
-xref:plugin-reference.adoc#org-apache-logging-log4j_log4j-jdbc-dbcp2_org-apache-logging-log4j-core-appender-db-jdbc-PoolableConnectionFactoryConfig[{plugin-reference-marker} Plugin reference for `PoolableConnectionFactory`]
+xref:plugin-reference.adoc#org-apache-logging-log4j_log4j-jdbc-dbcp2_org-apache-logging-log4j-dbcp2-appender-PoolableConnectionFactoryConfig[{plugin-reference-marker} Plugin reference for `PoolableConnectionFactory`]
|===
Additional runtime dependencies are required for using `PoolingDriver`:
include::partial$components/log4j-jdbc-dbcp2.adoc[]
-xref:plugin-reference.adoc#org-apache-logging-log4j_log4j-jdbc-dbcp2_org-apache-logging-log4j-core-appender-db-jdbc-PoolingDriverConnectionSource[{plugin-reference-marker} Plugin reference for `PoolingDriver`]
+xref:plugin-reference.adoc#org-apache-logging-log4j_log4j-jdbc-dbcp2_org-apache-logging-log4j-dbcp2-appender-PoolingDriverConnectionSource[{plugin-reference-marker} Plugin reference for `PoolingDriver`]
[#JdbcAppender-MapMessage]
=== Map Message handling
diff --git a/src/site/antora/modules/ROOT/pages/plugin-reference.adoc b/src/site/antora/modules/ROOT/pages/plugin-reference.adoc
index ebcc9b60ba..a002ed8c15 100644
--- a/src/site/antora/modules/ROOT/pages/plugin-reference.adoc
+++ b/src/site/antora/modules/ROOT/pages/plugin-reference.adoc
@@ -131,15 +131,15 @@ The purpose of the sections below is to remove IDE errors while editing configur
== `AbstractDriverManagerConnectionSource`
[#org-apache-logging-log4j_log4j-core_org-apache-logging-log4j-core-appender-db-jdbc-ColumnConfig]
== Column
-[#org-apache-logging-log4j_log4j-core_org-apache-logging-log4j-core-appender-db-jdbc-ConnectionSource]
+[#org-apache-logging-log4j_log4j-jdbc_org-apache-logging-log4j-jdbc-appender-ConnectionSource]
== `ConnectionSource`
-[#org-apache-logging-log4j_log4j-core_org-apache-logging-log4j-core-appender-db-jdbc-DataSourceConnectionSource]
+[#org-apache-logging-log4j_log4j-jdbc-jndi_org-apache-logging-log4j-jdbc-jndi-DataSourceConnectionSource]
== DataSource
-[#org-apache-logging-log4j_log4j-core_org-apache-logging-log4j-core-appender-db-jdbc-DriverManagerConnectionSource]
+[#org-apache-logging-log4j_log4j-jdbc_org-apache-logging-log4j-jdbc-appender-DriverManagerConnectionSource]
== DriverManager
-[#org-apache-logging-log4j_log4j-core_org-apache-logging-log4j-core-appender-db-jdbc-FactoryMethodConnectionSource]
+[#org-apache-logging-log4j_log4j-jdbc_org-apache-logging-log4j-jdbc-appender-FactoryMethodConnectionSource]
== ConnectionFactory
-[#org-apache-logging-log4j_log4j-core_org-apache-logging-log4j-core-appender-db-jdbc-JdbcAppender]
+[#org-apache-logging-log4j_log4j-jdbc_org-apache-logging-log4j-jdbc-appender-JdbcAppender]
== JDBC
[#org-apache-logging-log4j_log4j-core_org-apache-logging-log4j-core-appender-FailoverAppender]
== Failover
@@ -711,9 +711,9 @@ The purpose of the sections below is to remove IDE errors while editing configur
== Servlet
[#org-apache-logging-log4j_log4j-jakarta-web_org-apache-logging-log4j-web-WebLookup]
== web
-[#org-apache-logging-log4j_log4j-jdbc-dbcp2_org-apache-logging-log4j-core-appender-db-jdbc-PoolableConnectionFactoryConfig]
+[#org-apache-logging-log4j_log4j-jdbc-dbcp2_org-apache-logging-log4j-dbcp2-appender-PoolableConnectionFactoryConfig]
== PoolableConnectionFactory
-[#org-apache-logging-log4j_log4j-jdbc-dbcp2_org-apache-logging-log4j-core-appender-db-jdbc-PoolingDriverConnectionSource]
+[#org-apache-logging-log4j_log4j-jdbc-dbcp2_org-apache-logging-log4j-dbcp2-appender-PoolingDriverConnectionSource]
== PoolingDriver
[#org-apache-logging-log4j_log4j-jpa_org-apache-logging-log4j-core-appender-db-jpa-JpaAppender]
== JPA
diff --git a/src/site/antora/modules/ROOT/partials/components/log4j-jdbc-jndi.adoc b/src/site/antora/modules/ROOT/partials/components/log4j-jdbc-jndi.adoc
new file mode 100644
index 0000000000..0b06bd7353
--- /dev/null
+++ b/src/site/antora/modules/ROOT/partials/components/log4j-jdbc-jndi.adoc
@@ -0,0 +1,41 @@
+////
+ 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.
+////
+
+[tabs]
+====
+Maven::
++
+We assume you use xref:components.adoc#log4j-bom[`log4j-bom`] for dependency management.
++
+[source,xml]
+----
+<dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-jdbc-jndi</artifactId>
+ <scope>runtime</scope>
+</dependency>
+----
+
+Gradle::
++
+We assume you use xref:components.adoc#log4j-bom[`log4j-bom`] for dependency management.
++
+[source,groovy]
+----
+runtimeOnly 'org.apache.logging.log4j:log4j-jdbc-jndi'
+----
+====
\ No newline at end of file