This is an automated email from the ASF dual-hosted git repository.
mattsicker pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
The following commit(s) were added to refs/heads/master by this push:
new d3d76bd6b8 Migrate more code to use centralized property constants
d3d76bd6b8 is described below
commit d3d76bd6b83b52a7dd47d8f081cd82369bacc8e2
Author: Matt Sicker <[email protected]>
AuthorDate: Mon Nov 21 10:35:37 2022 -0600
Migrate more code to use centralized property constants
Signed-off-by: Matt Sicker <[email protected]>
---
.../logging/log4j/spi/LoggingSystemProperties.java | 21 +++++++++++++-----
.../log4j/core/async/perftest/PerfTestDriver.java | 25 +++++++++++++---------
.../core/async/perftest/ResponseTimeTest.java | 13 +++++------
.../log4j/core/config/TestConfiguratorError.java | 5 +++--
.../log4j/core/tools/GenerateCustomLoggerTest.java | 11 +++-------
.../core/tools/GenerateExtendedLoggerTest.java | 11 +++-------
.../core/config/DefaultConfigurationFactory.java | 6 ++++--
.../log4j/perf/jmh/AsyncLoggersBenchmark.java | 14 ++++++------
.../jmh/ConcurrentAsyncLoggerToFileBenchmark.java | 17 ++++++++-------
.../log4j/perf/jmh/ThreadContextBenchmark.java | 10 ++++-----
.../spring/boot/Log4j2SpringBootInitTest.java | 4 ++--
11 files changed, 74 insertions(+), 63 deletions(-)
diff --git
a/log4j-api/src/main/java/org/apache/logging/log4j/spi/LoggingSystemProperties.java
b/log4j-api/src/main/java/org/apache/logging/log4j/spi/LoggingSystemProperties.java
index 88541b010a..47fdd20741 100644
---
a/log4j-api/src/main/java/org/apache/logging/log4j/spi/LoggingSystemProperties.java
+++
b/log4j-api/src/main/java/org/apache/logging/log4j/spi/LoggingSystemProperties.java
@@ -43,17 +43,16 @@ public final class LoggingSystemProperties {
* <p>
* If property {@value} is either defined empty or its value equals to
{@code true} (ignoring case), all internal
* logging will be printed to the console. The presence of this system
property overrides any value set in the
- * configuration's {@code <Configuration status="<level>" ...>} status
attribute, as well as any value set for
- * system property {@code log4j2.simplelogStatusLoggerLevel}.
+ * configuration's {@code <Configuration status="<level>" ...>} status
attribute.
* </p>
*/
- public static final String SYSTEM_DEBUG = "log4j2.debug";
+ public static final String SYSTEM_DEBUG = "log4j2.*.System.debug";
/**
* Property to override webapp detection. Without this property, the
presence of the {@code Servlet} interface
* (from either {@code javax} or {@code jakarta}) is checked to see if
this is a webapp.
*/
- // Web.enableWebApp
+ // Web.enableWebApp : calculate | true | false
public static final String SYSTEM_IS_WEBAPP = "log4j2.isWebapp";
/**
@@ -61,7 +60,7 @@ public final class LoggingSystemProperties {
*
* @see <a
href="https://issues.apache.org/jira/browse/LOG4J2-1270">LOG4J2-1270</a>
*/
- // GC.enableThreadLocals
+ // GC.enableThreadLocals : calculate | true | false
public static final String SYSTEM_THREAD_LOCALS_ENABLED =
"log4j2.enableThreadlocals";
/**
@@ -69,6 +68,7 @@ public final class LoggingSystemProperties {
*
* @see LoaderUtil
*/
+ // TODO: see if this can be removed
public static final String LOADER_IGNORE_THREAD_CONTEXT_LOADER =
"log4j2.ignoreTCL";
/**
@@ -76,6 +76,7 @@ public final class LoggingSystemProperties {
*
* @see LoaderUtil
*/
+ // TODO: see if this can be removed
public static final String LOADER_FORCE_THREAD_CONTEXT_LOADER =
"log4j2.forceTCLOnly";
/**
@@ -118,6 +119,15 @@ public final class LoggingSystemProperties {
// GC.maxReusableMsgSize
public static final String GC_REUSABLE_MESSAGE_MAX_SIZE =
"log4j2.maxReusableMsgSize";
+ public static final String SIMPLE_SHOW_CONTEXT_MAP =
"SimpleLogger.showContextMap";
+ public static final String SIMPLE_SHOW_LOG_NAME =
"SimpleLogger.showLogName";
+ public static final String SIMPLE_SHOW_SHORT_LOG_NAME =
"SimpleLogger.showShortLogName";
+ public static final String SIMPLE_SHOW_DATE_TIME =
"SimpleLogger.showDateTime";
+ public static final String SIMPLE_DATE_TIME_FORMAT =
"SimpleLogger.dateTimeFormat";
+ public static final String SIMPLE_LOG_FILE = "SimpleLogger.logFile";
+ public static final String SIMPLE_LOG_LEVEL = "SimpleLogger.logLevel";
+ public static final String SIMPLE_LOGGER_LOG_LEVEL =
"SimpleLogger.%s.level";
+
/**
* Property that can be configured with the maximum number of status data
entries to keep queued. Once the limit is
* reached, older entries will be removed as new entries are added. The
default value is 200.
@@ -172,6 +182,7 @@ public final class LoggingSystemProperties {
* also implement {@link ReadOnlyThreadContextMap} if they should be
accessible to applications via
* {@link ThreadContext#getThreadContextMap()}.
*/
+ // TODO: replace with LoggingSystem overrides
public static final String THREAD_CONTEXT_MAP_CLASS =
"log4j2.threadContextMap";
/**
diff --git
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/perftest/PerfTestDriver.java
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/perftest/PerfTestDriver.java
index b395e74ab3..396dc1df8c 100644
---
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/perftest/PerfTestDriver.java
+++
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/perftest/PerfTestDriver.java
@@ -29,6 +29,7 @@ import java.util.Collections;
import java.util.List;
import org.apache.logging.log4j.core.async.AsyncLoggerContextSelector;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
/**
* Runs a sequence of performance tests.
@@ -86,17 +87,17 @@ public class PerfTestDriver {
// args.add("-XX:+PrintGCApplicationConcurrentTime");
// args.add("-XX:+PrintSafepointStatistics");
- args.add("-Dlog4j.configuration=" + log4jConfig); // log4j 1.2
- args.add("-Dlog4j.configurationFile=" + log4jConfig); // log4j 2
+ args.add("-D" + Log4jProperties.CONFIG_V1_FILE_NAME + '=' +
log4jConfig); // 1.2
+ args.add("-D" + Log4jProperties.CONFIG_LOCATION + '=' +
log4jConfig); // 2.x
args.add("-Dlogback.configurationFile=" + log4jConfig);// logback
final int ringBufferSize = getUserSpecifiedRingBufferSize();
if (ringBufferSize >= 128) {
- args.add("-DAsyncLoggerConfig.RingBufferSize=" +
ringBufferSize);
- args.add("-DAsyncLogger.RingBufferSize=" + ringBufferSize);
+ args.add("-D" + Log4jProperties.ASYNC_CONFIG_RING_BUFFER_SIZE
+ '=' + ringBufferSize);
+ args.add("-D" + Log4jProperties.ASYNC_LOGGER_RING_BUFFER_SIZE
+ '=' + ringBufferSize);
}
- args.add("-DAsyncLoggerConfig.WaitStrategy=" + wait);
- args.add("-DAsyncLogger.WaitStrategy=" + wait);
+ args.add("-D" + Log4jProperties.ASYNC_CONFIG_WAIT_STRATEGY + '=' +
wait);
+ args.add("-D" + Log4jProperties.ASYNC_LOGGER_WAIT_STRATEGY + '=' +
wait);
if (systemProperties != null) {
Collections.addAll(args, systemProperties);
}
@@ -220,11 +221,11 @@ public class PerfTestDriver {
final List<Setup> tests = new ArrayList<>();
// final String CACHEDCLOCK = "-Dlog4j.Clock=CachedClock";
- final String SYSCLOCK = "-Dlog4j.Clock=SystemClock";
- final String ALL_ASYNC = "-DLog4jContextSelector=" +
AsyncLoggerContextSelector.class.getName();
+ final String SYSCLOCK = asArgument(Log4jProperties.CONFIG_CLOCK,
"SystemClock");
+ final String ALL_ASYNC =
asArgument(Log4jProperties.CONTEXT_SELECTOR_CLASS_NAME,
AsyncLoggerContextSelector.class.getName());
- final String THREADNAME = "-DAsyncLogger.ThreadNameStrategy=" //
- + System.getProperty("AsyncLogger.ThreadNameStrategy",
"CACHED");
+ final String THREADNAME =
asArgument(Log4jProperties.ASYNC_LOGGER_THREAD_NAME_STRATEGY,
+
System.getProperty(Log4jProperties.ASYNC_LOGGER_THREAD_NAME_STRATEGY,
"CACHED"));
// includeLocation=false
add(tests, 1, "perf3PlainNoLoc.xml", Runner.Log4j2, "Loggers all
async", ALL_ASYNC, SYSCLOCK, THREADNAME);
@@ -363,4 +364,8 @@ public class PerfTestDriver {
t.start();
return t;
}
+
+ private static String asArgument(final String key, final String value) {
+ return String.format("-D%s=%s", key, value);
+ }
}
diff --git
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/perftest/ResponseTimeTest.java
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/perftest/ResponseTimeTest.java
index 16d5af1a6c..efeaa4917e 100644
---
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/perftest/ResponseTimeTest.java
+++
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/perftest/ResponseTimeTest.java
@@ -29,6 +29,7 @@ import org.HdrHistogram.Histogram;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.async.DefaultAsyncQueueFullPolicy;
import org.apache.logging.log4j.core.async.EventRoute;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.util.Constants;
import org.apache.logging.log4j.core.util.Loader;
@@ -107,12 +108,12 @@ public class ResponseTimeTest {
final String loggerLib = args.length > 2 ? args[2] : "Log4j2";
// print to console if ringbuffer is full
- System.setProperty("log4j2.AsyncQueueFullPolicy",
PrintingAsyncQueueFullPolicy.class.getName());
- System.setProperty("AsyncLogger.RingBufferSize", String.valueOf(256 *
1024));
- //System.setProperty("Log4jContextSelector",
AsyncLoggerContextSelector.class.getName());
- //System.setProperty("log4j.configurationFile", "perf3PlainNoLoc.xml");
- if (System.getProperty("AsyncLogger.WaitStrategy") == null) {
- System.setProperty("AsyncLogger.WaitStrategy", "Yield");
+ System.setProperty(Log4jProperties.ASYNC_LOGGER_QUEUE_FULL_POLICY,
PrintingAsyncQueueFullPolicy.class.getName());
+ System.setProperty(Log4jProperties.ASYNC_LOGGER_RING_BUFFER_SIZE,
String.valueOf(256 * 1024));
+ //System.setProperty(Log4jProperties.CONTEXT_SELECTOR_CLASS_NAME,
AsyncLoggerContextSelector.class.getName());
+ //System.setProperty(Log4jProperties.CONFIG_LOCATION,
"perf3PlainNoLoc.xml");
+ if (System.getProperty(Log4jProperties.ASYNC_LOGGER_WAIT_STRATEGY) ==
null) {
+ System.setProperty(Log4jProperties.ASYNC_LOGGER_WAIT_STRATEGY,
"Yield");
}
//for (Object key : System.getProperties().keySet()) {
// System.out.println(key + "=" + System.getProperty((String) key));
diff --git
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/TestConfiguratorError.java
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/TestConfiguratorError.java
index b41392fead..5b2046faae 100644
---
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/TestConfiguratorError.java
+++
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/TestConfiguratorError.java
@@ -17,15 +17,16 @@
package org.apache.logging.log4j.core.config;
import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.test.junit.LoggerContextFactoryExtension;
import org.apache.logging.log4j.simple.SimpleLoggerContextFactory;
+import org.apache.logging.log4j.spi.LoggingSystemProperties;
+import org.apache.logging.log4j.test.junit.LoggerContextFactoryExtension;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.api.parallel.ResourceLock;
import static org.junit.jupiter.api.Assertions.assertNull;
-@ResourceLock("log4j2.LoggerContextFactory")
+@ResourceLock(LoggingSystemProperties.LOGGER_CONTEXT_FACTORY_CLASS)
public class TestConfiguratorError {
@RegisterExtension
diff --git
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/tools/GenerateCustomLoggerTest.java
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/tools/GenerateCustomLoggerTest.java
index 2cd3c8266e..eea9662a16 100644
---
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/tools/GenerateCustomLoggerTest.java
+++
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/tools/GenerateCustomLoggerTest.java
@@ -14,7 +14,6 @@
* See the license for the specific language governing permissions and
* limitations under the license.
*/
-
package org.apache.logging.log4j.core.tools;
import java.io.File;
@@ -27,7 +26,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
-
import javax.tools.Diagnostic;
import javax.tools.DiagnosticCollector;
import javax.tools.JavaCompiler;
@@ -39,27 +37,24 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.message.Message;
import org.apache.logging.log4j.message.MessageFactory;
+import org.apache.logging.log4j.spi.LoggingSystemProperties;
import org.apache.logging.log4j.test.TestLogger;
import org.apache.logging.log4j.util.MessageSupplier;
import org.apache.logging.log4j.util.Strings;
import org.apache.logging.log4j.util.Supplier;
import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
+import org.junitpioneer.jupiter.SetSystemProperty;
import static org.junit.jupiter.api.Assertions.*;
@Tag("functional")
+@SetSystemProperty(key = LoggingSystemProperties.LOGGER_CONTEXT_FACTORY_CLASS,
value = "org.apache.logging.log4j.test.TestLoggerContextFactory")
public class GenerateCustomLoggerTest {
private static final String TEST_SOURCE =
"target/test-classes/org/apache/logging/log4j/core/MyCustomLogger.java";
- @BeforeAll
- public static void beforeClass() {
- System.setProperty("log4j2.loggerContextFactory",
"org.apache.logging.log4j.test.TestLoggerContextFactory");
- }
-
@AfterAll
public static void afterClass() {
File file = new File(TEST_SOURCE);
diff --git
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/tools/GenerateExtendedLoggerTest.java
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/tools/GenerateExtendedLoggerTest.java
index 47511e391f..88df837dc0 100644
---
a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/tools/GenerateExtendedLoggerTest.java
+++
b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/tools/GenerateExtendedLoggerTest.java
@@ -14,7 +14,6 @@
* See the license for the specific language governing permissions and
* limitations under the license.
*/
-
package org.apache.logging.log4j.core.tools;
import java.io.File;
@@ -27,7 +26,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
-
import javax.tools.Diagnostic;
import javax.tools.DiagnosticCollector;
import javax.tools.JavaCompiler;
@@ -40,27 +38,24 @@ import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.message.Message;
import org.apache.logging.log4j.message.MessageFactory;
import org.apache.logging.log4j.spi.ExtendedLogger;
+import org.apache.logging.log4j.spi.LoggingSystemProperties;
import org.apache.logging.log4j.test.TestLogger;
import org.apache.logging.log4j.util.MessageSupplier;
import org.apache.logging.log4j.util.Strings;
import org.apache.logging.log4j.util.Supplier;
import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
+import org.junitpioneer.jupiter.SetSystemProperty;
import static org.junit.jupiter.api.Assertions.*;
@Tag("functional")
+@SetSystemProperty(key = LoggingSystemProperties.LOGGER_CONTEXT_FACTORY_CLASS,
value = "org.apache.logging.log4j.test.TestLoggerContextFactory")
public class GenerateExtendedLoggerTest {
private static final String TEST_SOURCE =
"target/test-classes/org/apache/logging/log4j/core/MyExtendedLogger.java";
- @BeforeAll
- public static void beforeClass() {
- System.setProperty("log4j2.loggerContextFactory",
"org.apache.logging.log4j.test.TestLoggerContextFactory");
- }
-
@AfterAll
public static void afterClass() {
File file = new File(TEST_SOURCE);
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 c9577a2f49..9d5e9a5f5e 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
@@ -32,6 +32,7 @@ import org.apache.logging.log4j.core.util.Loader;
import org.apache.logging.log4j.core.util.NetUtils;
import org.apache.logging.log4j.plugins.Inject;
import org.apache.logging.log4j.plugins.di.Injector;
+import org.apache.logging.log4j.spi.LoggingSystemProperties;
import org.apache.logging.log4j.util.Lazy;
import org.apache.logging.log4j.util.LoaderUtil;
import org.apache.logging.log4j.util.PropertiesUtil;
@@ -159,9 +160,10 @@ public class DefaultConfigurationFactory extends
ConfigurationFactory {
LOGGER.warn("No Log4j 2 configuration file found. " +
"Using default configuration (logging only errors to the
console), " +
"or user programmatically provided configurations. " +
- "Set system property 'log4j2.debug' " +
+ "Set system property 'log4j2.*.{}' " +
"to show Log4j 2 internal initialization logging. " +
- "See
https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions
on how to configure Log4j 2");
+ "See
https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions
on how to configure Log4j 2",
+ LoggingSystemProperties.SYSTEM_DEBUG);
return new DefaultConfiguration();
}
diff --git
a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/AsyncLoggersBenchmark.java
b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/AsyncLoggersBenchmark.java
index 8ec2cb5516..43ae1aa1d1 100644
---
a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/AsyncLoggersBenchmark.java
+++
b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/AsyncLoggersBenchmark.java
@@ -14,7 +14,6 @@
* See the license for the specific language governing permissions and
* limitations under the license.
*/
-
package org.apache.logging.log4j.perf.jmh;
import java.io.File;
@@ -23,6 +22,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.LifeCycle;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.perf.util.BenchmarkMessageParams;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
@@ -57,12 +57,12 @@ public class AsyncLoggersBenchmark {
@Setup(Level.Trial)
public void up() {
- System.setProperty("log4j.configurationFile",
"perf-WithoutAnyAppender.xml");
- System.setProperty("Log4jContextSelector",
"org.apache.logging.log4j.core.async.AsyncLoggerContextSelector");
- System.setProperty("AsyncLogger.RingBufferSize", "262144");
- System.setProperty("AsyncLogger.WaitStrategy", "Yield");
- //System.setProperty("log4j2.enable.threadlocals", "true");
- //System.setProperty("log4j.format.msg.async", "true");
+ System.setProperty(Log4jProperties.CONFIG_LOCATION,
"perf-WithoutAnyAppender.xml");
+ System.setProperty(Log4jProperties.CONTEXT_SELECTOR_CLASS_NAME,
"org.apache.logging.log4j.core.async.AsyncLoggerContextSelector");
+ System.setProperty(Log4jProperties.ASYNC_LOGGER_RING_BUFFER_SIZE,
"262144");
+ System.setProperty(Log4jProperties.ASYNC_LOGGER_WAIT_STRATEGY,
"Yield");
+
//System.setProperty(LoggingSystemProperties.SYSTEM_THREAD_LOCALS_ENABLED,
"true");
+
//System.setProperty(Log4jProperties.ASYNC_LOGGER_FORMAT_MESSAGES_IN_BACKGROUND,
"true");
logger = LogManager.getLogger(getClass());
new File("perftest.log").delete();
diff --git
a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ConcurrentAsyncLoggerToFileBenchmark.java
b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ConcurrentAsyncLoggerToFileBenchmark.java
index 9211518b0a..fcdee8672d 100644
---
a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ConcurrentAsyncLoggerToFileBenchmark.java
+++
b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ConcurrentAsyncLoggerToFileBenchmark.java
@@ -28,6 +28,7 @@ import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.LifeCycle;
import org.apache.logging.log4j.core.async.AsyncQueueFullPolicy;
import org.apache.logging.log4j.core.async.EventRoute;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.perf.util.BenchmarkMessageParams;
import org.apache.logging.log4j.spi.LoggingSystemProperties;
import org.openjdk.jmh.annotations.Benchmark;
@@ -100,13 +101,13 @@ public class ConcurrentAsyncLoggerToFileBenchmark {
@SuppressWarnings("unused") // Used by JMH
public enum QueueFullPolicy {
- ENQUEUE(Map.of("log4j2.AsyncQueueFullPolicy", "Default")),
+ ENQUEUE(Map.of(Log4jProperties.ASYNC_LOGGER_QUEUE_FULL_POLICY,
"Default")),
ENQUEUE_UNSYNCHRONIZED(Map.of(
- "log4j2.AsyncQueueFullPolicy", "Default",
- "AsyncLogger.SynchronizeEnqueueWhenQueueFull", "false",
- "AsyncLoggerConfig.SynchronizeEnqueueWhenQueueFull", "false"
+ Log4jProperties.ASYNC_LOGGER_QUEUE_FULL_POLICY, "Default",
+
Log4jProperties.ASYNC_LOGGER_SYNCHRONIZE_ENQUEUE_WHEN_QUEUE_FULL, "false",
+
Log4jProperties.ASYNC_CONFIG_SYNCHRONIZE_ENQUEUE_WHEN_QUEUE_FULL, "false"
)),
- SYNCHRONOUS(Map.of("log4j2.AsyncQueueFullPolicy",
+ SYNCHRONOUS(Map.of(Log4jProperties.ASYNC_LOGGER_QUEUE_FULL_POLICY,
SynchronousAsyncQueueFullPolicy.class.getName()));
private final Map<String, String> properties;
@@ -131,12 +132,12 @@ public class ConcurrentAsyncLoggerToFileBenchmark {
void setProperties() {
switch (this) {
case ASYNC_CONTEXT:
- System.setProperty("log4j.configurationFile",
"ConcurrentAsyncLoggerToFileBenchmark.xml");
- System.setProperty("Log4jContextSelector",
+ System.setProperty(Log4jProperties.CONFIG_LOCATION,
"ConcurrentAsyncLoggerToFileBenchmark.xml");
+
System.setProperty(Log4jProperties.CONTEXT_SELECTOR_CLASS_NAME,
"org.apache.logging.log4j.core.async.AsyncLoggerContextSelector");
break;
case ASYNC_CONFIG:
- System.setProperty("log4j.configurationFile",
+ System.setProperty(Log4jProperties.CONFIG_LOCATION,
"ConcurrentAsyncLoggerToFileBenchmark-asyncConfig.xml");
break;
default:
diff --git
a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ThreadContextBenchmark.java
b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ThreadContextBenchmark.java
index ff22a47e00..94659687df 100644
---
a/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ThreadContextBenchmark.java
+++
b/log4j-perf/src/main/java/org/apache/logging/log4j/perf/jmh/ThreadContextBenchmark.java
@@ -14,7 +14,6 @@
* See the license for the specific language governing permissions and
* limitations under the license.
*/
-
package org.apache.logging.log4j.perf.jmh;
import java.util.ArrayList;
@@ -27,16 +26,17 @@ import java.util.concurrent.TimeUnit;
import org.apache.logging.log4j.ThreadContext;
import org.apache.logging.log4j.ThreadContextBenchmarkAccess;
-import org.apache.logging.log4j.core.config.Property;
import org.apache.logging.log4j.core.ContextDataInjector;
+import org.apache.logging.log4j.core.config.Property;
import org.apache.logging.log4j.core.impl.ContextDataInjectorFactory;
import org.apache.logging.log4j.perf.nogc.OpenHashStringMap;
import org.apache.logging.log4j.spi.CopyOnWriteOpenHashMapThreadContextMap;
import org.apache.logging.log4j.spi.DefaultThreadContextMap;
import org.apache.logging.log4j.spi.GarbageFreeOpenHashMapThreadContextMap;
+import org.apache.logging.log4j.spi.LoggingSystemProperties;
+import org.apache.logging.log4j.spi.ThreadContextMap;
import org.apache.logging.log4j.util.SortedArrayStringMap;
import org.apache.logging.log4j.util.StringMap;
-import org.apache.logging.log4j.spi.ThreadContextMap;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
@@ -103,7 +103,7 @@ public class ThreadContextBenchmark {
@Setup
public void setup() {
- System.setProperty("log4j2.threadContextMap",
IMPLEMENTATIONS.get(threadContextMapAlias).getName());
+ System.setProperty(LoggingSystemProperties.THREAD_CONTEXT_MAP_CLASS,
IMPLEMENTATIONS.get(threadContextMapAlias).getName());
ThreadContextBenchmarkAccess.init();
injector = ContextDataInjectorFactory.createInjector();
@@ -139,7 +139,7 @@ public class ThreadContextBenchmark {
@TearDown
public void tearDown() {
- System.clearProperty("log4j2.threadContextMap");
+ System.clearProperty(LoggingSystemProperties.THREAD_CONTEXT_MAP_CLASS);
ThreadContextBenchmarkAccess.init();
}
diff --git
a/log4j-spring-boot/src/test/java/org/apache/logging/log4j/spring/boot/Log4j2SpringBootInitTest.java
b/log4j-spring-boot/src/test/java/org/apache/logging/log4j/spring/boot/Log4j2SpringBootInitTest.java
index 93077df3dc..458827bef4 100644
---
a/log4j-spring-boot/src/test/java/org/apache/logging/log4j/spring/boot/Log4j2SpringBootInitTest.java
+++
b/log4j-spring-boot/src/test/java/org/apache/logging/log4j/spring/boot/Log4j2SpringBootInitTest.java
@@ -20,6 +20,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.test.appender.ListAppender;
+import org.apache.logging.log4j.spi.LoggingSystemProperties;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.SetSystemProperty;
import org.springframework.boot.ApplicationArguments;
@@ -32,7 +33,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@SetSystemProperty(key = "spring.profiles.active", value = "prod")
-@SetSystemProperty(key = "log4j2.loggerContextFactory", value =
"org.apache.logging.log4j.core.impl.Log4jContextFactory")
+@SetSystemProperty(key = LoggingSystemProperties.LOGGER_CONTEXT_FACTORY_CLASS,
value = "org.apache.logging.log4j.core.impl.Log4jContextFactory")
@SpringBootTest
public class Log4j2SpringBootInitTest {
@@ -61,4 +62,3 @@ public class Log4j2SpringBootInitTest {
}
}
}
-