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/04/03 09:38:11 UTC
(logging-log4j2) 03/03: Add property mapping for `log4j-1.2-api`
This is an automated email from the ASF dual-hosted git repository.
pkarwasz pushed a commit to branch feature/support-legacy-props
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
commit 5fa690fbe8a60b815e939145f1b0daae039aaa46
Author: Piotr P. Karwasz <pi...@karwasz.org>
AuthorDate: Wed Apr 3 10:36:34 2024 +0200
Add property mapping for `log4j-1.2-api`
---
.../java/org/apache/log4j/config/Log4j1Configuration.java | 1 -
.../log4j/config/PropertiesConfigurationFactory.java | 13 ++++++++-----
.../org/apache/log4j/xml/XmlConfigurationFactory.java | 14 ++++++++------
.../main/resources/META-INF/log4j/propertyMapping.json | 13 +++++++++++++
.../test/java/org/apache/log4j/config/AutoConfigTest.java | 4 ++--
.../org/apache/log4j/config/MapRewriteAppenderTest.java | 4 ++--
.../log4j/config/PropertiesConfigurationFactoryTest.java | 4 ++--
.../log4j/config/PropertiesReconfigurationTest.java | 3 ++-
.../log4j/config/PropertiesRollingWithPropertiesTest.java | 4 ++--
.../java/org/apache/log4j/config/RewriteAppenderTest.java | 4 ++--
.../apache/log4j/config/XmlConfigurationFactoryTest.java | 4 ++--
.../org/apache/log4j/config/XmlReconfigurationTest.java | 3 ++-
.../apache/log4j/config/XmlRollingWithPropertiesTest.java | 4 ++--
.../org/apache/logging/log4j/core/test/TestConstants.java | 4 +++-
.../logging/log4j/core/config/ConfigurationFactory.java | 15 ---------------
.../log4j/core/config/DefaultConfigurationFactory.java | 7 ++++---
.../apache/logging/log4j/core/impl/CoreProperties.java | 14 +++++++++++++-
17 files changed, 67 insertions(+), 48 deletions(-)
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1Configuration.java b/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1Configuration.java
index f8a2cbc99b..a581f35a77 100644
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1Configuration.java
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1Configuration.java
@@ -33,7 +33,6 @@ import org.apache.logging.log4j.plugins.di.DI;
*/
public class Log4j1Configuration extends AbstractConfiguration implements Reconfigurable {
- public static final String MONITOR_INTERVAL = "log4j1.monitorInterval";
public static final String APPENDER_REF_TAG = "appender-ref";
public static final String THRESHOLD_PARAM = "Threshold";
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/config/PropertiesConfigurationFactory.java b/log4j-1.2-api/src/main/java/org/apache/log4j/config/PropertiesConfigurationFactory.java
index 238fad514a..fe23383d4d 100644
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/config/PropertiesConfigurationFactory.java
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/config/PropertiesConfigurationFactory.java
@@ -21,6 +21,7 @@ import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.config.ConfigurationSource;
import org.apache.logging.log4j.core.config.Order;
+import org.apache.logging.log4j.core.impl.CoreProperties.Version1Properties;
import org.apache.logging.log4j.kit.env.PropertyEnvironment;
import org.apache.logging.log4j.plugins.Namespace;
import org.apache.logging.log4j.plugins.Plugin;
@@ -48,12 +49,11 @@ public class PropertiesConfigurationFactory extends ConfigurationFactory {
private final boolean enabled;
public PropertiesConfigurationFactory() {
- this(PropertyEnvironment.getGlobal());
+ this(PropertyEnvironment.getGlobal().getProperty(Version1Properties.class));
}
- private PropertiesConfigurationFactory(final PropertyEnvironment props) {
- this.enabled = props.getBooleanProperty(LOG4J1_EXPERIMENTAL)
- || props.getStringProperty(LOG4J1_CONFIGURATION_FILE_PROPERTY) != null;
+ private PropertiesConfigurationFactory(final Version1Properties properties) {
+ this.enabled = properties.compatibility() || properties.configuration() != null;
}
@Override
@@ -63,7 +63,10 @@ public class PropertiesConfigurationFactory extends ConfigurationFactory {
@Override
public Configuration getConfiguration(final LoggerContext loggerContext, final ConfigurationSource source) {
- final int interval = loggerContext.getEnvironment().getIntegerProperty(Log4j1Configuration.MONITOR_INTERVAL, 0);
+ final int interval = loggerContext
+ .getEnvironment()
+ .getProperty(Version1Properties.class)
+ .monitorInterval();
return new PropertiesConfiguration(loggerContext, source, interval);
}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/xml/XmlConfigurationFactory.java b/log4j-1.2-api/src/main/java/org/apache/log4j/xml/XmlConfigurationFactory.java
index 9ec7209046..4df966c86c 100644
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/xml/XmlConfigurationFactory.java
+++ b/log4j-1.2-api/src/main/java/org/apache/log4j/xml/XmlConfigurationFactory.java
@@ -16,12 +16,12 @@
*/
package org.apache.log4j.xml;
-import org.apache.log4j.config.Log4j1Configuration;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.config.ConfigurationSource;
import org.apache.logging.log4j.core.config.Order;
+import org.apache.logging.log4j.core.impl.CoreProperties.Version1Properties;
import org.apache.logging.log4j.kit.env.PropertyEnvironment;
import org.apache.logging.log4j.plugins.Namespace;
import org.apache.logging.log4j.plugins.Plugin;
@@ -49,12 +49,11 @@ public class XmlConfigurationFactory extends ConfigurationFactory {
private final boolean enabled;
public XmlConfigurationFactory() {
- this(PropertyEnvironment.getGlobal());
+ this(PropertyEnvironment.getGlobal().getProperty(Version1Properties.class));
}
- private XmlConfigurationFactory(final PropertyEnvironment props) {
- this.enabled = props.getBooleanProperty(LOG4J1_CONFIGURATION_FILE_PROPERTY)
- || props.getStringProperty(LOG4J1_CONFIGURATION_FILE_PROPERTY) != null;
+ private XmlConfigurationFactory(final Version1Properties properties) {
+ this.enabled = properties.compatibility() || properties.configuration() != null;
}
@Override
@@ -64,7 +63,10 @@ public class XmlConfigurationFactory extends ConfigurationFactory {
@Override
public Configuration getConfiguration(final LoggerContext loggerContext, final ConfigurationSource source) {
- final int interval = loggerContext.getEnvironment().getIntegerProperty(Log4j1Configuration.MONITOR_INTERVAL, 0);
+ final int interval = loggerContext
+ .getEnvironment()
+ .getProperty(Version1Properties.class)
+ .monitorInterval();
return new XmlConfiguration(loggerContext, source, interval);
}
diff --git a/log4j-1.2-api/src/main/resources/META-INF/log4j/propertyMapping.json b/log4j-1.2-api/src/main/resources/META-INF/log4j/propertyMapping.json
new file mode 100644
index 0000000000..eda0fc2d63
--- /dev/null
+++ b/log4j-1.2-api/src/main/resources/META-INF/log4j/propertyMapping.json
@@ -0,0 +1,13 @@
+{
+ "v1": {
+ "compatibility": [
+ "log4j1.compatibility"
+ ],
+ "configuration": [
+ "log4j.configuration"
+ ],
+ "monitorInterval": [
+ "log4j1.monitorInterval"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/AutoConfigTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/AutoConfigTest.java
index 6ee8618b1e..2820722d88 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/AutoConfigTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/AutoConfigTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.log4j.config;
-import static org.apache.logging.log4j.core.config.ConfigurationFactory.LOG4J1_CONFIGURATION_FILE_PROPERTY;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -30,6 +29,7 @@ import org.apache.log4j.spi.LoggingEvent;
import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.test.TestConstants;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.SetSystemProperty;
@@ -39,7 +39,7 @@ import org.junitpioneer.jupiter.SetSystemProperty;
public class AutoConfigTest {
@Test
- @SetSystemProperty(key = LOG4J1_CONFIGURATION_FILE_PROPERTY, value = "log4j.xml")
+ @SetSystemProperty(key = TestConstants.VERSION1_CONFIGURATION, value = "log4j.xml")
public void testListAppender() {
final Logger logger = LogManager.getLogger("test");
final LoggerContext context = LoggerContext.getContext(false);
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/MapRewriteAppenderTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/MapRewriteAppenderTest.java
index 893266bbb9..826413e354 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/MapRewriteAppenderTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/MapRewriteAppenderTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.log4j.config;
-import static org.apache.logging.log4j.core.config.ConfigurationFactory.LOG4J1_CONFIGURATION_FILE_PROPERTY;
import static org.assertj.core.api.Assertions.as;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.InstanceOfAssertFactories.MAP;
@@ -34,6 +33,7 @@ import org.apache.log4j.spi.LoggingEvent;
import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.test.TestConstants;
import org.apache.logging.log4j.test.junit.UsingThreadContextMap;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.SetSystemProperty;
@@ -45,7 +45,7 @@ import org.junitpioneer.jupiter.SetSystemProperty;
public class MapRewriteAppenderTest {
@Test
- @SetSystemProperty(key = LOG4J1_CONFIGURATION_FILE_PROPERTY, value = "log4j1-mapRewrite.xml")
+ @SetSystemProperty(key = TestConstants.VERSION1_CONFIGURATION, value = "log4j1-mapRewrite.xml")
public void testRewrite() {
final Logger logger = LogManager.getLogger("test");
final Map<String, String> map = new HashMap<>();
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesConfigurationFactoryTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesConfigurationFactoryTest.java
index 720bdacc82..7c2f89a974 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesConfigurationFactoryTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesConfigurationFactoryTest.java
@@ -16,12 +16,12 @@
*/
package org.apache.log4j.config;
-import static org.apache.logging.log4j.core.config.ConfigurationFactory.LOG4J1_CONFIGURATION_FILE_PROPERTY;
import static org.junit.Assert.assertTrue;
import java.io.File;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
+import org.apache.logging.log4j.core.test.TestConstants;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -32,7 +32,7 @@ public class PropertiesConfigurationFactoryTest {
@BeforeClass
public static void beforeClass() {
- System.setProperty(LOG4J1_CONFIGURATION_FILE_PROPERTY, "target/test-classes/log4j1-file-1.properties");
+ System.setProperty(TestConstants.VERSION1_CONFIGURATION, "target/test-classes/log4j1-file-1.properties");
}
@Test
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesReconfigurationTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesReconfigurationTest.java
index 99158fa8c1..0662df2e4a 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesReconfigurationTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesReconfigurationTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.log4j.config;
+import static org.apache.logging.log4j.core.test.TestConstants.VERSION1_MONITOR_INTERVAL;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNotSame;
@@ -200,7 +201,7 @@ public class PropertiesReconfigurationTest {
@Test
@Tag("sleepy")
public void testTestListener() throws Exception {
- System.setProperty(Log4j1Configuration.MONITOR_INTERVAL, "1");
+ System.setProperty(VERSION1_MONITOR_INTERVAL, "1");
final File file = new File(CONFIG_FILE_APPENDER_1);
assertTrue(file.exists(), "No Config file");
final long configMillis = file.lastModified();
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesRollingWithPropertiesTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesRollingWithPropertiesTest.java
index 6a53f20e0d..66b3ac96bd 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesRollingWithPropertiesTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesRollingWithPropertiesTest.java
@@ -16,12 +16,12 @@
*/
package org.apache.log4j.config;
-import static org.apache.logging.log4j.core.config.ConfigurationFactory.LOG4J1_CONFIGURATION_FILE_PROPERTY;
import static org.assertj.core.api.Assertions.assertThat;
import java.nio.file.Path;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.test.TestConstants;
import org.apache.logging.log4j.test.junit.TempLoggingDir;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.RestoreSystemProperties;
@@ -38,7 +38,7 @@ class PropertiesRollingWithPropertiesTest {
@RestoreSystemProperties
void testProperties() {
System.setProperty("test.directory", loggingPath.toString());
- System.setProperty(LOG4J1_CONFIGURATION_FILE_PROPERTY, "log4j1-rolling-properties.properties");
+ System.setProperty(TestConstants.VERSION1_CONFIGURATION, "log4j1-rolling-properties.properties");
try (final LoggerContext context = LoggerContext.getContext(false)) {
final Logger logger = context.getLogger("test");
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/RewriteAppenderTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/RewriteAppenderTest.java
index 78c3f44dd1..e264263c87 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/RewriteAppenderTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/RewriteAppenderTest.java
@@ -16,7 +16,6 @@
*/
package org.apache.log4j.config;
-import static org.apache.logging.log4j.core.config.ConfigurationFactory.LOG4J1_CONFIGURATION_FILE_PROPERTY;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -32,6 +31,7 @@ import org.apache.logging.log4j.ThreadContext;
import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.test.TestConstants;
import org.apache.logging.log4j.test.junit.UsingThreadContextMap;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.SetSystemProperty;
@@ -43,7 +43,7 @@ import org.junitpioneer.jupiter.SetSystemProperty;
public class RewriteAppenderTest {
@Test
- @SetSystemProperty(key = LOG4J1_CONFIGURATION_FILE_PROPERTY, value = "log4j1-rewrite.xml")
+ @SetSystemProperty(key = TestConstants.VERSION1_CONFIGURATION, value = "log4j1-rewrite.xml")
public void testRewrite() {
final Logger logger = LogManager.getLogger("test");
final LoggerContext context = LoggerContext.getContext(false);
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlConfigurationFactoryTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlConfigurationFactoryTest.java
index 7f2384dfd7..c6f058a80f 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlConfigurationFactoryTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlConfigurationFactoryTest.java
@@ -16,12 +16,12 @@
*/
package org.apache.log4j.config;
-import static org.apache.logging.log4j.core.config.ConfigurationFactory.LOG4J1_CONFIGURATION_FILE_PROPERTY;
import static org.junit.Assert.assertTrue;
import java.io.File;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
+import org.apache.logging.log4j.core.test.TestConstants;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -32,7 +32,7 @@ public class XmlConfigurationFactoryTest {
@BeforeClass
public static void beforeClass() {
- System.setProperty(LOG4J1_CONFIGURATION_FILE_PROPERTY, "target/test-classes/log4j1-file.xml");
+ System.setProperty(TestConstants.VERSION1_CONFIGURATION, "target/test-classes/log4j1-file.xml");
}
@Test
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlReconfigurationTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlReconfigurationTest.java
index f5452aba03..2ecc85e56b 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlReconfigurationTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlReconfigurationTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.log4j.config;
+import static org.apache.logging.log4j.core.test.TestConstants.VERSION1_MONITOR_INTERVAL;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.fail;
@@ -49,7 +50,7 @@ public class XmlReconfigurationTest {
@Test
public void testReconfiguration() throws Exception {
- System.setProperty(Log4j1Configuration.MONITOR_INTERVAL, "1");
+ System.setProperty(VERSION1_MONITOR_INTERVAL, "1");
final File file = new File(CONFIG);
assertNotNull(file, "No Config file");
final long configMillis = file.lastModified();
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlRollingWithPropertiesTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlRollingWithPropertiesTest.java
index 6954c452a6..7841ee53c6 100644
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlRollingWithPropertiesTest.java
+++ b/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlRollingWithPropertiesTest.java
@@ -16,12 +16,12 @@
*/
package org.apache.log4j.config;
-import static org.apache.logging.log4j.core.config.ConfigurationFactory.LOG4J1_CONFIGURATION_FILE_PROPERTY;
import static org.assertj.core.api.Assertions.assertThat;
import java.nio.file.Path;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.test.TestConstants;
import org.apache.logging.log4j.test.junit.TempLoggingDir;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.RestoreSystemProperties;
@@ -38,7 +38,7 @@ class XmlRollingWithPropertiesTest {
@RestoreSystemProperties
void testProperties() {
System.setProperty("test.directory", loggingPath.toString());
- System.setProperty(LOG4J1_CONFIGURATION_FILE_PROPERTY, "log4j1-rolling-properties.xml");
+ System.setProperty(TestConstants.VERSION1_CONFIGURATION, "log4j1-rolling-properties.xml");
try (final LoggerContext context = LoggerContext.getContext(false)) {
final Logger logger = context.getLogger("test");
diff --git a/log4j-core-test/src/main/java/org/apache/logging/log4j/core/test/TestConstants.java b/log4j-core-test/src/main/java/org/apache/logging/log4j/core/test/TestConstants.java
index 9cabb7ec79..21a60e631d 100644
--- a/log4j-core-test/src/main/java/org/apache/logging/log4j/core/test/TestConstants.java
+++ b/log4j-core-test/src/main/java/org/apache/logging/log4j/core/test/TestConstants.java
@@ -103,7 +103,9 @@ public final class TestConstants {
public static final String VERSION1_CONFIGURATION = "log4j.configuration";
- public static final String VERSION1_COMPATIBILITY = "log4j1.compatibility";
+ public static final String VERSION1_COMPATIBILITY = "log4j.v1.compatibility";
+
+ public static final String VERSION1_MONITOR_INTERVAL = "log4j.v1.monitorInterval";
private static final String THREAD_CONTEXT = "log4j.threadContext.";
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
index 5472c94f73..f9713667ff 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationFactory.java
@@ -22,7 +22,6 @@ import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilderFactory;
import org.apache.logging.log4j.core.impl.CoreProperties.AuthenticationProperties;
import org.apache.logging.log4j.core.util.AuthorizationProvider;
-import org.apache.logging.log4j.kit.env.Log4jProperty;
import org.apache.logging.log4j.kit.env.PropertyEnvironment;
import org.apache.logging.log4j.kit.env.internal.PropertiesUtilPropertyEnvironment;
import org.apache.logging.log4j.plugins.Namespace;
@@ -55,20 +54,6 @@ import org.apache.logging.log4j.util.PropertiesUtil;
*/
public abstract class ConfigurationFactory extends ConfigurationBuilderFactory implements URIConfigurationFactory {
- /**
- * If Log4j 1.2 Bridge is present on the classpath, this property will be interpreted as the location of a Log4j 1.x
- * configuration file.
- */
- @Log4jProperty
- public static final String LOG4J1_CONFIGURATION_FILE_PROPERTY = "log4j.configuration";
-
- /**
- * If Log4j 1.2 Bridge is present on the classpath, setting this property to {@code true} will enable the legacy
- * Log4j 1.x configuration process.
- */
- @Log4jProperty
- public static final String LOG4J1_EXPERIMENTAL = "log4j1.compatibility";
-
/**
* Plugin category used to inject a ConfigurationFactory {@link org.apache.logging.log4j.plugins.Plugin}
* class.
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/DefaultConfigurationFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/DefaultConfigurationFactory.java
index 089dc83a5d..e182b65639 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/DefaultConfigurationFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/DefaultConfigurationFactory.java
@@ -26,6 +26,7 @@ import java.util.Optional;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.composite.CompositeConfiguration;
+import org.apache.logging.log4j.core.impl.CoreProperties;
import org.apache.logging.log4j.core.impl.CoreProperties.ConfigurationProperties;
import org.apache.logging.log4j.core.lookup.ConfigurationStrSubstitutor;
import org.apache.logging.log4j.core.lookup.StrSubstitutor;
@@ -86,9 +87,9 @@ public class DefaultConfigurationFactory extends ConfigurationFactory {
}
return getConfiguration(null, loggerContext, configLocationStr, configurationFactories);
} else {
- // TODO: replace with CoreProperties.Version1Properties.class
- final String log4j1ConfigStr =
- substitutor.replace(environment.getStringProperty(LOG4J1_CONFIGURATION_FILE_PROPERTY));
+ final String log4j1ConfigStr = substitutor.replace(environment
+ .getProperty(CoreProperties.Version1Properties.class)
+ .configuration());
if (log4j1ConfigStr != null) {
return getConfiguration(LOG4J1_VERSION, loggerContext, log4j1ConfigStr, configurationFactories);
}
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/CoreProperties.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/CoreProperties.java
index 3e569ac881..27188eba77 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/CoreProperties.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/CoreProperties.java
@@ -232,6 +232,18 @@ public final class CoreProperties {
@Log4jProperty(name = "uuid")
public record UuidProperties(long sequence) {}
+ /**
+ * Configuration properties for the Log4j 1.x bridge.
+ * <p>
+ * This property class is in Log4j Core instead of Log4j 1.2 API, because it is used by the
+ * {@link org.apache.logging.log4j.core.config.DefaultConfigurationFactory} to detect if
+ * {@code "log4j.configuration"} was set.
+ * </p>
+ * @param compatibility If {@code true}, the automatic configuration process will scan for version 1.x
+ * configuration files.
+ * @param configuration The location of a 1.x configuration file.
+ * @param monitorInterval The interval in seconds to scan for updates in a 1.x configuration file.
+ */
@Log4jProperty(name = "v1")
- public record Version1Properties(String configuration, boolean compatibility) {}
+ public record Version1Properties(boolean compatibility, @Nullable String configuration, int monitorInterval) {}
}