diff --git a/log4j-jdbc-dbcp2/pom.xml b/log4j-jdbc-dbcp2/pom.xml index 70882c37f0f..f0854bf4295 100644 --- a/log4j-jdbc-dbcp2/pom.xml +++ b/log4j-jdbc-dbcp2/pom.xml @@ -27,7 +27,7 @@ log4j-jdbc-dbcp2 - Apache Log4j JDBC DBCP 2 + Apache Log4j JDBC: DBCP 2 datasource Connection source for the JDBC Appender using Apache Commons DBCP2. diff --git a/log4j-jdbc-jndi/.log4j-plugin-processing-activator b/log4j-jdbc-jndi/.log4j-plugin-processing-activator new file mode 100644 index 00000000000..ba133f36961 --- /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-jndi/pom.xml b/log4j-jdbc-jndi/pom.xml new file mode 100644 index 00000000000..6fc8e394da6 --- /dev/null +++ b/log4j-jdbc-jndi/pom.xml @@ -0,0 +1,109 @@ + + + + 4.0.0 + + org.apache.logging.log4j + log4j + ${revision} + ../log4j-parent + + + log4j-jdbc-jndi + Apache Log4j JDBC: JNDI datasource + Connection source for the JDBC Appender using JNDI. + + + + + org.apache.logging.log4j + log4j-api + + + + org.apache.logging.log4j + log4j-core + + + + org.apache.logging.log4j + log4j-jdbc + + + + org.apache.logging.log4j + log4j-jndi + + + + org.apache.logging.log4j + log4j-plugins + + + + org.apache.logging.log4j + log4j-core-test + test + + + + org.apache.logging.log4j + log4j-jndi-test + test + + + + org.apache.commons + commons-lang3 + test + + + + com.h2database + h2 + test + + + + org.hsqldb + hsqldb + test + + + + junit + junit + test + + + + org.junit.vintage + junit-vintage-engine + test + + + + + org.mockito + mockito-core + test + + + + + 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 333a20ca40f..422aba34a1f 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.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 String toString() { */ @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 static DataSourceConnectionSource createConnectionSource(@PluginAttribute 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 33e0f4dc5b9..92bd0780aad 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.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 static void beforeClass() { 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() { - @Override - public Connection answer(final InvocationOnMock invocation) throws Throwable { - return jdbcRule.getConnectionSource().getConnection(); - } - }); + given(dataSource.getConnection()).willAnswer((Answer) + 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 92% 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 eb949024aa4..9dc5d8c4977 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,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; @@ -22,13 +22,12 @@ 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.mockito.BDDMockito.mock; 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 +44,7 @@ public static Object[][] data() { 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 +53,8 @@ public static Object[][] data() { 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% 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/JdbcAppenderH2DataSourceTest.java index 8046fa51d0d..1a94e949105 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 4bc68c5f732..c5a6ff07561 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 125a17db70e..f57b1e1c8ac 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.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 @@ protected JdbcAppenderMapMessageDataSourceTest(final JdbcRule jdbcRule) { // @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-jndi/src/test/java/org/apache/logging/log4j/jdbc/jndi/JdbcH2TestHelper.java b/log4j-jdbc-jndi/src/test/java/org/apache/logging/log4j/jdbc/jndi/JdbcH2TestHelper.java new file mode 100644 index 00000000000..7e2a7220c84 --- /dev/null +++ b/log4j-jdbc-jndi/src/test/java/org/apache/logging/log4j/jdbc/jndi/JdbcH2TestHelper.java @@ -0,0 +1,37 @@ +/* + * 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.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 00000000000..8f833d50272 --- /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 c589410db49..1b6cd3f1829 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. --> - - + @@ -33,7 +36,7 @@ - + diff --git a/log4j-jdbc/src/test/resources/log4j-fatalOnly.xml b/log4j-jdbc-jndi/src/test/resources/DataSourceConnectionSourceTest.xml similarity index 73% rename from log4j-jdbc/src/test/resources/log4j-fatalOnly.xml rename to log4j-jdbc-jndi/src/test/resources/DataSourceConnectionSourceTest.xml index b3e386f33e4..95ac8003f83 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. --> - - - - - - - - + + - - - - + - 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 0d2a9e24879..b3926b2e5e4 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. --> - - + @@ -31,7 +34,7 @@ - + diff --git a/log4j-jdbc/pom.xml b/log4j-jdbc/pom.xml index ebfd6988396..494b2d6983b 100644 --- a/log4j-jdbc/pom.xml +++ b/log4j-jdbc/pom.xml @@ -30,89 +30,66 @@ Apache Log4j JDBC Apache Log4j Java Database Connectivity (JDBC). - - ${basedir}/.. - - - - - org.apache.logging.log4j.jndi;resolution:=optional - - - + org.apache.logging.log4j - log4j-core + log4j-api + org.apache.logging.log4j - log4j-jndi - true + log4j-core + org.apache.logging.log4j - log4j-api-test - test + log4j-plugins + org.apache.logging.log4j log4j-core-test test - - org.apache.logging.log4j - log4j-jndi-test - test - - - commons-io - commons-io - test - + org.apache.commons commons-lang3 test - - commons-logging - commons-logging - test - + com.h2database h2 test - - org.hamcrest - hamcrest - test - + org.hsqldb hsqldb test + - org.junit.jupiter - junit-jupiter-engine + junit + junit test + org.junit.vintage junit-vintage-engine test + org.mockito mockito-core test + 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 9eca48f064f..00000000000 --- 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 2b1e58c3e41..69b5bf88faa 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 b67b71aa8af..b2a9189dc83 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 @@ public class FactoryMethodConnectionSourceTest { private static final ThreadLocal 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 132eed8b911..6273ab9f7de 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 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 781bbf163b2..9526272a99b 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 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 cace44dd1a5..6782639c0ac 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 @@ 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 c0e9cada5bc..f2d23cb5c2a 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.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 81da06c4e91..b2e3788e3fd 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 static void afterClass() { } @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/FactoryMethodConnectionSourceTest.xml b/log4j-jdbc/src/test/resources/FactoryMethodConnectionSourceTest.xml new file mode 100644 index 00000000000..95ac8003f83 --- /dev/null +++ b/log4j-jdbc/src/test/resources/FactoryMethodConnectionSourceTest.xml @@ -0,0 +1,27 @@ + + + + + + + + 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 1a2debfb19d..4f8a994d871 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. --> - - + 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 47116a69e0a..2901bd18a2c 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. --> - - + 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 faa16cfbea9..d1fa5e6a896 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. --> - - + - - - - - - + method="getConnection"/> + + + + + + - + 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 1a8f53a9a05..3271556cc28 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. --> - - + 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 25f41f48ed8..4546884f7e4 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. --> - - + diff --git a/pom.xml b/pom.xml index 01945c4a60c..a4b354f9b2c 100644 --- a/pom.xml +++ b/pom.xml @@ -244,6 +244,7 @@ log4j-jctools log4j-jdbc log4j-jdbc-dbcp2 + log4j-jdbc-jndi log4j-jndi log4j-jndi-test log4j-jpl @@ -454,6 +455,12 @@ ${project.version} + + org.apache.logging.log4j + log4j-jdbc-jndi + ${project.version} + + org.apache.logging.log4j log4j-jndi 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 00000000000..b40be210ffc --- /dev/null +++ b/src/changelog/.3.x.x/1914_split_JDBC_JNDI_connection_source.xml @@ -0,0 +1,8 @@ + + + + Split off JNDI support of `log4j-jdbc` to a new `log4j-jdbc-jndi` module + diff --git a/src/site/antora/modules/ROOT/pages/components.adoc b/src/site/antora/modules/ROOT/pages/components.adoc index b354b6b91f6..830ecc40b5a 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 43b692bdc1a..079891da044 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 <> 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 <> and <> 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 <> and <> 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 ebcc9b60ba1..a002ed8c15d 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 00000000000..0b06bd7353d --- /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] +---- + + org.apache.logging.log4j + log4j-jdbc-jndi + runtime + +---- + +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