You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ma...@apache.org on 2022/11/19 23:04:06 UTC
[logging-log4j2] branch master updated: Centralize log4j-core properties in Log4jProperties
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 287ee839a6 Centralize log4j-core properties in Log4jProperties
287ee839a6 is described below
commit 287ee839a6db6a5c638a7a5e551f4ed89f503884
Author: Matt Sicker <ma...@apache.org>
AuthorDate: Sat Nov 19 17:03:49 2022 -0600
Centralize log4j-core properties in Log4jProperties
This pulls together all the various property names used in log4j-core into a central class. Future property names are documented in these classes for future work with enhancing properties.
This also migrates a few tests to JUnit 5 while updating them to use the centralized properties class. Other tests were updated to more consistently set and clear system properties when using JUnit 4 along with more direct use of LoggerContextRule.
Signed-off-by: Matt Sicker <ma...@apache.org>
---
.../logging/log4j/spi/LoggingSystemProperties.java | 23 +++-
.../org/apache/logging/log4j/util/Constants.java | 4 +-
.../appender/rolling/RollingNewDirectoryTest.java | 10 +-
.../async/AsyncAppenderConfigTest_LOG4J2_2032.java | 16 +--
.../async/AsyncLoggerClassLoadDeadlockTest.java | 8 +-
.../log4j/core/async/AsyncLoggerConfig4Test.java | 11 +-
.../core/async/AsyncLoggerConfigAutoFlushTest.java | 9 +-
.../core/async/AsyncLoggerConfigErrorOnFormat.java | 13 +-
.../log4j/core/async/AsyncLoggerConfigTest.java | 12 +-
.../log4j/core/async/AsyncLoggerConfigTest2.java | 12 +-
.../AsyncLoggerConfigUseAfterShutdownTest.java | 4 +-
.../AsyncLoggerConfigWithAsyncEnabledTest.java | 14 +--
.../core/async/AsyncLoggerDefaultLocationTest.java | 4 +-
.../AsyncLoggerEventTranslationExceptionTest.java | 6 +-
.../log4j/core/async/AsyncLoggerLocationTest.java | 12 +-
.../logging/log4j/core/async/AsyncLoggerTest.java | 12 +-
.../AsyncLoggerTestArgumentFreedOnErrorTest.java | 11 +-
.../async/AsyncLoggerTestCachedThreadName.java | 12 +-
.../async/AsyncLoggerTestUncachedThreadName.java | 14 +--
.../core/async/AsyncLoggerThreadContextTest.java | 41 +++---
.../async/AsyncLoggerThreadNameStrategyTest.java | 31 ++---
.../async/AsyncLoggerUseAfterShutdownTest.java | 7 +-
.../async/AsyncQueueFullPolicyFactoryTest.java | 56 ++++-----
.../log4j/core/async/AsyncThreadContextTest.java | 17 +--
...WaitStrategyFactoryConfigGlobalLoggersTest.java | 43 +++----
...egyFactoryIncorrectConfigGlobalLoggersTest.java | 18 +--
.../async/DefaultAsyncQueueFullPolicyTest.java | 9 +-
.../log4j/core/async/Log4j2Jira1688AsyncTest.java | 26 ++--
.../log4j/core/async/Log4j2Jira1688Test.java | 25 +---
.../core/async/QueueFullAsyncAppenderTest.java | 12 +-
.../core/async/QueueFullAsyncAppenderTest2.java | 17 +--
...llAsyncLoggerConfigLoggingFromToStringTest.java | 16 ++-
...lAsyncLoggerConfigLoggingFromToStringTest2.java | 25 ++--
.../core/async/QueueFullAsyncLoggerConfigTest.java | 18 +--
.../async/QueueFullAsyncLoggerConfigTest2.java | 20 +--
...ueueFullAsyncLoggerLoggingFromToStringTest.java | 20 ++-
...eueFullAsyncLoggerLoggingFromToStringTest2.java | 25 ++--
.../log4j/core/async/QueueFullAsyncLoggerTest.java | 18 ++-
.../core/async/QueueFullAsyncLoggerTest2.java | 20 ++-
.../core/async/QueueFullAsyncLoggerTest3.java | 29 ++---
.../log4j/core/async/RingBufferLogEventTest.java | 30 +++--
.../config/CompositeConfigurationMissingTest.java | 12 +-
.../log4j/core/config/CustomConfigurationTest.java | 24 ++--
.../log4j/core/config/ReliabilityStrategyTest.java | 16 +--
.../log4j/core/config/xml/XmlLoggerPropsTest.java | 20 +--
...taFactoryPropertySetMissingConstructorTest.java | 7 +-
.../impl/ContextDataFactoryPropertySetTest.java | 11 +-
.../logging/log4j/core/time/ClockFactoryTest.java | 15 +--
.../apache/logging/log4j/core/LoggerContext.java | 3 +-
.../log4j/core/appender/ConsoleAppender.java | 3 +-
.../core/async/AsyncLoggerConfigDisruptor.java | 5 +-
.../core/async/AsyncLoggerContextSelector.java | 4 +-
.../log4j/core/async/AsyncLoggerDisruptor.java | 10 +-
.../core/async/AsyncQueueFullPolicyFactory.java | 11 +-
.../logging/log4j/core/async/DisruptorUtil.java | 17 +--
.../core/async/ThreadNameCachingStrategy.java | 7 +-
.../log4j/core/config/AbstractConfiguration.java | 3 +-
.../AwaitUnconditionallyReliabilityStrategy.java | 3 +-
.../log4j/core/config/ConfigurationFactory.java | 9 +-
.../log4j/core/config/DefaultConfiguration.java | 4 +-
.../core/config/DefaultConfigurationFactory.java | 3 +-
.../core/config/ReliabilityStrategyFactory.java | 3 +-
.../config/composite/CompositeConfiguration.java | 17 +--
.../log4j/core/impl/ContextDataFactory.java | 5 +-
.../core/impl/ContextDataInjectorFactory.java | 2 +-
.../logging/log4j/core/impl/DefaultBundle.java | 45 ++++---
.../log4j/core/impl/Log4jContextFactory.java | 2 +-
.../logging/log4j/core/impl/Log4jProperties.java | 140 +++++++++++++++++++++
.../org/apache/logging/log4j/core/jmx/Server.java | 7 +-
.../log4j/core/layout/AbstractStringLayout.java | 3 +-
.../logging/log4j/core/layout/PatternLayout.java | 3 +-
.../core/net/ssl/SslConfigurationFactory.java | 39 +++---
.../apache/logging/log4j/core/osgi/Activator.java | 6 +-
.../logging/log4j/core/time/ClockFactory.java | 3 +-
.../apache/logging/log4j/core/util/Constants.java | 54 ++------
.../log4j/core/util/ShutdownCallbackRegistry.java | 6 +-
.../apache/logging/log4j/core/util/UuidUtil.java | 11 +-
.../log4j/gctests/GcFreeLoggingTestUtil.java | 2 +-
.../org/apache/logging/log4j/web/PropertyTest.java | 2 +-
.../JsonTemplateLayoutNullEventDelimiterTest.java | 17 +--
.../org/apache/logging/log4j/web/PropertyTest.java | 2 +-
81 files changed, 642 insertions(+), 644 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 7ee8868f22..88541b010a 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
@@ -35,6 +35,8 @@ import org.apache.logging.log4j.util.Unbox;
* @see PropertiesUtil
*/
public final class LoggingSystemProperties {
+ // TODO: rename properties according to established theme in
+ // https://cwiki.apache.org/confluence/display/LOGGING/Properties+Enhancement
/**
* Property to enable TRACE-level debug logging in the Log4j system itself.
@@ -51,6 +53,7 @@ public final class LoggingSystemProperties {
* 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
public static final String SYSTEM_IS_WEBAPP = "log4j2.isWebapp";
/**
@@ -58,6 +61,7 @@ public final class LoggingSystemProperties {
*
* @see <a href="https://issues.apache.org/jira/browse/LOG4J2-1270">LOG4J2-1270</a>
*/
+ // GC.enableThreadLocals
public static final String SYSTEM_THREAD_LOCALS_ENABLED = "log4j2.enableThreadlocals";
/**
@@ -75,29 +79,34 @@ public final class LoggingSystemProperties {
public static final String LOADER_FORCE_THREAD_CONTEXT_LOADER = "log4j2.forceTCLOnly";
/**
- * Property to override the default ringbuffer size used in {@link Unbox}.
+ * Property to override the default ringbuffer size used in {@link Unbox}. The default value is 32.
*/
+ // GC.unboxRingBufferSize
public static final String UNBOX_RING_BUFFER_SIZE = "log4j2.unboxRingbufferSize";
/**
* Property to set to the fully qualified class name of a custom implementation of {@link LoggerContextFactory}.
*/
+ // LoggerContext.factory
public static final String LOGGER_CONTEXT_FACTORY_CLASS = "log4j2.loggerContextFactory";
/**
* Property to override the default {@link MessageFactory} class.
*/
+ // Message.messageFactory
public static final String LOGGER_MESSAGE_FACTORY_CLASS = "log4j2.messageFactory";
/**
* Property to override the default {@link FlowMessageFactory} class.
*/
+ // Message.flowMessageFactory
public static final String LOGGER_FLOW_MESSAGE_FACTORY_CLASS = "log4j2.flowMessageFactory";
/**
* Property to override the default maximum nesting depth of map messages to format in JSON output. The
* default value is 8.
*/
+ // Message.jsonFormatterMaxDepth
public static final String LOGGER_MAP_MESSAGE_JSON_FORMATTER_MAX_DEPTH = "log4j2.mapMessageJsonFormatterMaxDepth";
/**
@@ -106,48 +115,56 @@ public final class LoggingSystemProperties {
* is trimmed to this maximum size. The default value is 518 which allows the StringBuilder to resize three times
* from its initial size.
*/
- public static final String LOGGER_REUSABLE_MESSAGE_MAX_SIZE = "log4j2.maxReusableMsgSize";
+ // GC.maxReusableMsgSize
+ public static final String GC_REUSABLE_MESSAGE_MAX_SIZE = "log4j2.maxReusableMsgSize";
/**
* 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.
*/
+ // StatusLogger.entries
public static final String STATUS_MAX_ENTRIES = "log4j2.statusEntries";
/**
* Property that can be configured with the {@link Level} name to use as the default level for
* {@link StatusListener}s. The default value is {@link Level#WARN}.
*/
+ // StatusLogger.statusLoggerLevel
public static final String STATUS_DEFAULT_LISTENER_LEVEL = "log4j2.statusLoggerLevel";
/**
* Property that can be configured with a date-time format string to use as the format for timestamps
* in the status logger output. See {@link java.text.SimpleDateFormat} for supported formats.
*/
+ // StatusLogger.dateFormat
public static final String STATUS_DATE_FORMAT = "log4j2.statusLoggerDateFormat";
/**
* Property to control whether {@link ThreadContext} stores map data. If set to {@code true}, then the
* thread context map will be disabled.
*/
+ // ThreadContext.enableMap
public static final String THREAD_CONTEXT_MAP_DISABLED = "log4j2.disableThreadContextMap";
/**
* Property to control whether {@link ThreadContext} stores stack data. If set to {@code true}, then the
* thread context stack will be disabled.
*/
+ // ThreadContext.enableStack
public static final String THREAD_CONTEXT_STACK_DISABLED = "log4j2.disableThreadContextStack";
/**
* Property to control whether {@link ThreadContext} stores any data. If set to {@code true}, then the
* thread context map and stack will be disabled.
*/
+ // ThreadContext.enabled
public static final String THREAD_CONTEXT_DISABLED = "log4j2.disableThreadContext";
/**
* Property to control whether {@link ThreadContextMap} uses {@link InheritableThreadLocal} when {@code true} or
* {@link ThreadLocal} otherwise for holding map data.
*/
+ // ThreadContext.inheritable
public static final String THREAD_CONTEXT_MAP_INHERITABLE = "log4j2.isThreadContextMapInheritable";
/**
@@ -160,11 +177,13 @@ public final class LoggingSystemProperties {
/**
* Property to override the initial capacity of the thread context map. The default value is 16.
*/
+ // ThreadContext.initialCapacity
public static final String THREAD_CONTEXT_INITIAL_CAPACITY = "log4j2.threadContextInitialCapacity";
/**
* Property to override whether to use a garbage-free implementation of {@link ThreadContextMap}.
*/
+ // ThreadContext.garbageFree
public static final String THREAD_CONTEXT_GARBAGE_FREE_ENABLED = "log4j2.garbagefreeThreadContextMap";
private LoggingSystemProperties() {
diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/util/Constants.java b/log4j-api/src/main/java/org/apache/logging/log4j/util/Constants.java
index d11a2a8269..0044eef676 100644
--- a/log4j-api/src/main/java/org/apache/logging/log4j/util/Constants.java
+++ b/log4j-api/src/main/java/org/apache/logging/log4j/util/Constants.java
@@ -88,11 +88,11 @@ public final class Constants {
* After a large message has been delivered to the appenders, the StringBuilder is trimmed to this size.
* <p>
* The default value is 518, which allows the StringBuilder to resize three times from its initial size.
- * Users can override with system property {@value LoggingSystemProperties#LOGGER_REUSABLE_MESSAGE_MAX_SIZE}.
+ * Users can override with system property {@value LoggingSystemProperties#GC_REUSABLE_MESSAGE_MAX_SIZE}.
* </p>
* @since 2.9
*/
- public static final int MAX_REUSABLE_MESSAGE_SIZE = size(LoggingSystemProperties.LOGGER_REUSABLE_MESSAGE_MAX_SIZE, (128 * 2 + 2) * 2 + 2);
+ public static final int MAX_REUSABLE_MESSAGE_SIZE = size(LoggingSystemProperties.GC_REUSABLE_MESSAGE_MAX_SIZE, (128 * 2 + 2) * 2 + 2);
private static int size(final String property, final int defaultValue) {
return PropertiesUtil.getProperties().getIntegerProperty(property, defaultValue);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingNewDirectoryTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingNewDirectoryTest.java
index 1dd931b4a0..d1317e7e12 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingNewDirectoryTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingNewDirectoryTest.java
@@ -16,6 +16,10 @@
*/
package org.apache.logging.log4j.core.appender.rolling;
+import java.io.File;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.test.junit.LoggerContextSource;
import org.apache.logging.log4j.plugins.Named;
@@ -23,10 +27,6 @@ import org.apache.logging.log4j.test.junit.CleanUpDirectories;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-import java.io.File;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.fail;
@@ -44,7 +44,7 @@ public class RollingNewDirectoryTest implements RolloverListener {
@LoggerContextSource(value = CONFIG, timeout = 10)
public void streamClosedError(final Logger logger, @Named("RollingFile") final RollingFileManager manager) throws Exception {
manager.addRolloverListener(this);
- for (int i = 0; i < 10; ++i) {
+ for (int i = 0; i <= 10; ++i) {
logger.info("AAA");
Thread.sleep(300);
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncAppenderConfigTest_LOG4J2_2032.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncAppenderConfigTest_LOG4J2_2032.java
index 378f655a21..8cbee4e4cb 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncAppenderConfigTest_LOG4J2_2032.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncAppenderConfigTest_LOG4J2_2032.java
@@ -16,24 +16,26 @@
*/
package org.apache.logging.log4j.core.async;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
+import org.apache.logging.log4j.spi.LoggingSystemProperties;
import org.apache.logging.log4j.test.junit.CleanUpFiles;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.SetSystemProperty;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-
import static org.junit.jupiter.api.Assertions.assertTrue;
@Tag("async")
-@SetSystemProperty(key = "log4j2.logEventFactory", value = "org.apache.logging.log4j.core.impl.ReusableLogEventFactory")
-@SetSystemProperty(key = "log4j2.messageFactory", value = "org.apache.logging.log4j.message.ReusableMessageFactory")
-@SetSystemProperty(key = "log4j2.configurationFile", value = "AsyncAppenderConfigTest-LOG4J2-2032.xml")
+@SetSystemProperty(key = Log4jProperties.LOG_EVENT_FACTORY_CLASS_NAME, value = "org.apache.logging.log4j.core.impl.ReusableLogEventFactory")
+@SetSystemProperty(key = LoggingSystemProperties.LOGGER_MESSAGE_FACTORY_CLASS, value = "org.apache.logging.log4j.message.ReusableMessageFactory")
+@SetSystemProperty(key = Log4jProperties.CONFIG_LOCATION, value = "AsyncAppenderConfigTest-LOG4J2-2032.xml")
public class AsyncAppenderConfigTest_LOG4J2_2032 {
@Test
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerClassLoadDeadlockTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerClassLoadDeadlockTest.java
index e3fda82202..b213db0383 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerClassLoadDeadlockTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerClassLoadDeadlockTest.java
@@ -16,7 +16,7 @@
*/
package org.apache.logging.log4j.core.async;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
@@ -28,9 +28,9 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
* Test class loading deadlock condition from the LOG4J2-1457
*/
@Tag("async")
-@SetSystemProperty(key = "Log4jContextSelector", value = "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector")
-@SetSystemProperty(key = "AsyncLogger.RingBufferSize", value = "128")
-@SetSystemProperty(key = ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, value = "AsyncLoggerConsoleTest.xml")
+@SetSystemProperty(key = Log4jProperties.CONTEXT_SELECTOR_CLASS_NAME, value = "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector")
+@SetSystemProperty(key = Log4jProperties.ASYNC_LOGGER_RING_BUFFER_SIZE, value = "128")
+@SetSystemProperty(key = Log4jProperties.CONFIG_LOCATION, value = "AsyncLoggerConsoleTest.xml")
public class AsyncLoggerClassLoadDeadlockTest {
static final int RING_BUFFER_SIZE = 128;
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfig4Test.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfig4Test.java
index 128a286d11..1e03176211 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfig4Test.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfig4Test.java
@@ -16,24 +16,25 @@
*/
package org.apache.logging.log4j.core.async;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.SetSystemProperty;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@Tag("async")
-@SetSystemProperty(key = "log4j2.configurationFile", value = "AsyncLoggerConfigTest4.xml")
+@SetSystemProperty(key = Log4jProperties.CONFIG_LOCATION, value = "AsyncLoggerConfigTest4.xml")
public class AsyncLoggerConfig4Test {
@Test
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigAutoFlushTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigAutoFlushTest.java
index 136bd13c30..5acd476b9c 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigAutoFlushTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigAutoFlushTest.java
@@ -16,21 +16,22 @@
*/
package org.apache.logging.log4j.core.async;
+import java.io.File;
+import java.nio.file.Files;
+
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
import org.apache.logging.log4j.test.junit.CleanUpFiles;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.SetSystemProperty;
-import java.io.File;
-import java.nio.file.Files;
-
import static org.junit.jupiter.api.Assertions.assertTrue;
@Tag("async")
-@SetSystemProperty(key = "log4j2.configurationFile", value = "AsyncLoggerConfigAutoFlushTest.xml")
+@SetSystemProperty(key = Log4jProperties.CONFIG_LOCATION, value = "AsyncLoggerConfigAutoFlushTest.xml")
public class AsyncLoggerConfigAutoFlushTest {
@Test
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigErrorOnFormat.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigErrorOnFormat.java
index e7d875ddaa..a1d640bdf8 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigErrorOnFormat.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigErrorOnFormat.java
@@ -16,8 +16,13 @@
*/
package org.apache.logging.log4j.core.async;
+import java.io.File;
+import java.nio.file.Files;
+import java.util.List;
+
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
import org.apache.logging.log4j.message.AsynchronouslyFormattable;
import org.apache.logging.log4j.message.Message;
@@ -26,18 +31,14 @@ import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.SetSystemProperty;
-import java.io.File;
-import java.nio.file.Files;
-import java.util.List;
-
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.jupiter.api.Assertions.assertTrue;
@Tag("async")
-@SetSystemProperty(key = "log4j2.configurationFile", value = "AsyncLoggerConfigErrorOnFormat.xml")
-@SetSystemProperty(key = "log4j2.logEventFactory", value = "org.apache.logging.log4j.core.impl.DefaultLogEventFactory")
+@SetSystemProperty(key = Log4jProperties.CONFIG_LOCATION, value = "AsyncLoggerConfigErrorOnFormat.xml")
+@SetSystemProperty(key = Log4jProperties.LOG_EVENT_FACTORY_CLASS_NAME, value = "org.apache.logging.log4j.core.impl.DefaultLogEventFactory")
public class AsyncLoggerConfigErrorOnFormat {
@Test
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigTest.java
index a1aad87060..eddb6233aa 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigTest.java
@@ -16,26 +16,26 @@
*/
package org.apache.logging.log4j.core.async;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.config.AppenderRef;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.config.DefaultConfiguration;
import org.apache.logging.log4j.core.config.LoggerConfig;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.SetSystemProperty;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-
import static org.junit.jupiter.api.Assertions.*;
@Tag("async")
-@SetSystemProperty(key = ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, value = "AsyncLoggerConfigTest.xml")
+@SetSystemProperty(key = Log4jProperties.CONFIG_LOCATION, value = "AsyncLoggerConfigTest.xml")
public class AsyncLoggerConfigTest {
@Test
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigTest2.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigTest2.java
index fc6a3a5202..0ee021162e 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigTest2.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigTest2.java
@@ -16,24 +16,24 @@
*/
package org.apache.logging.log4j.core.async;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+
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.config.ConfigurationFactory;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.SetSystemProperty;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@Tag("async")
-@SetSystemProperty(key = ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, value = "AsyncLoggerConfigTest2.xml")
+@SetSystemProperty(key = Log4jProperties.CONFIG_LOCATION, value = "AsyncLoggerConfigTest2.xml")
public class AsyncLoggerConfigTest2 {
@Test
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigUseAfterShutdownTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigUseAfterShutdownTest.java
index ba5545fabb..cec05f536e 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigUseAfterShutdownTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigUseAfterShutdownTest.java
@@ -19,7 +19,7 @@ package org.apache.logging.log4j.core.async;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
import org.apache.logging.log4j.message.SimpleMessage;
import org.apache.logging.log4j.spi.AbstractLogger;
@@ -28,7 +28,7 @@ import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.SetSystemProperty;
@Tag("async")
-@SetSystemProperty(key = ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, value = "AsyncLoggerConfigTest.xml")
+@SetSystemProperty(key = Log4jProperties.CONFIG_LOCATION, value = "AsyncLoggerConfigTest.xml")
public class AsyncLoggerConfigUseAfterShutdownTest {
@Test
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigWithAsyncEnabledTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigWithAsyncEnabledTest.java
index 4c026266ca..65e6af56d4 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigWithAsyncEnabledTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigWithAsyncEnabledTest.java
@@ -16,25 +16,25 @@
*/
package org.apache.logging.log4j.core.async;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.SetSystemProperty;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.junit.jupiter.api.Assertions.assertTrue;
@Tag("async")
-@SetSystemProperty(key = "Log4jContextSelector", value = "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector")
-@SetSystemProperty(key = ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, value = "AsyncLoggerConfigTest4.xml")
+@SetSystemProperty(key = Log4jProperties.CONTEXT_SELECTOR_CLASS_NAME, value = "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector")
+@SetSystemProperty(key = Log4jProperties.CONFIG_LOCATION, value = "AsyncLoggerConfigTest4.xml")
public class AsyncLoggerConfigWithAsyncEnabledTest {
@Test
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerDefaultLocationTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerDefaultLocationTest.java
index 9a731bc0f6..3d24bf331d 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerDefaultLocationTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerDefaultLocationTest.java
@@ -20,7 +20,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.test.appender.ListAppender;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
@@ -29,7 +29,7 @@ import org.junitpioneer.jupiter.SetSystemProperty;
import static org.junit.jupiter.api.Assertions.*;
@Tag("async")
-@SetSystemProperty(key = ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, value = "AsyncLoggerDefaultLocationTest.xml")
+@SetSystemProperty(key = Log4jProperties.CONFIG_LOCATION, value = "AsyncLoggerDefaultLocationTest.xml")
public class AsyncLoggerDefaultLocationTest {
@Test
public void testAsyncLogWritesToLog() throws Exception {
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerEventTranslationExceptionTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerEventTranslationExceptionTest.java
index cd347a743d..42e38f8ae2 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerEventTranslationExceptionTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerEventTranslationExceptionTest.java
@@ -16,10 +16,10 @@
*/
package org.apache.logging.log4j.core.async;
-import com.lmax.disruptor.ExceptionHandler;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
import org.apache.logging.log4j.core.test.junit.ContextSelectorType;
import org.apache.logging.log4j.message.Message;
@@ -29,6 +29,8 @@ import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.SetSystemProperty;
+import com.lmax.disruptor.ExceptionHandler;
+
import static org.junit.jupiter.api.Assertions.*;
/**
@@ -40,7 +42,7 @@ import static org.junit.jupiter.api.Assertions.*;
*/
@Tag("async")
@ContextSelectorType(AsyncLoggerContextSelector.class)
-@SetSystemProperty(key = "AsyncLogger.ExceptionHandler", value = "org.apache.logging.log4j.core.async.AsyncLoggerEventTranslationExceptionTest$TestExceptionHandler")
+@SetSystemProperty(key = Log4jProperties.ASYNC_LOGGER_EXCEPTION_HANDLER_CLASS_NAME, value = "org.apache.logging.log4j.core.async.AsyncLoggerEventTranslationExceptionTest$TestExceptionHandler")
class AsyncLoggerEventTranslationExceptionTest {
@Test
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerLocationTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerLocationTest.java
index 38fcdb8be1..2091586c22 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerLocationTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerLocationTest.java
@@ -16,9 +16,13 @@
*/
package org.apache.logging.log4j.core.async;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
import org.apache.logging.log4j.core.test.junit.ContextSelectorType;
import org.apache.logging.log4j.test.junit.CleanUpFiles;
@@ -26,16 +30,12 @@ import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.SetSystemProperty;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@Tag("async")
@ContextSelectorType(AsyncLoggerContextSelector.class)
-@SetSystemProperty(key = ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, value = "AsyncLoggerLocationTest.xml")
+@SetSystemProperty(key = Log4jProperties.CONFIG_LOCATION, value = "AsyncLoggerLocationTest.xml")
@CleanUpFiles("target/AsyncLoggerLocationTest.log")
public class AsyncLoggerLocationTest {
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTest.java
index a0bb2dbbf4..e2adb683d8 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTest.java
@@ -16,8 +16,12 @@
*/
package org.apache.logging.log4j.core.async;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+
import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
import org.apache.logging.log4j.core.test.junit.ContextSelectorType;
import org.apache.logging.log4j.core.time.internal.DummyNanoClock;
@@ -25,15 +29,11 @@ import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.SetSystemProperty;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-
import static org.junit.jupiter.api.Assertions.*;
@Tag("async")
@ContextSelectorType(AsyncLoggerContextSelector.class)
-@SetSystemProperty(key = ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, value = "AsyncLoggerTest.xml")
+@SetSystemProperty(key = Log4jProperties.CONFIG_LOCATION, value = "AsyncLoggerTest.xml")
public class AsyncLoggerTest {
@Test
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTestArgumentFreedOnErrorTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTestArgumentFreedOnErrorTest.java
index d03d75cbb7..f41dd7df31 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTestArgumentFreedOnErrorTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTestArgumentFreedOnErrorTest.java
@@ -16,8 +16,12 @@
*/
package org.apache.logging.log4j.core.async;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.GarbageCollectionHelper;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.test.junit.ContextSelectorType;
import org.apache.logging.log4j.message.Message;
import org.apache.logging.log4j.util.StringBuilderFormattable;
@@ -25,14 +29,11 @@ import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.SetSystemProperty;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
import static org.junit.jupiter.api.Assertions.assertTrue;
@Tag("async")
-@SetSystemProperty(key = "log4j2.enable.direct.encoders", value = "true")
-@SetSystemProperty(key = "log4j.format.msg.async", value = "true")
+@SetSystemProperty(key = Log4jProperties.GC_ENABLE_DIRECT_ENCODERS, value = "true")
+@SetSystemProperty(key = Log4jProperties.ASYNC_LOGGER_FORMAT_MESSAGES_IN_BACKGROUND, value = "true")
@ContextSelectorType(AsyncLoggerContextSelector.class)
public class AsyncLoggerTestArgumentFreedOnErrorTest {
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTestCachedThreadName.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTestCachedThreadName.java
index a1aebe6b5a..7020f59c6b 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTestCachedThreadName.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTestCachedThreadName.java
@@ -16,25 +16,25 @@
*/
package org.apache.logging.log4j.core.async;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
import org.apache.logging.log4j.core.test.junit.ContextSelectorType;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.SetSystemProperty;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@Tag("async")
@ContextSelectorType(AsyncLoggerContextSelector.class)
-@SetSystemProperty(key = ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, value = "AsyncLoggerTest.xml")
+@SetSystemProperty(key = Log4jProperties.CONFIG_LOCATION, value = "AsyncLoggerTest.xml")
public class AsyncLoggerTestCachedThreadName {
@Test
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTestUncachedThreadName.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTestUncachedThreadName.java
index a2b4aae483..08089ddff2 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTestUncachedThreadName.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerTestUncachedThreadName.java
@@ -16,23 +16,23 @@
*/
package org.apache.logging.log4j.core.async;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
import org.apache.logging.log4j.core.test.junit.ContextSelectorType;
import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.SetSystemProperty;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
-@SetSystemProperty(key = "AsyncLogger.ThreadNameStrategy", value = "UNCACHED")
-@SetSystemProperty(key = ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, value = "AsyncLoggerTest.xml")
+@SetSystemProperty(key = Log4jProperties.ASYNC_LOGGER_THREAD_NAME_STRATEGY, value = "UNCACHED")
+@SetSystemProperty(key = Log4jProperties.CONFIG_LOCATION, value = "AsyncLoggerTest.xml")
@ContextSelectorType(AsyncLoggerContextSelector.class)
public class AsyncLoggerTestUncachedThreadName {
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerThreadContextTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerThreadContextTest.java
index b5b4746764..e9a7afee7f 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerThreadContextTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerThreadContextTest.java
@@ -23,34 +23,21 @@ import java.io.FileReader;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.util.Constants;
-import org.apache.logging.log4j.util.Strings;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.apache.logging.log4j.core.test.junit.ContextSelectorType;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junitpioneer.jupiter.SetSystemProperty;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-@Category(AsyncLoggers.class)
+@Tag("async")
+@SetSystemProperty(key = Log4jProperties.CONFIG_LOCATION, value = "AsyncLoggerThreadContextTest.xml")
+@ContextSelectorType(AsyncLoggerContextSelector.class)
public class AsyncLoggerThreadContextTest {
- @BeforeClass
- public static void beforeClass() {
- System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR,
- AsyncLoggerContextSelector.class.getName());
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
- "AsyncLoggerThreadContextTest.xml");
- }
-
- @AfterClass
- public static void afterClass() {
- System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, Strings.EMPTY);
- }
-
@Test
public void testAsyncLogWritesToLog() throws Exception {
final File file = new File("target", "AsyncLoggerTest.log");
@@ -69,11 +56,11 @@ public class AsyncLoggerThreadContextTest {
final String line1 = reader.readLine();
reader.close();
file.delete();
- assertNotNull("line1", line1);
- assertTrue("line1 correct", line1.contains(msg));
+ assertNotNull(line1, "line1");
+ assertTrue(line1.contains(msg), "line1 correct");
- assertTrue("ThreadContext.map", line1.contains("mapvalue"));
- assertTrue("ThreadContext.stack", line1.contains("stackvalue"));
+ assertTrue(line1.contains("mapvalue"), "ThreadContext.map");
+ assertTrue(line1.contains("stackvalue"), "ThreadContext.stack");
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerThreadNameStrategyTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerThreadNameStrategyTest.java
index e755cf4389..c40862eba6 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerThreadNameStrategyTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerThreadNameStrategyTest.java
@@ -1,7 +1,7 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
- * this work for additional rmation regarding copyright ownership.
+ * 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
@@ -16,25 +16,16 @@
*/
package org.apache.logging.log4j.core.async;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junitpioneer.jupiter.SetSystemProperty;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
-@Category(AsyncLoggers.class)
+@Tag("async")
public class AsyncLoggerThreadNameStrategyTest {
- @After
- public void after() {
- System.clearProperty("AsyncLogger.ThreadNameStrategy");
- }
-
- @Before
- public void before() {
- System.clearProperty("AsyncLogger.ThreadNameStrategy");
- }
@Test
public void testDefaultIfNotConfigured() throws Exception {
@@ -43,22 +34,22 @@ public class AsyncLoggerThreadNameStrategyTest {
}
@Test
+ @SetSystemProperty(key = Log4jProperties.ASYNC_LOGGER_THREAD_NAME_STRATEGY, value = "\\%%InValid ")
public void testDefaultIfInvalidConfig() throws Exception {
- System.setProperty("AsyncLogger.ThreadNameStrategy", "\\%%InValid ");
final ThreadNameCachingStrategy tns = ThreadNameCachingStrategy.create();
assertSame(ThreadNameCachingStrategy.DEFAULT_STRATEGY, tns);
}
@Test
+ @SetSystemProperty(key = Log4jProperties.ASYNC_LOGGER_THREAD_NAME_STRATEGY, value = "CACHED")
public void testUseCachedThreadNameIfConfigured() throws Exception {
- System.setProperty("AsyncLogger.ThreadNameStrategy", "CACHED");
final ThreadNameCachingStrategy tns = ThreadNameCachingStrategy.create();
assertSame(ThreadNameCachingStrategy.CACHED, tns);
}
@Test
+ @SetSystemProperty(key = Log4jProperties.ASYNC_LOGGER_THREAD_NAME_STRATEGY, value = "UNCACHED")
public void testUseUncachedThreadNameIfConfigured() throws Exception {
- System.setProperty("AsyncLogger.ThreadNameStrategy", "UNCACHED");
final ThreadNameCachingStrategy tns = ThreadNameCachingStrategy.create();
assertSame(ThreadNameCachingStrategy.UNCACHED, tns);
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerUseAfterShutdownTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerUseAfterShutdownTest.java
index d96a29c316..267f9e88e0 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerUseAfterShutdownTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncLoggerUseAfterShutdownTest.java
@@ -19,9 +19,8 @@ package org.apache.logging.log4j.core.async;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
-import org.apache.logging.log4j.core.util.Constants;
import org.apache.logging.log4j.message.SimpleMessage;
import org.apache.logging.log4j.spi.AbstractLogger;
import org.junit.jupiter.api.Tag;
@@ -35,8 +34,8 @@ import org.junitpioneer.jupiter.SetSystemProperty;
@Tag("functional")
public class AsyncLoggerUseAfterShutdownTest {
@Test
- @SetSystemProperty(key = Constants.LOG4J_CONTEXT_SELECTOR, value = "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector")
- @SetSystemProperty(key = ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, value = "AsyncLoggerTest.xml")
+ @SetSystemProperty(key = Log4jProperties.CONTEXT_SELECTOR_CLASS_NAME, value = "org.apache.logging.log4j.core.async.AsyncLoggerContextSelector")
+ @SetSystemProperty(key = Log4jProperties.CONFIG_LOCATION, value = "AsyncLoggerTest.xml")
public void testNoErrorIfLogAfterShutdown() throws Exception {
final Logger log = LogManager.getLogger("com.foo.Bar");
final String msg = "Async logger msg";
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncQueueFullPolicyFactoryTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncQueueFullPolicyFactoryTest.java
index 006d422c93..8820918017 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncQueueFullPolicyFactoryTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncQueueFullPolicyFactoryTest.java
@@ -19,53 +19,53 @@ package org.apache.logging.log4j.core.async;
import java.util.Locale;
import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.util.PropertiesUtil;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Tests the AsyncQueueFullPolicyFactory class.
*/
-@Category(AsyncLoggers.class)
+@Tag("async")
public class AsyncQueueFullPolicyFactoryTest {
- @Before
- @After
- public void resetProperties() throws Exception {
- System.clearProperty(AsyncQueueFullPolicyFactory.PROPERTY_NAME_ASYNC_EVENT_ROUTER);
- System.clearProperty(AsyncQueueFullPolicyFactory.PROPERTY_NAME_DISCARDING_THRESHOLD_LEVEL);
- ((PropertiesUtil) PropertiesUtil.getProperties()).reload();
+ @BeforeEach
+ @AfterEach
+ public void resetProperties() {
+ System.clearProperty(Log4jProperties.ASYNC_LOGGER_QUEUE_FULL_POLICY);
+ System.clearProperty(Log4jProperties.ASYNC_LOGGER_DISCARD_THRESHOLD);
+ PropertiesUtil.getProperties().reload();
}
@Test
- public void testCreateReturnsDefaultRouterByDefault() throws Exception {
+ public void testCreateReturnsDefaultRouterByDefault() {
final AsyncQueueFullPolicy router = AsyncQueueFullPolicyFactory.create();
assertEquals(DefaultAsyncQueueFullPolicy.class, router.getClass());
}
@Test
- public void testCreateReturnsDiscardingRouterIfSpecified() throws Exception {
- System.setProperty(AsyncQueueFullPolicyFactory.PROPERTY_NAME_ASYNC_EVENT_ROUTER,
+ public void testCreateReturnsDiscardingRouterIfSpecified() {
+ System.setProperty(Log4jProperties.ASYNC_LOGGER_QUEUE_FULL_POLICY,
AsyncQueueFullPolicyFactory.PROPERTY_VALUE_DISCARDING_ASYNC_EVENT_ROUTER);
assertEquals(DiscardingAsyncQueueFullPolicy.class, AsyncQueueFullPolicyFactory.create().getClass());
- System.setProperty(AsyncQueueFullPolicyFactory.PROPERTY_NAME_ASYNC_EVENT_ROUTER,
+ System.setProperty(Log4jProperties.ASYNC_LOGGER_QUEUE_FULL_POLICY,
DiscardingAsyncQueueFullPolicy.class.getSimpleName());
assertEquals(DiscardingAsyncQueueFullPolicy.class, AsyncQueueFullPolicyFactory.create().getClass());
- System.setProperty(AsyncQueueFullPolicyFactory.PROPERTY_NAME_ASYNC_EVENT_ROUTER,
+ System.setProperty(Log4jProperties.ASYNC_LOGGER_QUEUE_FULL_POLICY,
DiscardingAsyncQueueFullPolicy.class.getName());
assertEquals(DiscardingAsyncQueueFullPolicy.class, AsyncQueueFullPolicyFactory.create().getClass());
}
@Test
- public void testCreateDiscardingRouterDefaultThresholdLevelInfo() throws Exception {
- System.setProperty(AsyncQueueFullPolicyFactory.PROPERTY_NAME_ASYNC_EVENT_ROUTER,
+ public void testCreateDiscardingRouterDefaultThresholdLevelInfo() {
+ System.setProperty(Log4jProperties.ASYNC_LOGGER_QUEUE_FULL_POLICY,
AsyncQueueFullPolicyFactory.PROPERTY_VALUE_DISCARDING_ASYNC_EVENT_ROUTER);
assertEquals(Level.INFO, ((DiscardingAsyncQueueFullPolicy) AsyncQueueFullPolicyFactory.create()).
getThresholdLevel());
@@ -73,19 +73,19 @@ public class AsyncQueueFullPolicyFactoryTest {
@Test
public void testCreateDiscardingRouterCaseInsensitive() {
- System.setProperty(AsyncQueueFullPolicyFactory.PROPERTY_NAME_ASYNC_EVENT_ROUTER,
+ System.setProperty(Log4jProperties.ASYNC_LOGGER_QUEUE_FULL_POLICY,
AsyncQueueFullPolicyFactory.PROPERTY_VALUE_DISCARDING_ASYNC_EVENT_ROUTER.toLowerCase(Locale.ENGLISH));
assertEquals(Level.INFO, ((DiscardingAsyncQueueFullPolicy) AsyncQueueFullPolicyFactory.create()).
getThresholdLevel());
}
@Test
- public void testCreateDiscardingRouterThresholdLevelCustomizable() throws Exception {
- System.setProperty(AsyncQueueFullPolicyFactory.PROPERTY_NAME_ASYNC_EVENT_ROUTER,
+ public void testCreateDiscardingRouterThresholdLevelCustomizable() {
+ System.setProperty(Log4jProperties.ASYNC_LOGGER_QUEUE_FULL_POLICY,
AsyncQueueFullPolicyFactory.PROPERTY_VALUE_DISCARDING_ASYNC_EVENT_ROUTER);
for (final Level level : Level.values()) {
- System.setProperty(AsyncQueueFullPolicyFactory.PROPERTY_NAME_DISCARDING_THRESHOLD_LEVEL,
+ System.setProperty(Log4jProperties.ASYNC_LOGGER_DISCARD_THRESHOLD,
level.name());
assertEquals(level, ((DiscardingAsyncQueueFullPolicy) AsyncQueueFullPolicyFactory.create()).
getThresholdLevel());
@@ -106,15 +106,15 @@ public class AsyncQueueFullPolicyFactoryTest {
}
@Test
- public void testCreateReturnsCustomRouterIfSpecified() throws Exception {
- System.setProperty(AsyncQueueFullPolicyFactory.PROPERTY_NAME_ASYNC_EVENT_ROUTER,
+ public void testCreateReturnsCustomRouterIfSpecified() {
+ System.setProperty(Log4jProperties.ASYNC_LOGGER_QUEUE_FULL_POLICY,
CustomRouterDefaultConstructor.class.getName());
assertEquals(CustomRouterDefaultConstructor.class, AsyncQueueFullPolicyFactory.create().getClass());
}
@Test
- public void testCreateReturnsDefaultRouterIfSpecifiedCustomRouterFails() throws Exception {
- System.setProperty(AsyncQueueFullPolicyFactory.PROPERTY_NAME_ASYNC_EVENT_ROUTER,
+ public void testCreateReturnsDefaultRouterIfSpecifiedCustomRouterFails() {
+ System.setProperty(Log4jProperties.ASYNC_LOGGER_QUEUE_FULL_POLICY,
DoesNotImplementInterface.class.getName());
assertEquals(DefaultAsyncQueueFullPolicy.class, AsyncQueueFullPolicyFactory.create().getClass());
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncThreadContextTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncThreadContextTest.java
index 8d0c39e9d3..292437161c 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncThreadContextTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncThreadContextTest.java
@@ -27,6 +27,7 @@ import org.apache.logging.log4j.core.Logger;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.ThreadContextTestAccess;
import org.apache.logging.log4j.core.impl.Log4jContextFactory;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.jmx.RingBufferAdmin;
import org.apache.logging.log4j.core.selector.ClassLoaderContextSelector;
import org.apache.logging.log4j.core.selector.ContextSelector;
@@ -41,15 +42,17 @@ import org.apache.logging.log4j.test.junit.CleanUpFiles;
import org.apache.logging.log4j.util.PropertiesUtil;
import org.apache.logging.log4j.util.Unbox;
import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
+import org.junitpioneer.jupiter.SetSystemProperty;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
@Tag("sleepy")
+@SetSystemProperty(key = Log4jProperties.ASYNC_LOGGER_RING_BUFFER_SIZE, value = "128") // minimum ringbuffer size
+@SetSystemProperty(key = Log4jProperties.ASYNC_CONFIG_RING_BUFFER_SIZE, value = "128") // minimum ringbuffer size
public class AsyncThreadContextTest {
private final static int LINE_COUNT = 130;
@@ -60,16 +63,8 @@ public class AsyncThreadContextTest {
new File("target", "AsyncAppenderContextTest.log"), //
};
- @BeforeAll
- public static void beforeClass() {
- System.setProperty("AsyncLogger.RingBufferSize", "128"); // minimum ringbuffer size
- System.setProperty("AsyncLoggerConfig.RingBufferSize", "128"); // minimum ringbuffer size
- }
-
@AfterAll
public static void afterClass() {
- System.clearProperty("AsyncLogger.RingBufferSize");
- System.clearProperty("AsyncLoggerConfig.RingBufferSize");
System.clearProperty(LoggingSystemProperties.THREAD_CONTEXT_GARBAGE_FREE_ENABLED);
System.clearProperty(LoggingSystemProperties.THREAD_CONTEXT_MAP_CLASS);
}
@@ -94,8 +89,8 @@ public class AsyncThreadContextTest {
void init() {
System.clearProperty(LoggingSystemProperties.THREAD_CONTEXT_MAP_CLASS);
final String PACKAGE = "org.apache.logging.log4j.spi.";
- System.setProperty("log4j2.threadContextMap", PACKAGE + implClassSimpleName());
- ((PropertiesUtil) PropertiesUtil.getProperties()).reload();
+ System.setProperty(LoggingSystemProperties.THREAD_CONTEXT_MAP_CLASS, PACKAGE + implClassSimpleName());
+ PropertiesUtil.getProperties().reload();
ThreadContextTestAccess.init();
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncWaitStrategyFactoryConfigGlobalLoggersTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncWaitStrategyFactoryConfigGlobalLoggersTest.java
index 708d8cad7f..499f395b57 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncWaitStrategyFactoryConfigGlobalLoggersTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncWaitStrategyFactoryConfigGlobalLoggersTest.java
@@ -18,52 +18,37 @@ package org.apache.logging.log4j.core.async;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
-import org.apache.logging.log4j.core.util.Constants;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.apache.logging.log4j.core.test.junit.ContextSelectorType;
+import org.apache.logging.log4j.core.test.junit.LoggerContextSource;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import com.lmax.disruptor.YieldingWaitStrategy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-@Category(AsyncLoggers.class)
+@Tag("async")
+@ContextSelectorType(AsyncLoggerContextSelector.class)
+@LoggerContextSource("AsyncWaitStrategyFactoryConfigGlobalLoggerTest.xml")
public class AsyncWaitStrategyFactoryConfigGlobalLoggersTest {
- @BeforeClass
- public static void beforeClass() {
- System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR,
- AsyncLoggerContextSelector.class.getName());
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
- "AsyncWaitStrategyFactoryConfigGlobalLoggerTest.xml");
- }
-
- @AfterClass
- public static void afterClass() {
- System.clearProperty(Constants.LOG4J_CONTEXT_SELECTOR);
- System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
- }
-
- @Ignore("This test succeeds when run individually but fails when run by Surefire with all other tests")
+ @Disabled("This test succeeds when run individually but fails when run by Surefire with all other tests")
@Test
public void testConfigWaitStrategyAndFactory() throws Exception {
final AsyncLogger logger = (AsyncLogger) LogManager.getLogger("com.foo.Bar");
final LoggerContext context = (LoggerContext) LogManager.getContext(false);
- assertTrue("context is AsyncLoggerContext", context instanceof AsyncLoggerContext);
+ assertTrue(context instanceof AsyncLoggerContext, "context is AsyncLoggerContext");
AsyncWaitStrategyFactory asyncWaitStrategyFactory = context.getConfiguration().getAsyncWaitStrategyFactory();
assertEquals(AsyncWaitStrategyFactoryConfigTest.YieldingWaitStrategyFactory.class, asyncWaitStrategyFactory.getClass());
- assertTrue("factory is YieldingWaitStrategyFactory", asyncWaitStrategyFactory instanceof AsyncWaitStrategyFactoryConfigTest.YieldingWaitStrategyFactory);
+ assertTrue(asyncWaitStrategyFactory instanceof AsyncWaitStrategyFactoryConfigTest.YieldingWaitStrategyFactory, "factory is YieldingWaitStrategyFactory");
AsyncLoggerDisruptor delegate = logger.getAsyncLoggerDisruptor();
assertEquals(YieldingWaitStrategy.class, delegate.getWaitStrategy().getClass());
- assertTrue("waitstrategy is YieldingWaitStrategy", delegate.getWaitStrategy() instanceof YieldingWaitStrategy);
+ assertTrue(delegate.getWaitStrategy() instanceof YieldingWaitStrategy, "waitstrategy is YieldingWaitStrategy");
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncWaitStrategyFactoryIncorrectConfigGlobalLoggersTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncWaitStrategyFactoryIncorrectConfigGlobalLoggersTest.java
index 517e608031..1106c56330 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncWaitStrategyFactoryIncorrectConfigGlobalLoggersTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/AsyncWaitStrategyFactoryIncorrectConfigGlobalLoggersTest.java
@@ -18,31 +18,19 @@ package org.apache.logging.log4j.core.async;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.test.junit.ContextSelectorType;
-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("async")
@ContextSelectorType(AsyncLoggerContextSelector.class)
+@SetSystemProperty(key = Log4jProperties.CONFIG_LOCATION, value = "AsyncWaitStrategyIncorrectFactoryConfigGlobalLoggerTest.xml")
public class AsyncWaitStrategyFactoryIncorrectConfigGlobalLoggersTest {
- @BeforeAll
- public static void beforeClass() {
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
- "AsyncWaitStrategyIncorrectFactoryConfigGlobalLoggerTest.xml");
- }
-
- @AfterAll
- public static void afterClass() {
- System.clearProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
- }
-
-
@Test
public void testIncorrectConfigWaitStrategyFactory() throws Exception {
final LoggerContext context = (LoggerContext) LogManager.getContext(false);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/DefaultAsyncQueueFullPolicyTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/DefaultAsyncQueueFullPolicyTest.java
index 05e02b2f2d..cc65c1fef3 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/DefaultAsyncQueueFullPolicyTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/DefaultAsyncQueueFullPolicyTest.java
@@ -17,16 +17,15 @@
package org.apache.logging.log4j.core.async;
import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Tests the DefaultAsyncQueueFullPolicy class.
*/
-@Category(AsyncLoggers.class)
+@Tag("async")
public class DefaultAsyncQueueFullPolicyTest {
private static long currentThreadId() {
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/Log4j2Jira1688AsyncTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/Log4j2Jira1688AsyncTest.java
index b5734ea401..44edc4a549 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/Log4j2Jira1688AsyncTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/Log4j2Jira1688AsyncTest.java
@@ -21,16 +21,12 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
+import org.apache.logging.log4j.core.test.appender.ListAppender;
import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.util.Constants;
import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
import org.apache.logging.log4j.spi.ExtendedLogger;
-import org.apache.logging.log4j.core.test.appender.ListAppender;
-import org.apache.logging.log4j.util.Strings;
import org.junit.AfterClass;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
@@ -39,6 +35,8 @@ import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.BlockJUnit4ClassRunner;
+import static org.junit.Assert.assertArrayEquals;
+
/**
* Tests LOG4J2-1688 Multiple loggings of arguments are setting these arguments to null.
*/
@@ -48,15 +46,13 @@ public class Log4j2Jira1688AsyncTest {
@BeforeClass
public static void beforeClass() {
- System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR,
+ System.setProperty(Log4jProperties.CONTEXT_SELECTOR_CLASS_NAME,
AsyncLoggerContextSelector.class.getName());
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
- "log4j-list.xml");
}
@AfterClass
public static void afterClass() {
- System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, Strings.EMPTY);
+ System.clearProperty(Log4jProperties.CONTEXT_SELECTOR_CLASS_NAME);
}
@Rule
@@ -78,19 +74,19 @@ public class Log4j2Jira1688AsyncTest {
@Test
public void testLog4j2Only() throws InterruptedException {
- final org.apache.logging.log4j.Logger log4JLogger = LogManager.getLogger(this.getClass());
+ final ExtendedLogger log4JLogger = context.getLogger(this.getClass());
final int limit = 11; // more than unrolled varargs
final Object[] args = createArray(limit);
final Object[] originalArgs = Arrays.copyOf(args, args.length);
listAppender.countDownLatch = new CountDownLatch(1);
- ((ExtendedLogger)log4JLogger).logIfEnabled("test", Level.ERROR, null, "test {}", args);
+ log4JLogger.logIfEnabled("test", Level.ERROR, null, "test {}", args);
listAppender.countDownLatch.await(1, TimeUnit.SECONDS);
- Assert.assertArrayEquals(Arrays.toString(args), originalArgs, args);
+ assertArrayEquals(Arrays.toString(args), originalArgs, args);
- ((ExtendedLogger)log4JLogger).logIfEnabled("test", Level.ERROR, null, "test {}", args);
- Assert.assertArrayEquals(Arrays.toString(args), originalArgs, args);
+ log4JLogger.logIfEnabled("test", Level.ERROR, null, "test {}", args);
+ assertArrayEquals(Arrays.toString(args), originalArgs, args);
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/Log4j2Jira1688Test.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/Log4j2Jira1688Test.java
index 499e40cf7f..8938b20f1c 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/Log4j2Jira1688Test.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/Log4j2Jira1688Test.java
@@ -21,18 +21,12 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.core.test.appender.ListAppender;
import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.util.Constants;
import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
import org.apache.logging.log4j.spi.ExtendedLogger;
-import org.apache.logging.log4j.core.test.appender.ListAppender;
-import org.apache.logging.log4j.util.Strings;
-import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
-import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -46,17 +40,6 @@ import org.junit.runners.BlockJUnit4ClassRunner;
@Category(AsyncLoggers.class)
public class Log4j2Jira1688Test {
- @BeforeClass
- public static void beforeClass() {
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
- "log4j-list.xml");
- }
-
- @AfterClass
- public static void afterClass() {
- System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, Strings.EMPTY);
- }
-
@Rule
public LoggerContextRule context = new LoggerContextRule("log4j-list.xml");
private ListAppender listAppender;
@@ -76,18 +59,18 @@ public class Log4j2Jira1688Test {
@Test
public void testLog4j2Only() throws InterruptedException {
- final org.apache.logging.log4j.Logger log4JLogger = LogManager.getLogger(this.getClass());
+ final ExtendedLogger log4JLogger = context.getLogger(this.getClass());
final int limit = 11; // more than unrolled varargs
final Object[] args = createArray(limit);
final Object[] originalArgs = Arrays.copyOf(args, args.length);
listAppender.countDownLatch = new CountDownLatch(1);
- ((ExtendedLogger)log4JLogger).logIfEnabled("test", Level.ERROR, null, "test {}", args);
+ log4JLogger.logIfEnabled("test", Level.ERROR, null, "test {}", args);
listAppender.countDownLatch.await(1, TimeUnit.SECONDS);
Assert.assertArrayEquals(Arrays.toString(args), originalArgs, args);
- ((ExtendedLogger)log4JLogger).logIfEnabled("test", Level.ERROR, null, "test {}", args);
+ log4JLogger.logIfEnabled("test", Level.ERROR, null, "test {}", args);
Assert.assertArrayEquals(Arrays.toString(args), originalArgs, args);
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncAppenderTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncAppenderTest.java
index a1c877befc..ebaaa83188 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncAppenderTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncAppenderTest.java
@@ -21,8 +21,8 @@ import java.util.concurrent.CountDownLatch;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.junit.Before;
@@ -42,12 +42,6 @@ import static org.junit.Assert.*;
@Category(AsyncLoggers.class)
public class QueueFullAsyncAppenderTest extends QueueFullAbstractTest {
- @BeforeClass
- public static void beforeClass() {
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
- "log4j2-queueFullAsyncAppender.xml");
- }
-
@Rule
public LoggerContextRule context = new LoggerContextRule(
"log4j2-queueFullAsyncAppender.xml");
@@ -59,8 +53,8 @@ public class QueueFullAsyncAppenderTest extends QueueFullAbstractTest {
@Test(timeout = 5000)
- public void testNormalQueueFullKeepsMessagesInOrder() throws InterruptedException {
- final Logger logger = LogManager.getLogger(this.getClass());
+ public void testNormalQueueFullKeepsMessagesInOrder() {
+ final Logger logger = context.getLogger(this.getClass());
blockingAppender.countDownLatch = new CountDownLatch(1);
unlocker = new Unlocker(new CountDownLatch(129));
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncAppenderTest2.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncAppenderTest2.java
index 489f1f6d2b..b6769cf3d1 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncAppenderTest2.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncAppenderTest2.java
@@ -18,11 +18,11 @@ package org.apache.logging.log4j.core.async;
import java.util.concurrent.CountDownLatch;
-import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
+import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
@@ -40,11 +40,12 @@ public class QueueFullAsyncAppenderTest2 extends QueueFullAbstractTest {
@BeforeClass
public static void beforeClass() {
- //FORMAT_MESSAGES_IN_BACKGROUND
- System.setProperty("log4j.format.msg.async", "true");
+ System.setProperty(Log4jProperties.ASYNC_LOGGER_FORMAT_MESSAGES_IN_BACKGROUND, "true");
+ }
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
- "log4j2-queueFullAsyncAppender.xml");
+ @AfterClass
+ public static void afterClass() throws Exception {
+ System.clearProperty(Log4jProperties.ASYNC_LOGGER_FORMAT_MESSAGES_IN_BACKGROUND);
}
@Rule
@@ -58,8 +59,8 @@ public class QueueFullAsyncAppenderTest2 extends QueueFullAbstractTest {
@Test(timeout = 5000)
- public void testNormalQueueFullKeepsMessagesInOrder() throws InterruptedException {
- final Logger logger = LogManager.getLogger(this.getClass());
+ public void testNormalQueueFullKeepsMessagesInOrder() {
+ final Logger logger = context.getLogger(this.getClass());
blockingAppender.countDownLatch = new CountDownLatch(1);
unlocker = new Unlocker(new CountDownLatch(129));
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerConfigLoggingFromToStringTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerConfigLoggingFromToStringTest.java
index 22562e57a0..17b5081b33 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerConfigLoggingFromToStringTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerConfigLoggingFromToStringTest.java
@@ -16,9 +16,14 @@
*/
package org.apache.logging.log4j.core.async;
+import java.util.List;
+import java.util.Stack;
+import java.util.concurrent.CountDownLatch;
+
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.test.junit.LoggerContextSource;
import org.apache.logging.log4j.plugins.Named;
import org.apache.logging.log4j.status.StatusData;
@@ -28,10 +33,7 @@ import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.OS;
-
-import java.util.List;
-import java.util.Stack;
-import java.util.concurrent.CountDownLatch;
+import org.junitpioneer.jupiter.SetSystemProperty;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.StringContains.containsString;
@@ -43,13 +45,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
*/
@Tag("async")
@DisabledOnOs(value = OS.WINDOWS, disabledReason = "https://issues.apache.org/jira/browse/LOG4J2-3513")
+@SetSystemProperty(key = Log4jProperties.ASYNC_CONFIG_RING_BUFFER_SIZE, value = "128")
public class QueueFullAsyncLoggerConfigLoggingFromToStringTest extends QueueFullAbstractTest {
- @BeforeAll
- public static void beforeClass() {
- System.setProperty("AsyncLoggerConfig.RingBufferSize", "128");
- }
-
@Test
@LoggerContextSource(value = "log4j2-queueFullAsyncLoggerConfig.xml", timeout = 5)
public void testLoggingFromToStringCausesOutOfOrderMessages(
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerConfigLoggingFromToStringTest2.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerConfigLoggingFromToStringTest2.java
index e84c758727..cb11e263e7 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerConfigLoggingFromToStringTest2.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerConfigLoggingFromToStringTest2.java
@@ -16,11 +16,13 @@
*/
package org.apache.logging.log4j.core.async;
-import org.apache.logging.log4j.LogManager;
+import java.util.concurrent.CountDownLatch;
+
import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
+import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
@@ -29,8 +31,6 @@ import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.BlockJUnit4ClassRunner;
-import java.util.concurrent.CountDownLatch;
-
/**
* Tests queue full scenarios with AsyncLoggers in configuration.
*/
@@ -40,11 +40,14 @@ public class QueueFullAsyncLoggerConfigLoggingFromToStringTest2 extends QueueFul
@BeforeClass
public static void beforeClass() {
- //FORMAT_MESSAGES_IN_BACKGROUND
- System.setProperty("log4j.format.msg.async", "true");
- System.setProperty("AsyncLoggerConfig.RingBufferSize", "128");
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
- "log4j2-queueFullAsyncLoggerConfig.xml");
+ System.setProperty(Log4jProperties.ASYNC_LOGGER_FORMAT_MESSAGES_IN_BACKGROUND, "true");
+ System.setProperty(Log4jProperties.ASYNC_CONFIG_RING_BUFFER_SIZE, "128");
+ }
+
+ @AfterClass
+ public static void afterClass() throws Exception {
+ System.clearProperty(Log4jProperties.ASYNC_LOGGER_FORMAT_MESSAGES_IN_BACKGROUND);
+ System.clearProperty(Log4jProperties.ASYNC_CONFIG_RING_BUFFER_SIZE);
}
@Rule
@@ -57,9 +60,9 @@ public class QueueFullAsyncLoggerConfigLoggingFromToStringTest2 extends QueueFul
}
@Test(timeout = 5000)
- public void testLoggingFromToStringCausesOutOfOrderMessages() throws InterruptedException {
+ public void testLoggingFromToStringCausesOutOfOrderMessages() {
//TRACE = true;
- final Logger logger = LogManager.getLogger(this.getClass());
+ final Logger logger = context.getLogger(this.getClass());
blockingAppender.countDownLatch = new CountDownLatch(1);
unlocker = new Unlocker(new CountDownLatch(129)); // count slightly different from "pure" async loggers
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerConfigTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerConfigTest.java
index bfcbca6276..86c40b346d 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerConfigTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerConfigTest.java
@@ -19,12 +19,12 @@ package org.apache.logging.log4j.core.async;
import java.util.Stack;
import java.util.concurrent.CountDownLatch;
-import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
import org.apache.logging.log4j.message.ParameterizedMessage;
+import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
@@ -33,7 +33,8 @@ import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.BlockJUnit4ClassRunner;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
/**
* Tests queue full scenarios with AsyncLoggers in configuration.
@@ -44,9 +45,12 @@ public class QueueFullAsyncLoggerConfigTest extends QueueFullAbstractTest {
@BeforeClass
public static void beforeClass() {
- System.setProperty("AsyncLoggerConfig.RingBufferSize", "128"); // minimum ringbuffer size
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
- "log4j2-queueFullAsyncLoggerConfig.xml");
+ System.setProperty(Log4jProperties.ASYNC_CONFIG_RING_BUFFER_SIZE, "128"); // minimum ringbuffer size
+ }
+
+ @AfterClass
+ public static void afterClass() throws Exception {
+ System.clearProperty(Log4jProperties.ASYNC_CONFIG_RING_BUFFER_SIZE);
}
@Rule
@@ -61,7 +65,7 @@ public class QueueFullAsyncLoggerConfigTest extends QueueFullAbstractTest {
@Test(timeout = 5000)
public void testNormalQueueFullKeepsMessagesInOrder() throws InterruptedException {
- final Logger logger = LogManager.getLogger(this.getClass());
+ final Logger logger = context.getLogger(this.getClass());
blockingAppender.countDownLatch = new CountDownLatch(1);
unlocker = new Unlocker(new CountDownLatch(129));
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerConfigTest2.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerConfigTest2.java
index 871ef9f4ec..38c79a8481 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerConfigTest2.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerConfigTest2.java
@@ -18,11 +18,11 @@ package org.apache.logging.log4j.core.async;
import java.util.concurrent.CountDownLatch;
-import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
+import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
@@ -40,12 +40,14 @@ public class QueueFullAsyncLoggerConfigTest2 extends QueueFullAbstractTest {
@BeforeClass
public static void beforeClass() {
- //FORMAT_MESSAGES_IN_BACKGROUND
- System.setProperty("log4j.format.msg.async", "true");
+ System.setProperty(Log4jProperties.ASYNC_LOGGER_FORMAT_MESSAGES_IN_BACKGROUND, "true");
+ System.setProperty(Log4jProperties.ASYNC_CONFIG_RING_BUFFER_SIZE, "128"); // minimum ringbuffer size
+ }
- System.setProperty("AsyncLoggerConfig.RingBufferSize", "128"); // minimum ringbuffer size
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
- "log4j2-queueFullAsyncLoggerConfig.xml");
+ @AfterClass
+ public static void afterClass() throws Exception {
+ System.clearProperty(Log4jProperties.ASYNC_LOGGER_FORMAT_MESSAGES_IN_BACKGROUND);
+ System.clearProperty(Log4jProperties.ASYNC_CONFIG_RING_BUFFER_SIZE);
}
@Rule
@@ -59,8 +61,8 @@ public class QueueFullAsyncLoggerConfigTest2 extends QueueFullAbstractTest {
@Test(timeout = 5000)
- public void testNormalQueueFullKeepsMessagesInOrder() throws InterruptedException {
- final Logger logger = LogManager.getLogger(this.getClass());
+ public void testNormalQueueFullKeepsMessagesInOrder() {
+ final Logger logger = context.getLogger(this.getClass());
blockingAppender.countDownLatch = new CountDownLatch(1);
unlocker = new Unlocker(new CountDownLatch(129));
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerLoggingFromToStringTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerLoggingFromToStringTest.java
index ceb6044b01..f803f6fe9b 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerLoggingFromToStringTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerLoggingFromToStringTest.java
@@ -19,15 +19,12 @@ package org.apache.logging.log4j.core.async;
import java.util.Stack;
import java.util.concurrent.CountDownLatch;
-import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.util.Constants;
+import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
import org.apache.logging.log4j.message.ParameterizedMessage;
-import org.apache.logging.log4j.util.Strings;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -37,7 +34,8 @@ import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.BlockJUnit4ClassRunner;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
/**
* Tests queue full scenarios with pure AsyncLoggers (all loggers async).
@@ -48,14 +46,12 @@ public class QueueFullAsyncLoggerLoggingFromToStringTest extends QueueFullAbstra
@BeforeClass
public static void beforeClass() {
- System.setProperty("AsyncLogger.RingBufferSize", "128"); // minimum ringbuffer size
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
- "log4j2-queueFull.xml");
+ System.setProperty(Log4jProperties.ASYNC_LOGGER_RING_BUFFER_SIZE, "128"); // minimum ringbuffer size
}
@AfterClass
public static void afterClass() {
- System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, Strings.EMPTY);
+ System.clearProperty(Log4jProperties.ASYNC_LOGGER_RING_BUFFER_SIZE);
}
@Rule
@@ -68,8 +64,8 @@ public class QueueFullAsyncLoggerLoggingFromToStringTest extends QueueFullAbstra
}
@Test(timeout = 50000)
- public void testLoggingFromToStringCausesOutOfOrderMessages() throws InterruptedException {
- final Logger logger = LogManager.getLogger(this.getClass());
+ public void testLoggingFromToStringCausesOutOfOrderMessages() {
+ final Logger logger = context.getLogger(this.getClass());
blockingAppender.countDownLatch = new CountDownLatch(1);
unlocker = new Unlocker(new CountDownLatch(129));
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerLoggingFromToStringTest2.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerLoggingFromToStringTest2.java
index a55f231501..2302f0c995 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerLoggingFromToStringTest2.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerLoggingFromToStringTest2.java
@@ -19,15 +19,12 @@ package org.apache.logging.log4j.core.async;
import java.util.Stack;
import java.util.concurrent.CountDownLatch;
-import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.test.CoreLoggerContexts;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.util.Constants;
+import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
import org.apache.logging.log4j.message.ParameterizedMessage;
-import org.apache.logging.log4j.util.Strings;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -38,7 +35,8 @@ import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.BlockJUnit4ClassRunner;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
/**
* Tests queue full scenarios with pure AsyncLoggers (all loggers async).
@@ -50,17 +48,14 @@ public class QueueFullAsyncLoggerLoggingFromToStringTest2 extends QueueFullAbstr
@BeforeClass
public static void beforeClass() {
- //FORMAT_MESSAGES_IN_BACKGROUND
- System.setProperty("log4j.format.msg.async", "true");
-
- System.setProperty("AsyncLogger.RingBufferSize", "128"); // minimum ringbuffer size
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
- "log4j2-queueFull.xml");
+ System.setProperty(Log4jProperties.ASYNC_LOGGER_FORMAT_MESSAGES_IN_BACKGROUND, "true");
+ System.setProperty(Log4jProperties.ASYNC_LOGGER_RING_BUFFER_SIZE, "128"); // minimum ringbuffer size
}
@AfterClass
public static void afterClass() {
- System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, Strings.EMPTY);
+ System.clearProperty(Log4jProperties.ASYNC_LOGGER_FORMAT_MESSAGES_IN_BACKGROUND);
+ System.clearProperty(Log4jProperties.ASYNC_LOGGER_RING_BUFFER_SIZE);
}
@Rule
@@ -75,8 +70,8 @@ public class QueueFullAsyncLoggerLoggingFromToStringTest2 extends QueueFullAbstr
@Ignore
@Test(timeout = 5000)
- public void testLoggingFromToStringCausesOutOfOrderMessages() throws InterruptedException {
- final Logger logger = LogManager.getLogger(this.getClass());
+ public void testLoggingFromToStringCausesOutOfOrderMessages() {
+ final Logger logger = context.getLogger(this.getClass());
blockingAppender.countDownLatch = new CountDownLatch(1);
unlocker = new Unlocker(new CountDownLatch(129));
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerTest.java
index d6dac9a614..d09f72f3f3 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerTest.java
@@ -19,14 +19,11 @@ package org.apache.logging.log4j.core.async;
import java.util.Stack;
import java.util.concurrent.CountDownLatch;
-import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.util.Constants;
import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
import org.apache.logging.log4j.message.ParameterizedMessage;
-import org.apache.logging.log4j.util.Strings;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -36,7 +33,8 @@ import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.BlockJUnit4ClassRunner;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
/**
* Tests queue full scenarios with pure AsyncLoggers (all loggers async).
@@ -47,14 +45,12 @@ public class QueueFullAsyncLoggerTest extends QueueFullAbstractTest {
@BeforeClass
public static void beforeClass() {
- System.setProperty("AsyncLogger.RingBufferSize", "128"); // minimum ringbuffer size
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
- "log4j2-queueFull.xml");
+ System.setProperty(Log4jProperties.ASYNC_LOGGER_RING_BUFFER_SIZE, "128"); // minimum ringbuffer size
}
@AfterClass
public static void afterClass() {
- System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, Strings.EMPTY);
+ System.clearProperty(Log4jProperties.ASYNC_CONFIG_RING_BUFFER_SIZE);
}
@Rule
@@ -68,8 +64,8 @@ public class QueueFullAsyncLoggerTest extends QueueFullAbstractTest {
@Test(timeout = 5000)
- public void testNormalQueueFullKeepsMessagesInOrder() throws InterruptedException {
- final Logger logger = LogManager.getLogger(this.getClass());
+ public void testNormalQueueFullKeepsMessagesInOrder() {
+ final Logger logger = context.getLogger(this.getClass());
blockingAppender.countDownLatch = new CountDownLatch(1);
unlocker = new Unlocker(new CountDownLatch(129));
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerTest2.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerTest2.java
index 972a29347d..86ab23965a 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerTest2.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerTest2.java
@@ -18,13 +18,10 @@ package org.apache.logging.log4j.core.async;
import java.util.concurrent.CountDownLatch;
-import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.util.Constants;
import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
-import org.apache.logging.log4j.util.Strings;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -43,17 +40,14 @@ public class QueueFullAsyncLoggerTest2 extends QueueFullAbstractTest {
@BeforeClass
public static void beforeClass() {
- //FORMAT_MESSAGES_IN_BACKGROUND
- System.setProperty("log4j.format.msg.async", "true");
-
- System.setProperty("AsyncLogger.RingBufferSize", "128"); // minimum ringbuffer size
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
- "log4j2-queueFull.xml");
+ System.setProperty(Log4jProperties.ASYNC_LOGGER_FORMAT_MESSAGES_IN_BACKGROUND, "true");
+ System.setProperty(Log4jProperties.ASYNC_LOGGER_RING_BUFFER_SIZE, "128"); // minimum ringbuffer size
}
@AfterClass
public static void afterClass() {
- System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, Strings.EMPTY);
+ System.clearProperty(Log4jProperties.ASYNC_LOGGER_FORMAT_MESSAGES_IN_BACKGROUND);
+ System.clearProperty(Log4jProperties.ASYNC_CONFIG_RING_BUFFER_SIZE);
}
@Rule
@@ -67,8 +61,8 @@ public class QueueFullAsyncLoggerTest2 extends QueueFullAbstractTest {
@Test(timeout = 5000)
- public void testNormalQueueFullKeepsMessagesInOrder() throws InterruptedException {
- final Logger logger = LogManager.getLogger(this.getClass());
+ public void testNormalQueueFullKeepsMessagesInOrder() {
+ final Logger logger = context.getLogger(this.getClass());
blockingAppender.countDownLatch = new CountDownLatch(1);
unlocker = new Unlocker(new CountDownLatch(129));
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerTest3.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerTest3.java
index 5813bec3c3..baf7212a7a 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerTest3.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/QueueFullAsyncLoggerTest3.java
@@ -16,15 +16,15 @@
*/
package org.apache.logging.log4j.core.async;
-import org.apache.logging.log4j.LogManager;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
import org.apache.logging.log4j.core.GarbageCollectionHelper;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.util.Constants;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
+import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.util.Strings;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -34,9 +34,6 @@ import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.BlockJUnit4ClassRunner;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
import static org.junit.Assert.assertTrue;
/**
@@ -48,18 +45,16 @@ public class QueueFullAsyncLoggerTest3 extends QueueFullAbstractTest {
@BeforeClass
public static void beforeClass() {
- //FORMAT_MESSAGES_IN_BACKGROUND
- System.setProperty("log4j.format.msg.async", "true");
- System.setProperty("log4j2.asyncQueueFullPolicy", "discard");
-
- System.setProperty("AsyncLogger.RingBufferSize", "128"); // minimum ringbuffer size
- System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
- "log4j2-queueFull.xml");
+ System.setProperty(Log4jProperties.ASYNC_LOGGER_FORMAT_MESSAGES_IN_BACKGROUND, "true");
+ System.setProperty(Log4jProperties.ASYNC_LOGGER_QUEUE_FULL_POLICY, "discard");
+ System.setProperty(Log4jProperties.ASYNC_LOGGER_RING_BUFFER_SIZE, "128"); // minimum ringbuffer size
}
@AfterClass
public static void afterClass() {
- System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, Strings.EMPTY);
+ System.clearProperty(Log4jProperties.ASYNC_LOGGER_FORMAT_MESSAGES_IN_BACKGROUND);
+ System.clearProperty(Log4jProperties.ASYNC_LOGGER_QUEUE_FULL_POLICY);
+ System.clearProperty(Log4jProperties.ASYNC_LOGGER_RING_BUFFER_SIZE);
}
@Rule
@@ -74,7 +69,7 @@ public class QueueFullAsyncLoggerTest3 extends QueueFullAbstractTest {
@Test(timeout = 15000)
public void discardedMessagesShouldBeGarbageCollected() throws InterruptedException {
- final Logger logger = LogManager.getLogger(this.getClass());
+ final Logger logger = context.getLogger(this.getClass());
blockingAppender.logEvents = null;
blockingAppender.countDownLatch = new CountDownLatch(1);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/RingBufferLogEventTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/RingBufferLogEventTest.java
index 3dd4b068d6..2971d1ebb4 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/RingBufferLogEventTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/async/RingBufferLogEventTest.java
@@ -14,16 +14,21 @@
* See the license for the specific language governing permissions and
* limitations under the license.
*/
-
package org.apache.logging.log4j.core.async;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Arrays;
+
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.MarkerManager;
import org.apache.logging.log4j.ThreadContext.ContextStack;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.impl.ThrowableProxy;
-import org.apache.logging.log4j.core.test.categories.AsyncLoggers;
import org.apache.logging.log4j.core.time.internal.DummyNanoClock;
import org.apache.logging.log4j.core.time.internal.FixedPreciseClock;
import org.apache.logging.log4j.message.Message;
@@ -32,30 +37,23 @@ import org.apache.logging.log4j.message.SimpleMessage;
import org.apache.logging.log4j.spi.MutableThreadContextStack;
import org.apache.logging.log4j.util.FilteredObjectInputStream;
import org.apache.logging.log4j.util.StringMap;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.Arrays;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.sameInstance;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Tests the RingBufferLogEvent class.
*/
-@Category(AsyncLoggers.class)
+@Tag("async")
public class RingBufferLogEventTest {
@Test
public void testToImmutable() {
final LogEvent logEvent = new RingBufferLogEvent();
- Assert.assertNotSame(logEvent, logEvent.toImmutable());
+ assertNotSame(logEvent, logEvent.toImmutable());
}
/**
@@ -167,7 +165,7 @@ public class RingBufferLogEventTest {
assertEquals(fqcn, other.getLoggerFqcn());
assertEquals(level, other.getLevel());
assertEquals(data, other.getMessage());
- assertNull("null after serialization", other.getThrown());
+ assertNull(other.getThrown(), "null after serialization");
assertEquals(new ThrowableProxy(t), other.getThrownProxy());
assertEquals(evt.getContextData(), other.getContextData());
assertEquals(contextStack, other.getContextStack());
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/CompositeConfigurationMissingTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/CompositeConfigurationMissingTest.java
index 81e6b800dc..6522c79cf3 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/CompositeConfigurationMissingTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/CompositeConfigurationMissingTest.java
@@ -19,18 +19,16 @@ package org.apache.logging.log4j.core.config;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.LoggerContext;
-import org.junit.jupiter.api.BeforeAll;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.junit.jupiter.api.Test;
+import org.junitpioneer.jupiter.SetSystemProperty;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+@SetSystemProperty(key = Log4jProperties.CONFIG_LOCATION, value = "classpath:log4j-comp-logger-root.xml,log4j-does-not-exist.json")
public class CompositeConfigurationMissingTest {
- @BeforeAll
- public static void beforeClass() {
- System.setProperty("log4j2.configurationFile", "classpath:log4j-comp-logger-root.xml,log4j-does-not-exist.json");
- }
-
@Test
public void testMissingConfig() {
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/CustomConfigurationTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/CustomConfigurationTest.java
index d3a266564c..af36b0d36b 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/CustomConfigurationTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/CustomConfigurationTest.java
@@ -16,6 +16,12 @@
*/
package org.apache.logging.log4j.core.config;
+import java.io.IOException;
+import java.io.Serializable;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.Layout;
@@ -23,19 +29,13 @@ import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.appender.FileAppender;
import org.apache.logging.log4j.core.config.xml.XmlConfiguration;
import org.apache.logging.log4j.core.layout.PatternLayout;
-import org.apache.logging.log4j.test.junit.CleanUpFiles;
import org.apache.logging.log4j.core.test.junit.LoggerContextSource;
import org.apache.logging.log4j.status.StatusConsoleListener;
import org.apache.logging.log4j.status.StatusListener;
import org.apache.logging.log4j.status.StatusLogger;
-import org.junit.jupiter.api.BeforeAll;
+import org.apache.logging.log4j.test.junit.CleanUpFiles;
import org.junit.jupiter.api.Test;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
+import org.junitpioneer.jupiter.SetSystemProperty;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.greaterThan;
@@ -44,16 +44,12 @@ import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;
@CleanUpFiles("target/test.log")
+@SetSystemProperty(key = "log4j.level", value = "info")
+@SetSystemProperty(key = "log.level", value = "info")
public class CustomConfigurationTest {
public static final Path LOG_FILE = Paths.get("target", "test.log");
- @BeforeAll
- public static void before() {
- System.setProperty("log4j.level", "info");
- System.setProperty("log.level", "info");
- }
-
@Test
@LoggerContextSource("log4j-props.xml")
public void testConfig(final LoggerContext ctx) throws IOException {
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ReliabilityStrategyTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ReliabilityStrategyTest.java
index fc7f0a9e3e..e86e66306c 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ReliabilityStrategyTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/ReliabilityStrategyTest.java
@@ -14,30 +14,20 @@
* See the license for the specific language governing permissions and
* limitations under the license.
*/
-
package org.apache.logging.log4j.core.config;
import org.apache.logging.log4j.core.appender.AsyncAppender;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.test.junit.LoggerContextSource;
import org.apache.logging.log4j.core.test.junit.Named;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
+import org.junitpioneer.jupiter.SetSystemProperty;
import static org.junit.jupiter.api.Assertions.assertTrue;
+@SetSystemProperty(key = Log4jProperties.CONFIG_RELIABILITY_STRATEGY, value = "org.apache.logging.log4j.core.config.MockReliabilityStrategy")
class ReliabilityStrategyTest {
- @BeforeAll
- static void setUp() {
- System.setProperty("log4j2.reliabilityStrategy", MockReliabilityStrategy.class.getName());
- }
-
- @AfterAll
- static void tearDown() {
- System.clearProperty("log4j2.reliabilityStrategy");
- }
-
@Test
@LoggerContextSource("ReliabilityStrategyTest.xml")
void beforeStopAppendersCalledBeforeAsyncAppendersStopped(@Named final AsyncAppender async, final Configuration config) {
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/xml/XmlLoggerPropsTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/xml/XmlLoggerPropsTest.java
index 7dfe5508e5..3293fab936 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/xml/XmlLoggerPropsTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/config/xml/XmlLoggerPropsTest.java
@@ -16,31 +16,21 @@
*/
package org.apache.logging.log4j.core.config.xml;
+import java.util.List;
+
import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.test.appender.ListAppender;
import org.apache.logging.log4j.core.test.junit.LoggerContextSource;
import org.apache.logging.log4j.core.test.junit.Named;
-import org.apache.logging.log4j.core.test.appender.ListAppender;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
-
-import java.util.List;
+import org.junitpioneer.jupiter.SetSystemProperty;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
+@SetSystemProperty(key = "test", value = "test")
public class XmlLoggerPropsTest {
- @BeforeAll
- static void setupClass() {
- System.setProperty("test", "test");
- }
-
- @AfterAll
- static void tearDownClass() {
- System.clearProperty("test");
- }
-
@Test
@LoggerContextSource("log4j-loggerprops.xml")
public void testWithProps(final LoggerContext context, @Named("List") final ListAppender listAppender) {
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ContextDataFactoryPropertySetMissingConstructorTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ContextDataFactoryPropertySetMissingConstructorTest.java
index 6183b60607..e499c144b1 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ContextDataFactoryPropertySetMissingConstructorTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ContextDataFactoryPropertySetMissingConstructorTest.java
@@ -18,20 +18,21 @@ package org.apache.logging.log4j.core.impl;
import org.apache.logging.log4j.util.SortedArrayStringMap;
import org.junit.jupiter.api.Test;
+import org.junitpioneer.jupiter.SetSystemProperty;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests the ContextDataFactory class.
*/
+@SetSystemProperty(key = Log4jProperties.THREAD_CONTEXT_DATA_CLASS_NAME, value = "org.apache.logging.log4j.core.impl.FactoryTestStringMapWithoutIntConstructor")
public class ContextDataFactoryPropertySetMissingConstructorTest {
@Test
public void intArgReturnsSortedArrayStringMapIfPropertySpecifiedButMissingIntConstructor() throws Exception {
- System.setProperty("log4j2.ContextData", FactoryTestStringMapWithoutIntConstructor.class.getName());
assertTrue(ContextDataFactory.createContextData(2) instanceof SortedArrayStringMap);
final SortedArrayStringMap actual = (SortedArrayStringMap) ContextDataFactory.createContextData(2);
assertEquals(2, actual.getThreshold());
- System.clearProperty("log4j2.ContextData");
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ContextDataFactoryPropertySetTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ContextDataFactoryPropertySetTest.java
index ed5ce3ff9c..d706f30cf3 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ContextDataFactoryPropertySetTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/impl/ContextDataFactoryPropertySetTest.java
@@ -17,33 +17,30 @@
package org.apache.logging.log4j.core.impl;
import org.junit.jupiter.api.Test;
+import org.junitpioneer.jupiter.SetSystemProperty;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests the ContextDataFactory class.
*/
+@SetSystemProperty(key = Log4jProperties.THREAD_CONTEXT_DATA_CLASS_NAME, value = "org.apache.logging.log4j.core.impl.FactoryTestStringMap")
public class ContextDataFactoryPropertySetTest {
@Test
public void noArgReturnsSpecifiedImplIfPropertySpecified() throws Exception {
- System.setProperty("log4j2.ContextData", FactoryTestStringMap.class.getName());
assertTrue(ContextDataFactory.createContextData() instanceof FactoryTestStringMap);
- System.clearProperty("log4j2.ContextData");
}
@Test
public void intArgReturnsSpecifiedImplIfPropertySpecified() throws Exception {
- System.setProperty("log4j2.ContextData", FactoryTestStringMap.class.getName());
assertTrue(ContextDataFactory.createContextData(2) instanceof FactoryTestStringMap);
- System.clearProperty("log4j2.ContextData");
}
@Test
public void intArgSetsCapacityIfPropertySpecified() throws Exception {
- System.setProperty("log4j2.ContextData", FactoryTestStringMap.class.getName());
final FactoryTestStringMap actual = (FactoryTestStringMap) ContextDataFactory.createContextData(2);
assertEquals(2, actual.initialCapacity);
- System.clearProperty("log4j2.ContextData");
}
}
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/time/ClockFactoryTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/time/ClockFactoryTest.java
index 33db41d9e2..525d2b358f 100644
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/time/ClockFactoryTest.java
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/time/ClockFactoryTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.logging.log4j.core.time;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.time.internal.CachedClock;
import org.apache.logging.log4j.core.time.internal.CoarseCachedClock;
import org.apache.logging.log4j.core.time.internal.SystemClock;
@@ -40,42 +41,42 @@ public class ClockFactoryTest {
}
@Test
- @SetSystemProperty(key = "log4j.Clock", value = "SystemClock")
+ @SetSystemProperty(key = Log4jProperties.CONFIG_CLOCK, value = "SystemClock")
public void testSpecifySystemClockShort() {
injector.init();
assertThat(injector.getInstance(Clock.class)).isInstanceOf(SystemClock.class);
}
@Test
- @SetSystemProperty(key = "log4j.Clock", value = "org.apache.logging.log4j.core.time.internal.SystemClock")
+ @SetSystemProperty(key = Log4jProperties.CONFIG_CLOCK, value = "org.apache.logging.log4j.core.time.internal.SystemClock")
public void testSpecifySystemClockLong() {
injector.init();
assertThat(injector.getInstance(Clock.class)).isInstanceOf(SystemClock.class);
}
@Test
- @SetSystemProperty(key = "log4j.Clock", value = "CachedClock")
+ @SetSystemProperty(key = Log4jProperties.CONFIG_CLOCK, value = "CachedClock")
public void testSpecifyCachedClockShort() {
injector.init();
assertThat(injector.getInstance(Clock.class)).isInstanceOf(CachedClock.class);
}
@Test
- @SetSystemProperty(key = "log4j.Clock", value = "org.apache.logging.log4j.core.time.internal.CachedClock")
+ @SetSystemProperty(key = Log4jProperties.CONFIG_CLOCK, value = "org.apache.logging.log4j.core.time.internal.CachedClock")
public void testSpecifyCachedClockLong() {
injector.init();
assertThat(injector.getInstance(Clock.class)).isInstanceOf(CachedClock.class);
}
@Test
- @SetSystemProperty(key = "log4j.Clock", value = "CoarseCachedClock")
+ @SetSystemProperty(key = Log4jProperties.CONFIG_CLOCK, value = "CoarseCachedClock")
public void testSpecifyCoarseCachedClockShort() {
injector.init();
assertThat(injector.getInstance(Clock.class)).isInstanceOf(CoarseCachedClock.class);
}
@Test
- @SetSystemProperty(key = "log4j.Clock", value = "org.apache.logging.log4j.core.time.internal.CoarseCachedClock")
+ @SetSystemProperty(key = Log4jProperties.CONFIG_CLOCK, value = "org.apache.logging.log4j.core.time.internal.CoarseCachedClock")
public void testSpecifyCoarseCachedClockLong() {
injector.init();
assertThat(injector.getInstance(Clock.class)).isInstanceOf(CoarseCachedClock.class);
@@ -89,7 +90,7 @@ public class ClockFactoryTest {
}
@Test
- @SetSystemProperty(key = "log4j.Clock", value = "org.apache.logging.log4j.core.time.ClockFactoryTest$MyClock")
+ @SetSystemProperty(key = Log4jProperties.CONFIG_CLOCK, value = "org.apache.logging.log4j.core.time.ClockFactoryTest$MyClock")
public void testCustomClock() {
injector.init();
assertThat(injector.getInstance(Clock.class)).isInstanceOf(MyClock.class);
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
index 7ef54dab99..ae6e8312f0 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/LoggerContext.java
@@ -40,6 +40,7 @@ import org.apache.logging.log4j.core.config.ConfigurationSource;
import org.apache.logging.log4j.core.config.DefaultConfiguration;
import org.apache.logging.log4j.core.config.NullConfiguration;
import org.apache.logging.log4j.core.config.Reconfigurable;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.jmx.Server;
import org.apache.logging.log4j.core.util.Cancellable;
import org.apache.logging.log4j.core.util.ExecutorServices;
@@ -273,7 +274,7 @@ public class LoggerContext extends AbstractLifeCycle
@Override
public void start() {
LOGGER.debug("Starting {}...", this);
- if (PropertiesUtil.getProperties().getBooleanProperty("log4j.LoggerContext.stacktrace.on.start", false)) {
+ if (PropertiesUtil.getProperties().getBooleanProperty(Log4jProperties.LOGGER_CONTEXT_STACKTRACE_ON_START, false)) {
LOGGER.debug("Stack trace to locate invoker",
new Exception("Not a real error, showing stack trace to locate invoker"));
}
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java
index bdcebd9079..64b6ef487e 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ConsoleAppender.java
@@ -31,6 +31,7 @@ import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.Filter;
import org.apache.logging.log4j.core.Layout;
import org.apache.logging.log4j.core.config.Property;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.util.CloseShieldOutputStream;
import org.apache.logging.log4j.core.util.Loader;
import org.apache.logging.log4j.core.util.Throwables;
@@ -188,7 +189,7 @@ public final class ConsoleAppender extends AbstractOutputStreamAppender<OutputSt
throw new IllegalStateException("Unsupported default encoding " + enc, ex);
}
final PropertyEnvironment properties = PropertiesUtil.getProperties();
- if (!properties.isOsWindows() || properties.getBooleanProperty("log4j.skipJansi", true) || direct) {
+ if (!properties.isOsWindows() || properties.getBooleanProperty(Log4jProperties.JANSI_DISABLED, true) || direct) {
return outputStream;
}
try {
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigDisruptor.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigDisruptor.java
index 2bce8d0344..f40c90b8e8 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigDisruptor.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfigDisruptor.java
@@ -23,6 +23,7 @@ import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.AbstractLifeCycle;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.impl.Log4jLogEvent;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.impl.LogEventFactory;
import org.apache.logging.log4j.core.impl.MutableLogEvent;
import org.apache.logging.log4j.core.impl.ReusableLogEventFactory;
@@ -202,9 +203,9 @@ public class AsyncLoggerConfigDisruptor extends AbstractLifeCycle implements Asy
return;
}
LOGGER.trace("AsyncLoggerConfigDisruptor creating new disruptor for this configuration.");
- ringBufferSize = DisruptorUtil.calculateRingBufferSize("AsyncLoggerConfig.RingBufferSize");
+ ringBufferSize = DisruptorUtil.calculateRingBufferSize(Log4jProperties.ASYNC_CONFIG_RING_BUFFER_SIZE);
waitStrategy = DisruptorUtil.createWaitStrategy(
- "AsyncLoggerConfig.WaitStrategy", asyncWaitStrategyFactory);
+ Log4jProperties.ASYNC_CONFIG_WAIT_STRATEGY, asyncWaitStrategyFactory);
final ThreadFactory threadFactory = new Log4jThreadFactory("AsyncLoggerConfig", true, Thread.NORM_PRIORITY) {
@Override
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerContextSelector.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerContextSelector.java
index 80bc4ce46f..37f585e7e0 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerContextSelector.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerContextSelector.java
@@ -19,8 +19,8 @@ package org.apache.logging.log4j.core.async;
import java.net.URI;
import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.selector.ClassLoaderContextSelector;
-import org.apache.logging.log4j.core.util.Constants;
import org.apache.logging.log4j.plugins.Inject;
import org.apache.logging.log4j.plugins.Singleton;
import org.apache.logging.log4j.plugins.di.Injector;
@@ -43,7 +43,7 @@ public class AsyncLoggerContextSelector extends ClassLoaderContextSelector {
public static boolean isSelected() {
// FIXME(ms): this should check Injector bindings
return AsyncLoggerContextSelector.class.getName().equals(
- PropertiesUtil.getProperties().getStringProperty(Constants.LOG4J_CONTEXT_SELECTOR));
+ PropertiesUtil.getProperties().getStringProperty(Log4jProperties.CONTEXT_SELECTOR_CLASS_NAME));
}
@Inject
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerDisruptor.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerDisruptor.java
index a25ffd5acf..80ecc8e921 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerDisruptor.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerDisruptor.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.async;
import java.util.Objects;
@@ -22,22 +21,23 @@ import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;
-import com.lmax.disruptor.EventTranslatorVararg;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.core.AbstractLifeCycle;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.jmx.RingBufferAdmin;
import org.apache.logging.log4j.core.util.Log4jThread;
import org.apache.logging.log4j.core.util.Log4jThreadFactory;
import org.apache.logging.log4j.core.util.Throwables;
+import org.apache.logging.log4j.message.Message;
+import com.lmax.disruptor.EventTranslatorVararg;
import com.lmax.disruptor.ExceptionHandler;
import com.lmax.disruptor.RingBuffer;
import com.lmax.disruptor.TimeoutException;
import com.lmax.disruptor.WaitStrategy;
import com.lmax.disruptor.dsl.Disruptor;
import com.lmax.disruptor.dsl.ProducerType;
-import org.apache.logging.log4j.message.Message;
/**
* Helper class for async loggers: AsyncLoggerDisruptor handles the mechanics of working with the LMAX Disruptor, and
@@ -102,9 +102,9 @@ class AsyncLoggerDisruptor extends AbstractLifeCycle {
}
setStarting();
LOGGER.trace("[{}] AsyncLoggerDisruptor creating new disruptor for this context.", contextName);
- ringBufferSize = DisruptorUtil.calculateRingBufferSize("AsyncLogger.RingBufferSize");
+ ringBufferSize = DisruptorUtil.calculateRingBufferSize(Log4jProperties.ASYNC_LOGGER_RING_BUFFER_SIZE);
AsyncWaitStrategyFactory factory = waitStrategyFactorySupplier.get(); // get factory from configuration
- waitStrategy = DisruptorUtil.createWaitStrategy("AsyncLogger.WaitStrategy", factory);
+ waitStrategy = DisruptorUtil.createWaitStrategy(Log4jProperties.ASYNC_LOGGER_WAIT_STRATEGY, factory);
final ThreadFactory threadFactory = new Log4jThreadFactory("AsyncLogger[" + contextName + "]", true, Thread.NORM_PRIORITY) {
@Override
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncQueueFullPolicyFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncQueueFullPolicyFactory.java
index b73f4034b4..1e67bdb012 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncQueueFullPolicyFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncQueueFullPolicyFactory.java
@@ -18,6 +18,7 @@ package org.apache.logging.log4j.core.async;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.util.Loader;
import org.apache.logging.log4j.status.StatusLogger;
import org.apache.logging.log4j.util.PropertiesUtil;
@@ -28,12 +29,12 @@ import org.apache.logging.log4j.util.PropertyEnvironment;
* created by this factory is used in AsyncLogger, AsyncLoggerConfig and AsyncAppender
* to control if events are logged in the current thread, the background thread, or discarded.
* <p>
- * Property {@code "log4j2.AsyncQueueFullPolicy"} controls the routing behaviour. If this property is not specified or has
+ * Property {@value Log4jProperties#ASYNC_LOGGER_QUEUE_FULL_POLICY} controls the routing behaviour. If this property is not specified or has
* value {@code "Default"}, this factory creates {@link DefaultAsyncQueueFullPolicy} objects.
* </p> <p>
* If this property has value {@code "Discard"}, this factory creates {@link DiscardingAsyncQueueFullPolicy} objects.
* By default, this router discards events of level {@code INFO}, {@code DEBUG} and {@code TRACE} if the queue is full.
- * This can be adjusted with property {@code "log4j2.DiscardThreshold"} (name of the level at which to start
+ * This can be adjusted with property {@value Log4jProperties#ASYNC_LOGGER_DISCARD_THRESHOLD} (name of the level at which to start
* discarding).
* </p> <p>
* For any other value, this
@@ -44,10 +45,8 @@ import org.apache.logging.log4j.util.PropertyEnvironment;
* @since 2.6
*/
public class AsyncQueueFullPolicyFactory {
- static final String PROPERTY_NAME_ASYNC_EVENT_ROUTER = "log4j2.AsyncQueueFullPolicy";
static final String PROPERTY_VALUE_DEFAULT_ASYNC_EVENT_ROUTER = "Default";
static final String PROPERTY_VALUE_DISCARDING_ASYNC_EVENT_ROUTER = "Discard";
- static final String PROPERTY_NAME_DISCARDING_THRESHOLD_LEVEL = "log4j2.DiscardThreshold";
private static final Logger LOGGER = StatusLogger.getLogger();
@@ -66,7 +65,7 @@ public class AsyncQueueFullPolicyFactory {
* @return a new AsyncQueueFullPolicy
*/
public static AsyncQueueFullPolicy create() {
- final String router = PropertiesUtil.getProperties().getStringProperty(PROPERTY_NAME_ASYNC_EVENT_ROUTER);
+ final String router = PropertiesUtil.getProperties().getStringProperty(Log4jProperties.ASYNC_LOGGER_QUEUE_FULL_POLICY);
if (router == null || isRouterSelected(
router, DefaultAsyncQueueFullPolicy.class, PROPERTY_VALUE_DEFAULT_ASYNC_EVENT_ROUTER)) {
return new DefaultAsyncQueueFullPolicy();
@@ -101,7 +100,7 @@ public class AsyncQueueFullPolicyFactory {
private static AsyncQueueFullPolicy createDiscardingAsyncQueueFullPolicy() {
final PropertyEnvironment properties = PropertiesUtil.getProperties();
- final String level = properties.getStringProperty(PROPERTY_NAME_DISCARDING_THRESHOLD_LEVEL, Level.INFO.name());
+ final String level = properties.getStringProperty(Log4jProperties.ASYNC_LOGGER_DISCARD_THRESHOLD, Level.INFO.name());
final Level thresholdLevel = Level.toLevel(level, Level.INFO);
LOGGER.debug("Creating custom DiscardingAsyncQueueFullPolicy(discardThreshold:{})", thresholdLevel);
return new DiscardingAsyncQueueFullPolicy(thresholdLevel);
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/DisruptorUtil.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/DisruptorUtil.java
index 6de190aa6d..cf61a73683 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/DisruptorUtil.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/DisruptorUtil.java
@@ -20,6 +20,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.util.Integers;
import org.apache.logging.log4j.core.util.Loader;
import org.apache.logging.log4j.status.StatusLogger;
@@ -46,9 +47,9 @@ final class DisruptorUtil {
* CPU utilization is significantly reduced by restricting access to the enqueue operation.
*/
static final boolean ASYNC_LOGGER_SYNCHRONIZE_ENQUEUE_WHEN_QUEUE_FULL = PropertiesUtil.getProperties()
- .getBooleanProperty("AsyncLogger.SynchronizeEnqueueWhenQueueFull", true);
+ .getBooleanProperty(Log4jProperties.ASYNC_LOGGER_SYNCHRONIZE_ENQUEUE_WHEN_QUEUE_FULL, true);
static final boolean ASYNC_CONFIG_SYNCHRONIZE_ENQUEUE_WHEN_QUEUE_FULL = PropertiesUtil.getProperties()
- .getBooleanProperty("AsyncLoggerConfig.SynchronizeEnqueueWhenQueueFull", true);
+ .getBooleanProperty(Log4jProperties.ASYNC_CONFIG_SYNCHRONIZE_ENQUEUE_WHEN_QUEUE_FULL, true);
private DisruptorUtil() {
}
@@ -83,7 +84,7 @@ final class DisruptorUtil {
}
static ExceptionHandler<RingBufferLogEvent> getAsyncLoggerExceptionHandler() {
- final String cls = PropertiesUtil.getProperties().getStringProperty("AsyncLogger.ExceptionHandler");
+ final String cls = PropertiesUtil.getProperties().getStringProperty(Log4jProperties.ASYNC_LOGGER_EXCEPTION_HANDLER_CLASS_NAME);
if (cls == null) {
return new AsyncLoggerDefaultExceptionHandler();
}
@@ -92,14 +93,14 @@ final class DisruptorUtil {
final Class<? extends ExceptionHandler<RingBufferLogEvent>> klass =
(Class<? extends ExceptionHandler<RingBufferLogEvent>>) Loader.loadClass(cls);
return klass.newInstance();
- } catch (final Exception ignored) {
- LOGGER.debug("Invalid AsyncLogger.ExceptionHandler value: error creating {}: ", cls, ignored);
+ } catch (final Exception e) {
+ LOGGER.debug("Invalid {} value: error creating {}: ", Log4jProperties.ASYNC_LOGGER_EXCEPTION_HANDLER_CLASS_NAME, cls, e);
return new AsyncLoggerDefaultExceptionHandler();
}
}
static ExceptionHandler<AsyncLoggerConfigDisruptor.Log4jEventWrapper> getAsyncLoggerConfigExceptionHandler() {
- final String cls = PropertiesUtil.getProperties().getStringProperty("AsyncLoggerConfig.ExceptionHandler");
+ final String cls = PropertiesUtil.getProperties().getStringProperty(Log4jProperties.ASYNC_CONFIG_EXCEPTION_HANDLER_CLASS_NAME);
if (cls == null) {
return new AsyncLoggerConfigDefaultExceptionHandler();
}
@@ -108,8 +109,8 @@ final class DisruptorUtil {
final Class<? extends ExceptionHandler<AsyncLoggerConfigDisruptor.Log4jEventWrapper>> klass =
(Class<? extends ExceptionHandler<AsyncLoggerConfigDisruptor.Log4jEventWrapper>>) Loader.loadClass(cls);
return klass.newInstance();
- } catch (final Exception ignored) {
- LOGGER.debug("Invalid AsyncLoggerConfig.ExceptionHandler value: error creating {}: ", cls, ignored);
+ } catch (final Exception e) {
+ LOGGER.debug("Invalid {} value: error creating {}: ", Log4jProperties.ASYNC_CONFIG_EXCEPTION_HANDLER_CLASS_NAME, cls, e);
return new AsyncLoggerConfigDefaultExceptionHandler();
}
}
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/ThreadNameCachingStrategy.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/ThreadNameCachingStrategy.java
index c1aa2e67c8..636857f4f3 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/ThreadNameCachingStrategy.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/ThreadNameCachingStrategy.java
@@ -19,6 +19,7 @@ package org.apache.logging.log4j.core.async;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.status.StatusLogger;
import org.apache.logging.log4j.util.Constants;
import org.apache.logging.log4j.util.PropertiesUtil;
@@ -52,14 +53,14 @@ public enum ThreadNameCachingStrategy { // LOG4J2-467
abstract String getThreadName();
public static ThreadNameCachingStrategy create() {
- final String name = PropertiesUtil.getProperties().getStringProperty("AsyncLogger.ThreadNameStrategy");
+ final String name = PropertiesUtil.getProperties().getStringProperty(Log4jProperties.ASYNC_LOGGER_THREAD_NAME_STRATEGY);
try {
final ThreadNameCachingStrategy result = name != null ? ThreadNameCachingStrategy.valueOf(name) : DEFAULT_STRATEGY;
- LOGGER.debug("AsyncLogger.ThreadNameStrategy={} (user specified {}, default is {})",
+ LOGGER.debug("{}={} (user specified {}, default is {})", Log4jProperties.ASYNC_LOGGER_THREAD_NAME_STRATEGY,
result.name(), name, DEFAULT_STRATEGY.name());
return result;
} catch (final Exception ex) {
- LOGGER.debug("Using AsyncLogger.ThreadNameStrategy.{}: '{}' not valid: {}",
+ LOGGER.debug("Using {}.{}: '{}' not valid: {}", Log4jProperties.ASYNC_LOGGER_THREAD_NAME_STRATEGY,
DEFAULT_STRATEGY.name(), name, ex.toString());
return DEFAULT_STRATEGY;
}
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
index f82f7ad228..0f6766dcba 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java
@@ -54,6 +54,7 @@ import org.apache.logging.log4j.core.async.AsyncWaitStrategyFactoryConfig;
import org.apache.logging.log4j.core.config.arbiters.Arbiter;
import org.apache.logging.log4j.core.config.arbiters.SelectArbiter;
import org.apache.logging.log4j.core.filter.AbstractFilterable;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.layout.PatternLayout;
import org.apache.logging.log4j.core.lookup.ConfigurationStrSubstitutor;
import org.apache.logging.log4j.core.lookup.Interpolator;
@@ -753,7 +754,7 @@ public abstract class AbstractConfiguration extends AbstractFilterable implement
rootLoggerConfig.addAppender(appender, null, null);
final Level defaultLevel = Level.ERROR;
- final String levelName = PropertiesUtil.getProperties().getStringProperty(DefaultConfiguration.DEFAULT_LEVEL,
+ final String levelName = PropertiesUtil.getProperties().getStringProperty(Log4jProperties.CONFIG_DEFAULT_LEVEL,
defaultLevel.name());
final Level level = Level.valueOf(levelName);
rootLoggerConfig.setLevel(level != null ? level : defaultLevel);
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AwaitUnconditionallyReliabilityStrategy.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AwaitUnconditionallyReliabilityStrategy.java
index c84a3cbb79..abc5f59370 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AwaitUnconditionallyReliabilityStrategy.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AwaitUnconditionallyReliabilityStrategy.java
@@ -21,6 +21,7 @@ import java.util.Objects;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.message.Message;
import org.apache.logging.log4j.status.StatusLogger;
import org.apache.logging.log4j.util.PropertiesUtil;
@@ -40,7 +41,7 @@ public class AwaitUnconditionallyReliabilityStrategy implements ReliabilityStrat
}
private static long sleepMillis() {
- return PropertiesUtil.getProperties().getLongProperty("log4j.waitMillisBeforeStopOldConfig",
+ return PropertiesUtil.getProperties().getLongProperty(Log4jProperties.CONFIG_RELIABILITY_STRATEGY_AWAIT_UNCONDITIONALLY_MILLIS,
DEFAULT_SLEEP_MILLIS);
}
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 de5d143156..689e685550 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
@@ -21,6 +21,7 @@ import java.net.URI;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilderFactory;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.lookup.StrSubstitutor;
import org.apache.logging.log4j.core.util.AuthorizationProvider;
import org.apache.logging.log4j.core.util.BasicAuthorizationProvider;
@@ -63,16 +64,16 @@ public abstract class ConfigurationFactory extends ConfigurationBuilderFactory {
/**
* Allows the ConfigurationFactory class to be specified as a system property.
*/
- public static final String CONFIGURATION_FACTORY_PROPERTY = "log4j.configurationFactory";
+ public static final String CONFIGURATION_FACTORY_PROPERTY = Log4jProperties.CONFIG_CONFIGURATION_FACTORY_CLASS_NAME;
/**
* Allows the location of the configuration file to be specified as a system property.
*/
- public static final String CONFIGURATION_FILE_PROPERTY = "log4j.configurationFile";
+ public static final String CONFIGURATION_FILE_PROPERTY = Log4jProperties.CONFIG_LOCATION;
- public static final String LOG4J1_CONFIGURATION_FILE_PROPERTY = "log4j.configuration";
+ public static final String LOG4J1_CONFIGURATION_FILE_PROPERTY = Log4jProperties.CONFIG_V1_FILE_NAME;
- public static final String LOG4J1_EXPERIMENTAL = "log4j1.compatibility";
+ public static final String LOG4J1_EXPERIMENTAL = Log4jProperties.CONFIG_V1_COMPATIBILITY_ENABLED;
/**
* Plugin category used to inject a ConfigurationFactory {@link org.apache.logging.log4j.plugins.Plugin}
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/DefaultConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/DefaultConfiguration.java
index c300ccc551..ea315e49c0 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/DefaultConfiguration.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/DefaultConfiguration.java
@@ -16,6 +16,8 @@
*/
package org.apache.logging.log4j.core.config;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
+
/**
* The default configuration writes all output to the Console using the default logging level. You configure default
* logging level by setting the system property "org.apache.logging.log4j.level" to a level name. If you do not
@@ -32,7 +34,7 @@ public class DefaultConfiguration extends AbstractConfiguration {
/**
* The System Property used to specify the logging level.
*/
- public static final String DEFAULT_LEVEL = "org.apache.logging.log4j.level";
+ public static final String DEFAULT_LEVEL = Log4jProperties.CONFIG_DEFAULT_LEVEL;
/**
* The default Pattern used for the default Layout.
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 7e54fbae6f..c9577a2f49 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
@@ -27,6 +27,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.Log4jProperties;
import org.apache.logging.log4j.core.util.Loader;
import org.apache.logging.log4j.core.util.NetUtils;
import org.apache.logging.log4j.plugins.Inject;
@@ -293,7 +294,7 @@ public class DefaultConfigurationFactory extends ConfigurationFactory {
private static List<ConfigurationFactory> loadConfigurationFactories(final Injector injector) {
final List<ConfigurationFactory> factories = new ArrayList<>();
- Optional.ofNullable(PropertiesUtil.getProperties().getStringProperty(CONFIGURATION_FACTORY_PROPERTY))
+ Optional.ofNullable(PropertiesUtil.getProperties().getStringProperty(Log4jProperties.CONFIG_CONFIGURATION_FACTORY_CLASS_NAME))
.flatMap(DefaultConfigurationFactory::tryLoadFactoryClass)
.map(clazz -> {
try {
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ReliabilityStrategyFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ReliabilityStrategyFactory.java
index 019c6f2313..957f107e2c 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ReliabilityStrategyFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ReliabilityStrategyFactory.java
@@ -16,6 +16,7 @@
*/
package org.apache.logging.log4j.core.config;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.util.Loader;
import org.apache.logging.log4j.status.StatusLogger;
import org.apache.logging.log4j.util.PropertiesUtil;
@@ -45,7 +46,7 @@ public final class ReliabilityStrategyFactory {
*/
public static ReliabilityStrategy getReliabilityStrategy(final LoggerConfig loggerConfig) {
- final String strategy = PropertiesUtil.getProperties().getStringProperty("log4j.ReliabilityStrategy",
+ final String strategy = PropertiesUtil.getProperties().getStringProperty(Log4jProperties.CONFIG_RELIABILITY_STRATEGY,
"AwaitCompletion");
if ("AwaitCompletion".equals(strategy)) {
return new AwaitCompletionReliabilityStrategy(loggerConfig);
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/composite/CompositeConfiguration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/composite/CompositeConfiguration.java
index 536101d223..1b6f634a10 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/composite/CompositeConfiguration.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/composite/CompositeConfiguration.java
@@ -16,6 +16,12 @@
*/
package org.apache.logging.log4j.core.config.composite;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.config.AbstractConfiguration;
import org.apache.logging.log4j.core.config.Configuration;
@@ -30,22 +36,11 @@ import org.apache.logging.log4j.core.util.Watcher;
import org.apache.logging.log4j.plugins.Node;
import org.apache.logging.log4j.plugins.util.ResolverUtil;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-
/**
* A Composite Configuration.
*/
public class CompositeConfiguration extends AbstractConfiguration implements Reconfigurable {
- /**
- * Allow the ConfigurationFactory class to be specified as a system property.
- */
- public static final String MERGE_STRATEGY_PROPERTY = "log4j.mergeStrategy";
-
private static final String[] VERBOSE_CLASSES = new String[] {ResolverUtil.class.getName()};
private final List<? extends AbstractConfiguration> configurations;
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ContextDataFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ContextDataFactory.java
index cb745fff62..5676672ca8 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ContextDataFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ContextDataFactory.java
@@ -35,7 +35,8 @@ import org.apache.logging.log4j.util.StringMap;
* instances may be either populated with key-value pairs from the context, or completely replaced altogether.
* <p>
* By default returns {@code SortedArrayStringMap} objects. Can be configured by setting system property
- * {@code "log4j2.ContextData"} to the fully qualified class name of a class implementing the {@code StringMap}
+ * {@value Log4jProperties#THREAD_CONTEXT_DATA_CLASS_NAME}
+ * to the fully qualified class name of a class implementing the {@code StringMap}
* interface. The class must have a public default constructor, and if possible should also have a public constructor
* that takes a single {@code int} argument for the initial capacity.
* </p>
@@ -46,7 +47,7 @@ import org.apache.logging.log4j.util.StringMap;
* @since 2.7
*/
public class ContextDataFactory {
- private static final String CLASS_NAME = PropertiesUtil.getProperties().getStringProperty("log4j2.ContextData");
+ private static final String CLASS_NAME = PropertiesUtil.getProperties().getStringProperty(Log4jProperties.THREAD_CONTEXT_DATA_CLASS_NAME);
private static final Class<? extends StringMap> CACHED_CLASS = createCachedClass(CLASS_NAME);
/**
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ContextDataInjectorFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ContextDataInjectorFactory.java
index 74925f6cb9..2ff65023b6 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ContextDataInjectorFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ContextDataInjectorFactory.java
@@ -66,7 +66,7 @@ public class ContextDataInjectorFactory {
* @see ContextDataInjector
*/
public static ContextDataInjector createInjector() {
- final String className = PropertiesUtil.getProperties().getStringProperty("log4j2.ContextDataInjector");
+ final String className = PropertiesUtil.getProperties().getStringProperty(Log4jProperties.THREAD_CONTEXT_DATA_INJECTOR_CLASS_NAME);
if (className == null) {
return createDefaultInjector();
}
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/DefaultBundle.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/DefaultBundle.java
index dc7cc9e276..6e5f4f8168 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/DefaultBundle.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/DefaultBundle.java
@@ -25,7 +25,6 @@ import org.apache.logging.log4j.ThreadContext;
import org.apache.logging.log4j.core.ContextDataInjector;
import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.config.DefaultConfigurationFactory;
-import org.apache.logging.log4j.core.config.composite.CompositeConfiguration;
import org.apache.logging.log4j.core.config.composite.DefaultMergeStrategy;
import org.apache.logging.log4j.core.config.composite.MergeStrategy;
import org.apache.logging.log4j.core.lookup.Interpolator;
@@ -35,7 +34,6 @@ import org.apache.logging.log4j.core.lookup.StrSubstitutor;
import org.apache.logging.log4j.core.selector.ClassLoaderContextSelector;
import org.apache.logging.log4j.core.selector.ContextSelector;
import org.apache.logging.log4j.core.time.Clock;
-import org.apache.logging.log4j.core.time.ClockFactory;
import org.apache.logging.log4j.core.time.NanoClock;
import org.apache.logging.log4j.core.time.PreciseClock;
import org.apache.logging.log4j.core.time.internal.CachedClock;
@@ -43,7 +41,6 @@ import org.apache.logging.log4j.core.time.internal.CoarseCachedClock;
import org.apache.logging.log4j.core.time.internal.DummyNanoClock;
import org.apache.logging.log4j.core.time.internal.SystemClock;
import org.apache.logging.log4j.core.time.internal.SystemMillisClock;
-import org.apache.logging.log4j.core.util.Constants;
import org.apache.logging.log4j.core.util.DefaultShutdownCallbackRegistry;
import org.apache.logging.log4j.core.util.ShutdownCallbackRegistry;
import org.apache.logging.log4j.plugins.Factory;
@@ -66,7 +63,7 @@ import static org.apache.logging.log4j.util.Constants.isThreadLocalsEnabled;
/**
* Contains default bindings for Log4j including support for {@link PropertiesUtil}-based configuration.
*
- * @see Constants
+ * @see Log4jProperties
* @see ContextSelector
* @see ShutdownCallbackRegistry
* @see Clock
@@ -91,11 +88,11 @@ public class DefaultBundle {
this.classLoader = classLoader;
}
- @ConditionalOnProperty(name = Constants.LOG4J_CONTEXT_SELECTOR)
+ @ConditionalOnProperty(name = Log4jProperties.CONTEXT_SELECTOR_CLASS_NAME)
@SingletonFactory
@Ordered(100)
public ContextSelector systemPropertyContextSelector() throws ClassNotFoundException {
- return newInstanceOfProperty(Constants.LOG4J_CONTEXT_SELECTOR, ContextSelector.class);
+ return newInstanceOfProperty(Log4jProperties.CONTEXT_SELECTOR_CLASS_NAME, ContextSelector.class);
}
@SingletonFactory
@@ -103,11 +100,11 @@ public class DefaultBundle {
return new ClassLoaderContextSelector(injector);
}
- @ConditionalOnProperty(name = ShutdownCallbackRegistry.SHUTDOWN_CALLBACK_REGISTRY)
+ @ConditionalOnProperty(name = Log4jProperties.SHUTDOWN_CALLBACK_REGISTRY_CLASS_NAME)
@SingletonFactory
@Ordered(100)
public ShutdownCallbackRegistry systemPropertyShutdownCallbackRegistry() throws ClassNotFoundException {
- return newInstanceOfProperty(ShutdownCallbackRegistry.SHUTDOWN_CALLBACK_REGISTRY, ShutdownCallbackRegistry.class);
+ return newInstanceOfProperty(Log4jProperties.SHUTDOWN_CALLBACK_REGISTRY_CLASS_NAME, ShutdownCallbackRegistry.class);
}
@SingletonFactory
@@ -115,53 +112,53 @@ public class DefaultBundle {
return new DefaultShutdownCallbackRegistry();
}
- @ConditionalOnProperty(name = ClockFactory.PROPERTY_NAME, value = "SystemClock")
+ @ConditionalOnProperty(name = Log4jProperties.CONFIG_CLOCK, value = "SystemClock")
@SingletonFactory
@Ordered(200)
public Clock systemClock() {
return logSupportedPrecision(new SystemClock());
}
- @ConditionalOnProperty(name = ClockFactory.PROPERTY_NAME, value = "SystemMillisClock")
+ @ConditionalOnProperty(name = Log4jProperties.CONFIG_CLOCK, value = "SystemMillisClock")
@SingletonFactory
@Ordered(200)
public Clock systemMillisClock() {
return logSupportedPrecision(new SystemMillisClock());
}
- @ConditionalOnProperty(name = ClockFactory.PROPERTY_NAME, value = "CachedClock")
+ @ConditionalOnProperty(name = Log4jProperties.CONFIG_CLOCK, value = "CachedClock")
@SingletonFactory
@Ordered(200)
public Clock cachedClock() {
return logSupportedPrecision(CachedClock.instance());
}
- @ConditionalOnProperty(name = ClockFactory.PROPERTY_NAME, value = "org.apache.logging.log4j.core.time.internal.CachedClock")
+ @ConditionalOnProperty(name = Log4jProperties.CONFIG_CLOCK, value = "org.apache.logging.log4j.core.time.internal.CachedClock")
@SingletonFactory
@Ordered(200)
public Clock cachedClockFqcn() {
return logSupportedPrecision(CachedClock.instance());
}
- @ConditionalOnProperty(name = ClockFactory.PROPERTY_NAME, value = "CoarseCachedClock")
+ @ConditionalOnProperty(name = Log4jProperties.CONFIG_CLOCK, value = "CoarseCachedClock")
@SingletonFactory
@Ordered(200)
public Clock coarseCachedClock() {
return logSupportedPrecision(CoarseCachedClock.instance());
}
- @ConditionalOnProperty(name = ClockFactory.PROPERTY_NAME, value = "org.apache.logging.log4j.core.time.internal.CoarseCachedClock")
+ @ConditionalOnProperty(name = Log4jProperties.CONFIG_CLOCK, value = "org.apache.logging.log4j.core.time.internal.CoarseCachedClock")
@SingletonFactory
@Ordered(200)
public Clock coarseCachedClockFqcn() {
return logSupportedPrecision(CoarseCachedClock.instance());
}
- @ConditionalOnProperty(name = ClockFactory.PROPERTY_NAME)
+ @ConditionalOnProperty(name = Log4jProperties.CONFIG_CLOCK)
@SingletonFactory
@Ordered(100)
public Clock systemPropertyClock() throws ClassNotFoundException {
- return logSupportedPrecision(newInstanceOfProperty(ClockFactory.PROPERTY_NAME, Clock.class));
+ return logSupportedPrecision(newInstanceOfProperty(Log4jProperties.CONFIG_CLOCK, Clock.class));
}
@SingletonFactory
@@ -174,11 +171,11 @@ public class DefaultBundle {
return new DummyNanoClock();
}
- @ConditionalOnProperty(name = "log4j2.ContextDataInjector")
+ @ConditionalOnProperty(name = Log4jProperties.THREAD_CONTEXT_DATA_INJECTOR_CLASS_NAME)
@Factory
@Ordered(100)
public ContextDataInjector systemPropertyContextDataInjector() throws ClassNotFoundException {
- return newInstanceOfProperty("log4j2.ContextDataInjector", ContextDataInjector.class);
+ return newInstanceOfProperty(Log4jProperties.THREAD_CONTEXT_DATA_INJECTOR_CLASS_NAME, ContextDataInjector.class);
}
@Factory
@@ -196,11 +193,11 @@ public class DefaultBundle {
return new ThreadContextDataInjector.ForGarbageFreeThreadContextMap();
}
- @ConditionalOnProperty(name = Constants.LOG4J_LOG_EVENT_FACTORY)
+ @ConditionalOnProperty(name = Log4jProperties.LOG_EVENT_FACTORY_CLASS_NAME)
@SingletonFactory
@Ordered(100)
public LogEventFactory systemPropertyLogEventFactory() throws ClassNotFoundException {
- return newInstanceOfProperty(Constants.LOG4J_LOG_EVENT_FACTORY, LogEventFactory.class);
+ return newInstanceOfProperty(Log4jProperties.LOG_EVENT_FACTORY_CLASS_NAME, LogEventFactory.class);
}
@SingletonFactory
@@ -229,11 +226,11 @@ public class DefaultBundle {
return factory;
}
- @ConditionalOnProperty(name = CompositeConfiguration.MERGE_STRATEGY_PROPERTY)
+ @ConditionalOnProperty(name = Log4jProperties.CONFIG_MERGE_STRATEGY_CLASS_NAME)
@SingletonFactory
@Ordered(100)
public MergeStrategy systemPropertyMergeStrategy() throws ClassNotFoundException {
- return newInstanceOfProperty(CompositeConfiguration.MERGE_STRATEGY_PROPERTY, MergeStrategy.class);
+ return newInstanceOfProperty(Log4jProperties.CONFIG_MERGE_STRATEGY_CLASS_NAME, MergeStrategy.class);
}
@SingletonFactory
@@ -241,12 +238,12 @@ public class DefaultBundle {
return new DefaultMergeStrategy();
}
- @ConditionalOnProperty(name = Constants.LOG4J_DEFAULT_STATUS_LEVEL)
+ @ConditionalOnProperty(name = Log4jProperties.STATUS_DEFAULT_LEVEL)
@SingletonFactory
@Named("StatusLogger")
@Ordered(100)
public Level systemPropertyDefaultStatusLevel() {
- return Level.getLevel(properties.getStringProperty(Constants.LOG4J_DEFAULT_STATUS_LEVEL));
+ return Level.getLevel(properties.getStringProperty(Log4jProperties.STATUS_DEFAULT_LEVEL));
}
@SingletonFactory
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java
index 0ddf5047a3..41e071e095 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jContextFactory.java
@@ -394,6 +394,6 @@ public class Log4jContextFactory implements LoggerContextFactory, ShutdownCallba
public boolean isShutdownHookEnabled() {
return !isWebApp() && PropertiesUtil.getProperties()
- .getBooleanProperty(ShutdownCallbackRegistry.SHUTDOWN_HOOK_ENABLED, true);
+ .getBooleanProperty(Log4jProperties.SHUTDOWN_HOOK_ENABLED, true);
}
}
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jProperties.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jProperties.java
new file mode 100644
index 0000000000..62a2a710e7
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/Log4jProperties.java
@@ -0,0 +1,140 @@
+/*
+ * 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.core.impl;
+
+public class Log4jProperties {
+ // TODO: rename properties according to established theme in
+ // https://cwiki.apache.org/confluence/display/LOGGING/Properties+Enhancement
+
+ // LoggerContext.shutdownCallbackRegistry
+ public static final String SHUTDOWN_CALLBACK_REGISTRY_CLASS_NAME = "log4j2.shutdownCallbackRegistry";
+ // LoggerContext.shutdownHookEnabled
+ public static final String SHUTDOWN_HOOK_ENABLED = "log4j2.shutdownHookEnabled";
+
+ // LoggerContext.stacktraceOnStart
+ public static final String LOGGER_CONTEXT_STACKTRACE_ON_START = "log4j2.LoggerContext.stacktraceOnStart";
+
+ // Jansi.enabled
+ public static final String JANSI_DISABLED = "log4j2.skipJansi";
+
+ // LoggerContext.contextSelector
+ public static final String CONTEXT_SELECTOR_CLASS_NAME = "log4j2.contextSelector";
+
+ // LoggerContext.logEventFactory
+ public static final String LOG_EVENT_FACTORY_CLASS_NAME = "log4j2.logEventFactory";
+
+ // StatusLogger.defaultStatusLevel
+ public static final String STATUS_DEFAULT_LEVEL = "log4j2.defaultStatusLevel";
+
+ // Configuration.level
+ public static final String CONFIG_DEFAULT_LEVEL = "log4j2.level";
+ // Configuration.clock
+ public static final String CONFIG_CLOCK = "log4j2.clock";
+ // Configuration.mergeStrategy
+ public static final String CONFIG_MERGE_STRATEGY_CLASS_NAME = "log4j2.mergeStrategy";
+ // Configuration.reliabilityStrategy
+ public static final String CONFIG_RELIABILITY_STRATEGY = "log4j2.reliabilityStrategy";
+ // Configuration.reliabilityStrategyAwaitUnconditionallyMillis
+ public static final String CONFIG_RELIABILITY_STRATEGY_AWAIT_UNCONDITIONALLY_MILLIS = "log4j2.waitMillisBeforeStopOldConfig";
+ // Configuration.factory
+ public static final String CONFIG_CONFIGURATION_FACTORY_CLASS_NAME = "log4j2.configurationFactory";
+ // Configuration.location
+ public static final String CONFIG_LOCATION = "log4j2.configurationFile";
+ public static final String CONFIG_V1_FILE_NAME = "log4j.configuration";
+ public static final String CONFIG_V1_COMPATIBILITY_ENABLED = "log4j1.compatibility";
+
+ // AsyncLogger.formatMsgAsync
+ public static final String ASYNC_LOGGER_FORMAT_MESSAGES_IN_BACKGROUND = "log4j2.formatMsgAsync";
+ // AsyncLogger.queueFullPolicy
+ public static final String ASYNC_LOGGER_QUEUE_FULL_POLICY = "log4j2.asyncQueueFullPolicy";
+ // AsyncLogger.discardThreshold
+ public static final String ASYNC_LOGGER_DISCARD_THRESHOLD = "log4j2.discardThreshold";
+ // AsyncLogger.ringBufferSize
+ public static final String ASYNC_LOGGER_RING_BUFFER_SIZE = "log4j2.AsyncLogger.ringBufferSize";
+ // AsyncLogger.waitStrategy
+ public static final String ASYNC_LOGGER_WAIT_STRATEGY = "log4j2.AsyncLogger.waitStrategy";
+ // AsyncLogger.synchronizeEnqueueWhenQueueFull
+ public static final String ASYNC_LOGGER_SYNCHRONIZE_ENQUEUE_WHEN_QUEUE_FULL = "log4j2.AsyncLogger.synchronizeEnqueueWhenQueueFull";
+ // AsyncLogger.exceptionHandler
+ public static final String ASYNC_LOGGER_EXCEPTION_HANDLER_CLASS_NAME = "log4j2.AsyncLogger.exceptionHandler";
+ // AsyncLogger.threadNameStrategy
+ public static final String ASYNC_LOGGER_THREAD_NAME_STRATEGY = "log4j2.AsyncLogger.threadNameStrategy";
+ // AsyncLoggerConfig.ringBufferSize
+ public static final String ASYNC_CONFIG_RING_BUFFER_SIZE = "log4j2.AsyncLoggerConfig.ringBufferSize";
+ // AsyncLoggerConfig.waitStrategy
+ public static final String ASYNC_CONFIG_WAIT_STRATEGY = "log4j2.AsyncLoggerConfig.waitStrategy";
+ // AsyncLoggerConfig.synchronizeEnqueueWhenQueueFull
+ public static final String ASYNC_CONFIG_SYNCHRONIZE_ENQUEUE_WHEN_QUEUE_FULL = "log4j2.AsyncLoggerConfig.synchronizeEnqueueWhenQueueFull";
+ // AsyncLoggerConfig.exceptionHandler
+ public static final String ASYNC_CONFIG_EXCEPTION_HANDLER_CLASS_NAME = "log4j2.AsyncLoggerConfig.exceptionHandler";
+
+ // GC.enableDirectEncoders
+ public static final String GC_ENABLE_DIRECT_ENCODERS = "log4j2.enableDirectEncoders";
+ // GC.initialReusableMsgSize
+ public static final String GC_INITIAL_REUSABLE_MESSAGE_SIZE = "log4j2.initialReusableMsgSize";
+ // GC.encoderCharBufferSize
+ public static final String GC_ENCODER_CHAR_BUFFER_SIZE = "log4j2.encoderCharBufferSize";
+ // GC.encoderByteBufferSize
+ public static final String GC_ENCODER_BYTE_BUFFER_SIZE = "log4j2.encoderByteBufferSize";
+ // GC.layoutStringBuilderMaxSize
+ public static final String GC_LAYOUT_STRING_BUILDER_MAX_SIZE = "log4j2.layoutStringBuilderMaxSize";
+
+ // ThreadContext.contextData
+ public static final String THREAD_CONTEXT_DATA_CLASS_NAME = "log4j2.contextData";
+ // ThreadContext.contextDataInjector
+ public static final String THREAD_CONTEXT_DATA_INJECTOR_CLASS_NAME = "log4j2.contextDataInjector";
+
+ // JMX.enabled
+ public static final String JMX_DISABLED = "log4j2.disableJmx";
+ // JMX.notifyAsync
+ public static final String JMX_NOTIFY_ASYNC = "log4j2.jmxNotifyAsync";
+
+ // TransportSecurity.trustStore.location
+ public static final String TRANSPORT_SECURITY_TRUST_STORE_LOCATION = "log4j2.trustStoreLocation";
+ // TransportSecurity.trustStore.password
+ public static final String TRANSPORT_SECURITY_TRUST_STORE_PASSWORD = "log4j2.trustStorePassword";
+ // TransportSecurity.trustStore.passwordFile
+ public static final String TRANSPORT_SECURITY_TRUST_STORE_PASSWORD_FILE = "log4j2.trustStorePasswordFile";
+ // TransportSecurity.trustStore.passwordEnvironmentVariable
+ public static final String TRANSPORT_SECURITY_TRUST_STORE_PASSWORD_ENV_VAR = "log4j2.trustStorePasswordEnvironmentVariable";
+ // TransportSecurity.trustStore.keyStoreType
+ public static final String TRANSPORT_SECURITY_TRUST_STORE_KEY_STORE_TYPE = "log4j2.trustStoreKeyStoreType";
+ // TransportSecurity.trustStore.keyManagerFactoryAlgorithm
+ public static final String TRANSPORT_SECURITY_TRUST_STORE_KEY_MANAGER_FACTORY_ALGORITHM = "log4j2.trustStoreKeyManagerFactoryAlgorithm";
+ // TransportSecurity.keyStore.location
+ public static final String TRANSPORT_SECURITY_KEY_STORE_LOCATION = "log4j2.keyStoreLocation";
+ // TransportSecurity.keyStore.password
+ public static final String TRANSPORT_SECURITY_KEY_STORE_PASSWORD = "log4j2.keyStorePassword";
+ // TransportSecurity.keyStore.passwordFile
+ public static final String TRANSPORT_SECURITY_KEY_STORE_PASSWORD_FILE = "log4j2.keyStorePasswordFile";
+ // TransportSecurity.keyStore.passwordEnvironmentVariable
+ public static final String TRANSPORT_SECURITY_KEY_STORE_PASSWORD_ENV_VAR = "log4j2.keyStorePasswordEnvironmentVariable";
+ // TransportSecurity.keyStore.keyStoreType
+ public static final String TRANSPORT_SECURITY_KEY_STORE_TYPE = "log4j2.keyStoreType";
+ // TransportSecurity.keyStore.keyManagerFactoryAlgorithm
+ public static final String TRANSPORT_SECURITY_KEY_STORE_KEY_MANAGER_FACTORY_ALGORITHM = "log4j2.keyStoreKeyManagerFactoryAlgorithm";
+ // TransportSecurity.verifyHostName
+ public static final String TRANSPORT_SECURITY_VERIFY_HOST_NAME = "log4j2.sslVerifyHostName";
+
+ /**
+ * Property that may be used to seed the UUID generation with an integer value.
+ *
+ * @see org.apache.logging.log4j.core.util.UuidUtil
+ */
+ // UUID.sequence
+ public static final String UUID_SEQUENCE = "log4j2.uuidSequence";
+}
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/Server.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/Server.java
index 0c75ea03ba..5b782a921e 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/Server.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/jmx/Server.java
@@ -38,6 +38,7 @@ import org.apache.logging.log4j.core.async.AsyncLoggerConfig;
import org.apache.logging.log4j.core.async.AsyncLoggerContext;
import org.apache.logging.log4j.core.config.LoggerConfig;
import org.apache.logging.log4j.core.impl.Log4jContextFactory;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.selector.ContextSelector;
import org.apache.logging.log4j.core.util.Log4jThreadFactory;
import org.apache.logging.log4j.spi.LoggerContextFactory;
@@ -58,8 +59,6 @@ public final class Server {
* The domain part, or prefix ({@value}) of the {@code ObjectName} of all MBeans that instrument Log4J2 components.
*/
public static final String DOMAIN = "org.apache.logging.log4j2";
- private static final String PROPERTY_DISABLE_JMX = "log4j2.disable.jmx";
- private static final String PROPERTY_ASYNC_NOTIF = "log4j2.jmx.notify.async";
private static final String THREAD_NAME_PREFIX = "jmx.notif";
private static final StatusLogger LOGGER = StatusLogger.getLogger();
static final Executor executor = isJmxDisabled() ? null : createExecutor();
@@ -76,7 +75,7 @@ public final class Server {
*/
private static ExecutorService createExecutor() {
final boolean defaultAsync = !Constants.isWebApp();
- final boolean async = PropertiesUtil.getProperties().getBooleanProperty(PROPERTY_ASYNC_NOTIF, defaultAsync);
+ final boolean async = PropertiesUtil.getProperties().getBooleanProperty(Log4jProperties.JMX_NOTIFY_ASYNC, defaultAsync);
return async ? Executors.newFixedThreadPool(1, Log4jThreadFactory.createDaemonThreadFactory(THREAD_NAME_PREFIX))
: null;
}
@@ -127,7 +126,7 @@ public final class Server {
}
private static boolean isJmxDisabled() {
- return PropertiesUtil.getProperties().getBooleanProperty(PROPERTY_DISABLE_JMX);
+ return PropertiesUtil.getProperties().getBooleanProperty(Log4jProperties.JMX_DISABLED);
}
public static void reregisterMBeansAfterReconfigure() {
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
index 00a35f32c2..78c6bef1b3 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/AbstractStringLayout.java
@@ -24,6 +24,7 @@ import org.apache.logging.log4j.core.StringLayout;
import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.config.LoggerConfig;
import org.apache.logging.log4j.core.impl.DefaultLogEventFactory;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.util.Constants;
import org.apache.logging.log4j.core.util.StringEncoder;
import org.apache.logging.log4j.plugins.PluginBuilderAttribute;
@@ -111,7 +112,7 @@ public abstract class AbstractStringLayout extends AbstractLayout<String> implem
protected static final int DEFAULT_STRING_BUILDER_SIZE = 1024;
protected static final int MAX_STRING_BUILDER_SIZE = Math.max(DEFAULT_STRING_BUILDER_SIZE,
- size("log4j.layoutStringBuilder.maxSize", 2 * 1024));
+ size(Log4jProperties.GC_LAYOUT_STRING_BUILDER_MAX_SIZE, 2 * 1024));
private static final ThreadLocal<StringBuilder> threadLocal = new ThreadLocal<>();
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java
index 86c83e40eb..8af7ec9037 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java
@@ -27,6 +27,7 @@ import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.config.Configuration;
import org.apache.logging.log4j.core.config.DefaultConfiguration;
import org.apache.logging.log4j.core.config.plugins.PluginConfiguration;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.pattern.FormattingInfo;
import org.apache.logging.log4j.core.pattern.LogEventPatternConverter;
import org.apache.logging.log4j.core.pattern.PatternFormatter;
@@ -576,7 +577,7 @@ public final class PatternLayout extends AbstractStringLayout {
private boolean useAnsiEscapeCodes() {
final PropertyEnvironment properties = PropertiesUtil.getProperties();
final boolean isPlatformSupportsAnsi = !properties.isOsWindows();
- final boolean isJansiRequested = !properties.getBooleanProperty("log4j.skipJansi", true);
+ final boolean isJansiRequested = !properties.getBooleanProperty(Log4jProperties.JANSI_DISABLED, true);
return isPlatformSupportsAnsi || isJansiRequested;
}
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/ssl/SslConfigurationFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/ssl/SslConfigurationFactory.java
index 6fdbbbc8a7..ff92816867 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/net/ssl/SslConfigurationFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/net/ssl/SslConfigurationFactory.java
@@ -17,6 +17,7 @@
package org.apache.logging.log4j.core.net.ssl;
import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.status.StatusLogger;
import org.apache.logging.log4j.util.Lazy;
import org.apache.logging.log4j.util.PropertiesUtil;
@@ -29,62 +30,52 @@ public class SslConfigurationFactory {
private static final Logger LOGGER = StatusLogger.getLogger();
- private static final String trustStorelocation = "log4j2.trustStore.location";
- private static final String trustStorePassword = "log4j2.trustStore.password";
- private static final String trustStorePasswordFile = "log4j2.trustStore.passwordFile";
- private static final String trustStorePasswordEnvVar = "log4j2.trustStore.passwordEnvironmentVariable";
- private static final String trustStoreKeyStoreType = "log4j2.trustStore.keyStoreType";
- private static final String trustStoreKeyManagerFactoryAlgorithm = "log4j2.trustStore.keyManagerFactoryAlgorithm";
- private static final String keyStoreLocation = "log4j2.keyStore.location";
- private static final String keyStorePassword = "log4j2.keyStore.password";
- private static final String keyStorePasswordFile = "log4j2.keyStore.passwordFile";
- private static final String keyStorePasswordEnvVar = "log4j2.keyStore.passwordEnvironmentVariable";
- private static final String keyStoreType = "log4j2.keyStore.type";
- private static final String keyStoreKeyManagerFactoryAlgorithm = "log4j2.keyStore.keyManagerFactoryAlgorithm";
- private static final String verifyHostName = "log4j2.ssl.verifyHostName";
-
private static final Lazy<SslConfiguration> SSL_CONFIGURATION = Lazy.lazy(() -> {
final PropertyEnvironment props = PropertiesUtil.getProperties();
return createSslConfiguration(props);
});
- static final SslConfiguration createSslConfiguration(final PropertyEnvironment props) {
+ static SslConfiguration createSslConfiguration(final PropertyEnvironment props) {
KeyStoreConfiguration keyStoreConfiguration = null;
TrustStoreConfiguration trustStoreConfiguration = null;
- String location = props.getStringProperty(trustStorelocation);
+ String location = props.getStringProperty(Log4jProperties.TRANSPORT_SECURITY_TRUST_STORE_LOCATION);
if (location != null) {
- final String password = props.getStringProperty(trustStorePassword);
+ final String password = props.getStringProperty(Log4jProperties.TRANSPORT_SECURITY_TRUST_STORE_PASSWORD);
char[] passwordChars = null;
if (password != null) {
passwordChars = password.toCharArray();
}
try {
trustStoreConfiguration = TrustStoreConfiguration.createKeyStoreConfiguration(location, passwordChars,
- props.getStringProperty(trustStorePasswordEnvVar), props.getStringProperty(trustStorePasswordFile),
- props.getStringProperty(trustStoreKeyStoreType), props.getStringProperty(trustStoreKeyManagerFactoryAlgorithm));
+ props.getStringProperty(Log4jProperties.TRANSPORT_SECURITY_TRUST_STORE_PASSWORD_ENV_VAR),
+ props.getStringProperty(Log4jProperties.TRANSPORT_SECURITY_TRUST_STORE_PASSWORD_FILE),
+ props.getStringProperty(Log4jProperties.TRANSPORT_SECURITY_TRUST_STORE_KEY_STORE_TYPE),
+ props.getStringProperty(Log4jProperties.TRANSPORT_SECURITY_TRUST_STORE_KEY_MANAGER_FACTORY_ALGORITHM));
} catch (final Exception ex) {
LOGGER.warn("Unable to create trust store configuration due to: {} {}", ex.getClass().getName(),
ex.getMessage());
}
}
- location = props.getStringProperty(keyStoreLocation);
+ location = props.getStringProperty(Log4jProperties.TRANSPORT_SECURITY_KEY_STORE_LOCATION);
if (location != null) {
- final String password = props.getStringProperty(keyStorePassword);
+ final String password = props.getStringProperty(Log4jProperties.TRANSPORT_SECURITY_KEY_STORE_PASSWORD);
char[] passwordChars = null;
if (password != null) {
passwordChars = password.toCharArray();
}
try {
keyStoreConfiguration = KeyStoreConfiguration.createKeyStoreConfiguration(location, passwordChars,
- props.getStringProperty(keyStorePasswordEnvVar), props.getStringProperty(keyStorePasswordFile),
- props.getStringProperty(keyStoreType), props.getStringProperty(keyStoreKeyManagerFactoryAlgorithm));
+ props.getStringProperty(Log4jProperties.TRANSPORT_SECURITY_KEY_STORE_PASSWORD_ENV_VAR),
+ props.getStringProperty(Log4jProperties.TRANSPORT_SECURITY_KEY_STORE_PASSWORD_FILE),
+ props.getStringProperty(Log4jProperties.TRANSPORT_SECURITY_KEY_STORE_TYPE),
+ props.getStringProperty(Log4jProperties.TRANSPORT_SECURITY_KEY_STORE_KEY_MANAGER_FACTORY_ALGORITHM));
} catch (final Exception ex) {
LOGGER.warn("Unable to create key store configuration due to: {} {}", ex.getClass().getName(),
ex.getMessage());
}
}
if (trustStoreConfiguration != null || keyStoreConfiguration != null) {
- final boolean isVerifyHostName = props.getBooleanProperty(verifyHostName, false);
+ final boolean isVerifyHostName = props.getBooleanProperty(Log4jProperties.TRANSPORT_SECURITY_VERIFY_HOST_NAME, false);
return SslConfiguration.createSSLConfiguration(null, keyStoreConfiguration,
trustStoreConfiguration, isVerifyHostName);
}
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/osgi/Activator.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/osgi/Activator.java
index 9ae5aa3dc1..ef0ebaa17d 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/osgi/Activator.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/osgi/Activator.java
@@ -21,7 +21,7 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.util.Constants;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.util.ContextDataProvider;
import org.apache.logging.log4j.plugins.di.Injector;
import org.apache.logging.log4j.plugins.di.InjectorCallback;
@@ -72,8 +72,8 @@ public final class Activator implements BundleActivator {
registry.loadServicesFromBundle(ContextDataProvider.class, bundleId, classLoader);
registry.loadServicesFromBundle(InjectorCallback.class, bundleId, classLoader);
// allow the user to override the default ContextSelector (e.g., by using BasicContextSelector for a global cfg)
- if (PropertiesUtil.getProperties().getStringProperty(Constants.LOG4J_CONTEXT_SELECTOR) == null) {
- System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, BundleContextSelector.class.getName());
+ if (PropertiesUtil.getProperties().getStringProperty(Log4jProperties.CONTEXT_SELECTOR_CLASS_NAME) == null) {
+ System.setProperty(Log4jProperties.CONTEXT_SELECTOR_CLASS_NAME, BundleContextSelector.class.getName());
}
contextRef.compareAndSet(null, context);
}
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/time/ClockFactory.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/time/ClockFactory.java
index 185f27e4e2..8b0ebfcbb8 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/time/ClockFactory.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/time/ClockFactory.java
@@ -16,6 +16,7 @@
*/
package org.apache.logging.log4j.core.time;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.core.time.internal.CachedClock;
import org.apache.logging.log4j.core.time.internal.CoarseCachedClock;
import org.apache.logging.log4j.core.time.internal.SystemClock;
@@ -34,7 +35,7 @@ public final class ClockFactory {
* Name of the system property that can be used to specify a {@code Clock}
* implementation class. The value of this property is {@value}.
*/
- public static final String PROPERTY_NAME = "log4j.Clock";
+ public static final String PROPERTY_NAME = Log4jProperties.CONFIG_CLOCK;
private static final Lazy<Clock> FALLBACK = Lazy.lazy(() -> {
// TODO(ms): split out clock bindings for smaller fallback init
final Injector injector = DI.createInjector();
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Constants.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Constants.java
index e87d2d8297..62fc657e36 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Constants.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Constants.java
@@ -17,13 +17,13 @@
package org.apache.logging.log4j.core.util;
import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.plugins.Named;
import org.apache.logging.log4j.plugins.di.Key;
+import org.apache.logging.log4j.spi.LoggingSystemProperties;
import org.apache.logging.log4j.util.LoaderUtil;
import org.apache.logging.log4j.util.PropertiesUtil;
-import static org.apache.logging.log4j.util.Constants.isThreadLocalsEnabled;
-
/**
* Log4j Constants.
*/
@@ -53,17 +53,17 @@ public final class Constants {
/**
* Name of the system property to use to identify the LogEvent factory.
*/
- public static final String LOG4J_LOG_EVENT_FACTORY = "Log4jLogEventFactory";
+ public static final String LOG4J_LOG_EVENT_FACTORY = Log4jProperties.LOG_EVENT_FACTORY_CLASS_NAME;
/**
* Name of the system property to use to identify the ContextSelector Class.
*/
- public static final String LOG4J_CONTEXT_SELECTOR = "Log4jContextSelector";
+ public static final String LOG4J_CONTEXT_SELECTOR = Log4jProperties.CONTEXT_SELECTOR_CLASS_NAME;
/**
* Property name for the default status (internal log4j logging) level to use if not specified in configuration.
*/
- public static final String LOG4J_DEFAULT_STATUS_LEVEL = "Log4jDefaultStatusLevel";
+ public static final String LOG4J_DEFAULT_STATUS_LEVEL = Log4jProperties.STATUS_DEFAULT_LEVEL;
public static final Key<Level> DEFAULT_STATUS_LEVEL_KEY = new @Named("StatusLogger") Key<>() {};
@@ -81,39 +81,7 @@ public final class Constants {
* Supports user request LOG4J2-898 to have the option to format a message in the background thread.
*/
public static final boolean FORMAT_MESSAGES_IN_BACKGROUND = PropertiesUtil.getProperties().getBooleanProperty(
- "log4j.format.msg.async", false);
-
- /**
- * LOG4J2-3198 property which used to globally opt out of lookups in pattern layout message text, however
- * this is the default and this property is no longer read.
- *
- * Deprecated in 2.15.
- *
- * @since 2.10
- * @deprecated no longer used, lookups are only used when {@code %m{lookups}} is specified
- */
- @Deprecated(forRemoval = true)
- public static final boolean FORMAT_MESSAGES_PATTERN_DISABLE_LOOKUPS = PropertiesUtil.getProperties().getBooleanProperty(
- "log4j2.formatMsgNoLookups", true);
-
- /**
- * {@code true} if we think we are running in a web container, based on the boolean value of system property
- * "log4j2.is.webapp", or (if this system property is not set) whether the {@code javax.servlet.Servlet} class
- * is present in the classpath.
- */
- @Deprecated(forRemoval = true)
- public static final boolean IS_WEB_APP = org.apache.logging.log4j.util.Constants.isWebApp();
-
- /**
- * Kill switch for object pooling in ThreadLocals that enables much of the LOG4J2-1270 no-GC behaviour.
- * <p>
- * {@code True} for non-{@link #IS_WEB_APP web apps}, disable by setting system property
- * "log4j2.enable.threadlocals" to "false".
- *
- * @since 2.6
- */
- @Deprecated(forRemoval = true)
- public static final boolean ENABLE_THREADLOCALS = isThreadLocalsEnabled();
+ Log4jProperties.ASYNC_LOGGER_FORMAT_MESSAGES_IN_BACKGROUND, false);
/**
* Kill switch for garbage-free Layout behaviour that encodes LogEvents directly into
@@ -127,7 +95,7 @@ public final class Constants {
* @since 2.6
*/
public static final boolean ENABLE_DIRECT_ENCODERS = PropertiesUtil.getProperties().getBooleanProperty(
- "log4j2.enable.direct.encoders", true); // enable GC-free text encoding by default
+ Log4jProperties.GC_ENABLE_DIRECT_ENCODERS, true); // enable GC-free text encoding by default
// the alternative is to enable GC-free encoding only by default only when using all-async loggers:
//AsyncLoggerContextSelector.class.getName().equals(PropertiesUtil.getProperties().getStringProperty(LOG4J_CONTEXT_SELECTOR)));
@@ -138,7 +106,7 @@ public final class Constants {
* </p>
* @since 2.6
*/
- public static final int INITIAL_REUSABLE_MESSAGE_SIZE = size("log4j.initialReusableMsgSize", 128);
+ public static final int INITIAL_REUSABLE_MESSAGE_SIZE = size(Log4jProperties.GC_INITIAL_REUSABLE_MESSAGE_SIZE, 128);
/**
* Maximum size of the StringBuilders used in RingBuffer LogEvents to store the contents of reusable Messages.
@@ -149,7 +117,7 @@ public final class Constants {
* </p>
* @since 2.6
*/
- public static final int MAX_REUSABLE_MESSAGE_SIZE = size("log4j.maxReusableMsgSize", (128 * 2 + 2) * 2 + 2);
+ public static final int MAX_REUSABLE_MESSAGE_SIZE = size(LoggingSystemProperties.GC_REUSABLE_MESSAGE_MAX_SIZE, (128 * 2 + 2) * 2 + 2);
/**
* Size of CharBuffers used by text encoders.
@@ -158,7 +126,7 @@ public final class Constants {
* </p>
* @since 2.6
*/
- public static final int ENCODER_CHAR_BUFFER_SIZE = size("log4j.encoder.charBufferSize", 2048);
+ public static final int ENCODER_CHAR_BUFFER_SIZE = size(Log4jProperties.GC_ENCODER_CHAR_BUFFER_SIZE, 2048);
/**
* Default size of ByteBuffers used to encode LogEvents without allocating temporary objects.
@@ -168,7 +136,7 @@ public final class Constants {
* @see org.apache.logging.log4j.core.layout.ByteBufferDestination
* @since 2.6
*/
- public static final int ENCODER_BYTE_BUFFER_SIZE = size("log4j.encoder.byteBufferSize", 8 * 1024);
+ public static final int ENCODER_BYTE_BUFFER_SIZE = size(Log4jProperties.GC_ENCODER_BYTE_BUFFER_SIZE, 8 * 1024);
private static int size(final String property, final int defaultValue) {
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/ShutdownCallbackRegistry.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/ShutdownCallbackRegistry.java
index 2893ddfb2a..f8c8d750a0 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/ShutdownCallbackRegistry.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/ShutdownCallbackRegistry.java
@@ -14,11 +14,11 @@
* See the license for the specific language governing permissions and
* limitations under the license.
*/
-
package org.apache.logging.log4j.core.util;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.MarkerManager;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.plugins.di.Key;
/**
@@ -33,14 +33,14 @@ public interface ShutdownCallbackRegistry {
/**
* System property to set to choose the ShutdownCallbackRegistry.
*/
- String SHUTDOWN_CALLBACK_REGISTRY = "log4j.shutdownCallbackRegistry";
+ String SHUTDOWN_CALLBACK_REGISTRY = Log4jProperties.SHUTDOWN_CALLBACK_REGISTRY_CLASS_NAME;
Key<ShutdownCallbackRegistry> KEY = Key.forClass(ShutdownCallbackRegistry.class);
/**
* System property to set to override the global ability to register shutdown hooks.
*/
- String SHUTDOWN_HOOK_ENABLED = "log4j.shutdownHookEnabled";
+ String SHUTDOWN_HOOK_ENABLED = Log4jProperties.SHUTDOWN_HOOK_ENABLED;
/**
* Shared Marker to indicate log messages corresponding to shutdown hooks.
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/UuidUtil.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/UuidUtil.java
index 62564f39da..255c70aa09 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/UuidUtil.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/UuidUtil.java
@@ -22,8 +22,7 @@ import java.util.Random;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.status.StatusLogger;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
import org.apache.logging.log4j.util.PropertiesUtil;
/**
@@ -31,12 +30,6 @@ import org.apache.logging.log4j.util.PropertiesUtil;
* less than 10,000 IDs are generated per millisecond on the same device (as identified by its MAC address).
*/
public final class UuidUtil {
- /**
- * System property that may be used to seed the UUID generation with an integer value.
- */
- public static final String UUID_SEQUENCE = "org.apache.logging.log4j.uuidSequence";
-
- private static final Logger LOGGER = StatusLogger.getLogger();
private static final String ASSIGNED_SEQUENCES = "org.apache.logging.log4j.assignedSequences";
@@ -45,7 +38,7 @@ public final class UuidUtil {
private static final byte VARIANT = (byte) 0x80;
private static final int SEQUENCE_MASK = 0x3FFF;
private static final long NUM_100NS_INTERVALS_SINCE_UUID_EPOCH = 0x01b21dd213814000L;
- private static final long INITIAL_UUID_SEQNO = PropertiesUtil.getProperties().getLongProperty(UUID_SEQUENCE, 0);
+ private static final long INITIAL_UUID_SEQNO = PropertiesUtil.getProperties().getLongProperty(Log4jProperties.UUID_SEQUENCE, 0);
private static final long LOW_MASK = 0xffffffffL;
private static final long MID_MASK = 0xffff00000000L;
diff --git a/log4j-gctests/src/test/java/org/apache/logging/log4j/gctests/GcFreeLoggingTestUtil.java b/log4j-gctests/src/test/java/org/apache/logging/log4j/gctests/GcFreeLoggingTestUtil.java
index f02009a8aa..169cf6ed66 100644
--- a/log4j-gctests/src/test/java/org/apache/logging/log4j/gctests/GcFreeLoggingTestUtil.java
+++ b/log4j-gctests/src/test/java/org/apache/logging/log4j/gctests/GcFreeLoggingTestUtil.java
@@ -59,7 +59,7 @@ public enum GcFreeLoggingTestUtil {;
assertTrue(isThreadLocalsEnabled(), "Constants.ENABLE_THREADLOCALS");
assertTrue(Constants.ENABLE_DIRECT_ENCODERS, "Constants.ENABLE_DIRECT_ENCODERS");
- assertFalse(isWebApp(), "Constants.IS_WEB_APP");
+ assertFalse(isWebApp(), "Constants.isWebApp()");
final MyCharSeq myCharSeq = new MyCharSeq();
final Marker testGrandParent = MarkerManager.getMarker("testGrandParent");
diff --git a/log4j-jakarta-web/src/test/java/org/apache/logging/log4j/web/PropertyTest.java b/log4j-jakarta-web/src/test/java/org/apache/logging/log4j/web/PropertyTest.java
index bb5dc6296e..9a83931d69 100644
--- a/log4j-jakarta-web/src/test/java/org/apache/logging/log4j/web/PropertyTest.java
+++ b/log4j-jakarta-web/src/test/java/org/apache/logging/log4j/web/PropertyTest.java
@@ -38,6 +38,6 @@ public class PropertyTest {
@Test
public void testIsWebApp() {
- assertTrue(Constants.isWebApp(), "When servlet classes are available IS_WEB_APP should default to true");
+ assertTrue(Constants.isWebApp(), "When servlet classes are available Constants.isWebApp() should default to true");
}
}
diff --git a/log4j-layout-template-json-test/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutNullEventDelimiterTest.java b/log4j-layout-template-json-test/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutNullEventDelimiterTest.java
index f4cfe84167..5cb67e3434 100644
--- a/log4j-layout-template-json-test/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutNullEventDelimiterTest.java
+++ b/log4j-layout-template-json-test/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutNullEventDelimiterTest.java
@@ -16,13 +16,6 @@
*/
package org.apache.logging.log4j.layout.template.json;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.assertj.core.api.Assertions;
-import org.awaitility.Awaitility;
-import org.junit.jupiter.api.Test;
-
import java.io.ByteArrayOutputStream;
import java.io.EOFException;
import java.io.IOException;
@@ -31,6 +24,14 @@ import java.net.ServerSocket;
import java.net.Socket;
import java.time.Duration;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.impl.Log4jProperties;
+import org.assertj.core.api.Assertions;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.Test;
+
class JsonTemplateLayoutNullEventDelimiterTest {
@Test
@@ -44,7 +45,7 @@ class JsonTemplateLayoutNullEventDelimiterTest {
"serverPort",
String.valueOf(server.getPort()));
System.setProperty(
- "log4j.configurationFile",
+ Log4jProperties.CONFIG_LOCATION,
"nullEventDelimitedJsonTemplateLayoutLogging.xml");
// Produce log events.
diff --git a/log4j-web/src/test/java/org/apache/logging/log4j/web/PropertyTest.java b/log4j-web/src/test/java/org/apache/logging/log4j/web/PropertyTest.java
index bb5dc6296e..9a83931d69 100644
--- a/log4j-web/src/test/java/org/apache/logging/log4j/web/PropertyTest.java
+++ b/log4j-web/src/test/java/org/apache/logging/log4j/web/PropertyTest.java
@@ -38,6 +38,6 @@ public class PropertyTest {
@Test
public void testIsWebApp() {
- assertTrue(Constants.isWebApp(), "When servlet classes are available IS_WEB_APP should default to true");
+ assertTrue(Constants.isWebApp(), "When servlet classes are available Constants.isWebApp() should default to true");
}
}