- * This method is equivalent to calling the {@link #setMaxDepth}
- * method with a zero maxDepth
argument.
- *
- */
- public static void clear() {
- org.apache.logging.log4j.ThreadContext.clearStack();
- }
-
- /**
- * Clone the diagnostic context for the current thread.
- *
- * Internally a diagnostic context is represented as a stack. A
- * given thread can supply the stack (i.e. diagnostic context) to a
- * child thread so that the child can inherit the parent thread's
- * diagnostic context.
- *
- *
- * The child thread uses the {@link #inherit inherit} method to
- * inherit the parent's diagnostic context.
- *
- * @return Stack A clone of the current thread's diagnostic context, Stack of Strings.
- */
- @SuppressWarnings("rawtypes")
- public static Stack cloneStack() {
- final Stack stack = new Stack<>();
- for (final String element :
- org.apache.logging.log4j.ThreadContext.cloneStack().asList()) {
- stack.push(element);
- }
- return stack;
- }
-
- /**
- * Inherit the diagnostic context of another thread, a Stack of Strings.
- *
- * The parent thread can obtain a reference to its diagnostic
- * context using the {@link #cloneStack} method. It should
- * communicate this information to its child so that it may inherit
- * the parent's diagnostic context.
- *
- *
- * The parent's diagnostic context is cloned before being
- * inherited. In other words, once inherited, the two diagnostic
- * contexts can be managed independently.
- *
- *
- * In java, a child thread cannot obtain a reference to its
- * parent, unless it is directly handed the reference. Consequently,
- * there is no client-transparent way of inheriting diagnostic
- * contexts. Do you know any solution to this problem?
- *
- * @param stack The diagnostic context of the parent thread, a Stack of Strings.
- */
- @SuppressWarnings({"rawtypes", "unchecked"})
- public static void inherit(final Stack stack) {
- org.apache.logging.log4j.ThreadContext.setStack(stack);
- }
-
- /**
- * Never use this method directly.
- *
- * @return The string value of the specified key.
- */
- public static String get() {
- return org.apache.logging.log4j.ThreadContext.peek();
- }
-
- /**
- * Get the current nesting depth of this diagnostic context.
- * @return int The number of elements in the call stack.
- * @see #setMaxDepth
- */
- public static int getDepth() {
- return org.apache.logging.log4j.ThreadContext.getDepth();
- }
-
- /**
- * Clients should call this method before leaving a diagnostic
- * context.
- *
- * The returned value is the value that was pushed last. If no
- * context is available, then the empty string "" is returned.
- *
- * @return String The innermost diagnostic context.
- */
- public static String pop() {
- return org.apache.logging.log4j.ThreadContext.pop();
- }
-
- /**
- * Looks at the last diagnostic context at the top of this NDC
- * without removing it.
- *
- * The returned value is the value that was pushed last. If no
- * context is available, then the empty string "" is returned.
- *
- * @return String The innermost diagnostic context.
- */
- public static String peek() {
- return org.apache.logging.log4j.ThreadContext.peek();
- }
-
- /**
- * Push new diagnostic context information for the current thread.
- *
- * The contents of the message
parameter is
- * determined solely by the client.
- *
- * @param message The new diagnostic context information.
- */
- public static void push(final String message) {
- org.apache.logging.log4j.ThreadContext.push(message);
- }
-
- /**
- * Remove the diagnostic context for this thread.
- *
- * Each thread that created a diagnostic context by calling
- * {@link #push} should call this method before exiting. Otherwise,
- * the memory used by the thread cannot be reclaimed by the
- * VM.
- *
- *
- * As this is such an important problem in heavy duty systems and
- * because it is difficult to always guarantee that the remove
- * method is called before exiting a thread, this method has been
- * augmented to lazily remove references to dead threads. In
- * practice, this means that you can be a little sloppy and
- * occasionally forget to call {@code remove} before exiting a
- * thread. However, you must call remove
sometime. If
- * you never call it, then your application is sure to run out of
- * memory.
- *
- */
- public static void remove() {
- org.apache.logging.log4j.ThreadContext.removeStack();
- }
-
- /**
- * Set maximum depth of this diagnostic context. If the current
- * depth is smaller or equal to maxDepth
, then no
- * action is taken.
- *
- * This method is a convenient alternative to multiple {@link
- * #pop} calls. Moreover, it is often the case that at the end of
- * complex call sequences, the depth of the NDC is
- * unpredictable. The setMaxDepth
method circumvents
- * this problem.
- *
- *
- * For example, the combination
- *
- *
- * void foo() {
- * int depth = NDC.getDepth();
- *
- * ... complex sequence of calls
- *
- * NDC.setMaxDepth(depth);
- * }
- *
- *
- * ensures that between the entry and exit of foo the depth of the
- * diagnostic stack is conserved.
- *
- *
- * @see #getDepth
- * @param maxDepth The maximum depth of the stack.
- */
- public static void setMaxDepth(final int maxDepth) {
- org.apache.logging.log4j.ThreadContext.trim(maxDepth);
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/PatternLayout.java b/log4j-1.2-api/src/main/java/org/apache/log4j/PatternLayout.java
deleted file mode 100644
index 7331cfeda9d..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/PatternLayout.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-import org.apache.log4j.helpers.PatternConverter;
-import org.apache.log4j.helpers.PatternParser;
-import org.apache.log4j.spi.LoggingEvent;
-
-/**
- *
- */
-public class PatternLayout extends Layout {
-
- /**
- * Default pattern string for log output. Currently set to the string {@value #DEFAULT_CONVERSION_PATTERN} which
- * just prints the application supplied message.
- */
- public static final String DEFAULT_CONVERSION_PATTERN = "%m%n";
-
- /**
- * A conversion pattern equivalent to the TTCCCLayout. Current value is {@value #TTCC_CONVERSION_PATTERN}
- */
- public static final String TTCC_CONVERSION_PATTERN = "%r [%t] %p %c %x - %m%n";
-
- protected final int BUF_SIZE = 256;
-
- protected final int MAX_CAPACITY = 1024;
-
- // output buffer appended to when format() is invoked
- private StringBuffer sbuf = new StringBuffer(BUF_SIZE);
-
- private String pattern;
-
- private PatternConverter head;
-
- /**
- * Constructs a PatternLayout using the DEFAULT_LAYOUT_PATTERN.
- *
- * The default pattern just produces the application supplied message.
- */
- public PatternLayout() {
- this(DEFAULT_CONVERSION_PATTERN);
- }
-
- /**
- * Constructs a PatternLayout using the supplied conversion pattern.
- */
- public PatternLayout(final String pattern) {
- this.pattern = pattern;
- head = createPatternParser((pattern == null) ? DEFAULT_CONVERSION_PATTERN : pattern)
- .parse();
- }
-
- /**
- * Does not do anything as options become effective
- */
- public void activateOptions() {
- // nothing to do.
- }
-
- /**
- * Returns PatternParser used to parse the conversion string. Subclasses may override this to return a subclass of
- * PatternParser which recognize custom conversion characters.
- *
- * @since 0.9.0
- */
- protected PatternParser createPatternParser(final String pattern) {
- return new PatternParser(pattern);
- }
-
- /**
- * Produces a formatted string as specified by the conversion pattern.
- */
- @Override
- public String format(final LoggingEvent event) {
- // Reset working stringbuffer
- if (sbuf.capacity() > MAX_CAPACITY) {
- sbuf = new StringBuffer(BUF_SIZE);
- } else {
- sbuf.setLength(0);
- }
-
- PatternConverter c = head;
-
- while (c != null) {
- c.format(sbuf, event);
- c = c.next;
- }
- return sbuf.toString();
- }
-
- /**
- * Returns the value of the ConversionPattern option.
- */
- public String getConversionPattern() {
- return pattern;
- }
-
- /**
- * The PatternLayout does not handle the throwable contained within {@link LoggingEvent LoggingEvents}. Thus, it returns
- * true
.
- *
- * @since 0.8.4
- */
- @Override
- public boolean ignoresThrowable() {
- return true;
- }
-
- /**
- * Set the ConversionPattern option. This is the string which controls formatting and consists of a mix of
- * literal content and conversion specifiers.
- */
- public void setConversionPattern(final String conversionPattern) {
- pattern = conversionPattern;
- head = createPatternParser(conversionPattern).parse();
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/Priority.java b/log4j-1.2-api/src/main/java/org/apache/log4j/Priority.java
deleted file mode 100644
index 80c7ed10473..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/Priority.java
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-/**
- * Refrain from using this class directly, use
- * the {@link Level} class instead.
- */
-public class Priority {
-
- /**
- * The OFF
has the highest possible rank and is
- * intended to turn off logging.
- */
- public static final int OFF_INT = Integer.MAX_VALUE;
- /**
- * The FATAL
level designates very severe error
- * events that will presumably lead the application to abort.
- */
- public static final int FATAL_INT = 50000;
- /**
- * The ERROR
level designates error events that
- * might still allow the application to continue running.
- */
- public static final int ERROR_INT = 40000;
- /**
- * The WARN
level designates potentially harmful situations.
- */
- public static final int WARN_INT = 30000;
- /**
- * The INFO
level designates informational messages
- * that highlight the progress of the application at coarse-grained
- * level.
- */
- public static final int INFO_INT = 20000;
- /**
- * The DEBUG
Level designates fine-grained
- * informational events that are most useful to debug an
- * application.
- */
- public static final int DEBUG_INT = 10000;
- // public final static int FINE_INT = DEBUG_INT;
- /**
- * The ALL
has the lowest possible rank and is intended to
- * turn on all logging.
- */
- public static final int ALL_INT = Integer.MIN_VALUE;
-
- /**
- * @deprecated Use {@link Level#FATAL} instead.
- */
- @Deprecated
- public static final Priority FATAL = new Level(FATAL_INT, "FATAL", 0);
-
- /**
- * @deprecated Use {@link Level#ERROR} instead.
- */
- @Deprecated
- public static final Priority ERROR = new Level(ERROR_INT, "ERROR", 3);
-
- /**
- * @deprecated Use {@link Level#WARN} instead.
- */
- @Deprecated
- public static final Priority WARN = new Level(WARN_INT, "WARN", 4);
-
- /**
- * @deprecated Use {@link Level#INFO} instead.
- */
- @Deprecated
- public static final Priority INFO = new Level(INFO_INT, "INFO", 6);
-
- /**
- * @deprecated Use {@link Level#DEBUG} instead.
- */
- @Deprecated
- public static final Priority DEBUG = new Level(DEBUG_INT, "DEBUG", 7);
-
- /*
- * These variables should be private but were not in Log4j 1.2 so are left the same way here.
- */
- transient int level;
- transient String levelStr;
- transient int syslogEquivalent;
- transient org.apache.logging.log4j.Level version2Level;
-
- /**
- * Default constructor for deserialization.
- */
- protected Priority() {
- level = DEBUG_INT;
- levelStr = "DEBUG";
- syslogEquivalent = 7;
- }
-
- /**
- * Instantiate a level object.
- * @param level The level value.
- * @param levelStr The level name.
- * @param syslogEquivalent The equivalent syslog value.
- */
- protected Priority(final int level, final String levelStr, final int syslogEquivalent) {
- this.level = level;
- this.levelStr = levelStr;
- this.syslogEquivalent = syslogEquivalent;
- }
-
- /**
- * Two priorities are equal if their level fields are equal.
- * @param o The Object to check.
- * @return true if the objects are equal, false otherwise.
- *
- * @since 1.2
- */
- @Override
- public boolean equals(final Object o) {
- if (o instanceof Priority) {
- final Priority r = (Priority) o;
- return this.level == r.level;
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return this.level;
- }
-
- /**
- * Returns the syslog equivalent of this priority as an integer.
- * @return The equivalent syslog value.
- */
- public final int getSyslogEquivalent() {
- return syslogEquivalent;
- }
-
- /**
- * Gets the Log4j 2.x level associated with this priority
- *
- * @return a Log4j 2.x level.
- */
- public org.apache.logging.log4j.Level getVersion2Level() {
- return version2Level;
- }
-
- /**
- * Returns {@code true} if this level has a higher or equal
- * level than the level passed as argument, {@code false}
- * otherwise.
- *
- * You should think twice before overriding the default
- * implementation of isGreaterOrEqual
method.
- *
- * @param r The Priority to check.
- * @return true if the current level is greater or equal to the specified Priority.
- */
- public boolean isGreaterOrEqual(final Priority r) {
- return level >= r.level;
- }
-
- /**
- * Returns all possible priorities as an array of Level objects in
- * descending order.
- * @return An array of all possible Priorities.
- *
- * @deprecated This method will be removed with no replacement.
- */
- @Deprecated
- public static Priority[] getAllPossiblePriorities() {
- return new Priority[] {Priority.FATAL, Priority.ERROR, Level.WARN, Priority.INFO, Priority.DEBUG};
- }
-
- /**
- * Returns the string representation of this priority.
- * @return The name of the Priority.
- */
- @Override
- public final String toString() {
- return levelStr;
- }
-
- /**
- * Returns the integer representation of this level.
- * @return The integer value of this level.
- */
- public final int toInt() {
- return level;
- }
-
- /**
- * @param sArg The name of the Priority.
- * @return The Priority matching the name.
- * @deprecated Please use the {@link Level#toLevel(String)} method instead.
- */
- @Deprecated
- public static Priority toPriority(final String sArg) {
- return Level.toLevel(sArg);
- }
-
- /**
- * @param val The value of the Priority.
- * @return The Priority matching the value.
- * @deprecated Please use the {@link Level#toLevel(int)} method instead.
- */
- @Deprecated
- public static Priority toPriority(final int val) {
- return toPriority(val, Priority.DEBUG);
- }
-
- /**
- * @param val The value of the Priority.
- * @param defaultPriority The default Priority to use if the value is invalid.
- * @return The Priority matching the value or the default Priority if no match is found.
- * @deprecated Please use the {@link Level#toLevel(int, Level)} method instead.
- */
- @Deprecated
- public static Priority toPriority(final int val, final Priority defaultPriority) {
- return Level.toLevel(val, (Level) defaultPriority);
- }
-
- /**
- * @param sArg The name of the Priority.
- * @param defaultPriority The default Priority to use if the name is not found.
- * @return The Priority matching the name or the default Priority if no match is found.
- * @deprecated Please use the {@link Level#toLevel(String, Level)} method instead.
- */
- @Deprecated
- public static Priority toPriority(final String sArg, final Priority defaultPriority) {
- return Level.toLevel(sArg, (Level) defaultPriority);
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/PropertyConfigurator.java b/log4j-1.2-api/src/main/java/org/apache/log4j/PropertyConfigurator.java
deleted file mode 100644
index ca88c35d038..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/PropertyConfigurator.java
+++ /dev/null
@@ -1,705 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InterruptedIOException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Map;
-import java.util.Properties;
-import java.util.StringTokenizer;
-import java.util.Vector;
-import org.apache.log4j.bridge.FilterAdapter;
-import org.apache.log4j.config.Log4j1Configuration;
-import org.apache.log4j.config.PropertiesConfiguration;
-import org.apache.log4j.config.PropertySetter;
-import org.apache.log4j.helpers.FileWatchdog;
-import org.apache.log4j.helpers.LogLog;
-import org.apache.log4j.helpers.OptionConverter;
-import org.apache.log4j.or.RendererMap;
-import org.apache.log4j.spi.Configurator;
-import org.apache.log4j.spi.ErrorHandler;
-import org.apache.log4j.spi.Filter;
-import org.apache.log4j.spi.LoggerFactory;
-import org.apache.log4j.spi.LoggerRepository;
-import org.apache.log4j.spi.OptionHandler;
-import org.apache.log4j.spi.RendererSupport;
-import org.apache.log4j.spi.ThrowableRenderer;
-import org.apache.log4j.spi.ThrowableRendererSupport;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.net.UrlConnectionFactory;
-import org.apache.logging.log4j.util.StackLocatorUtil;
-
-/**
- * Configures Log4j from properties.
- */
-public class PropertyConfigurator implements Configurator {
-
- static class NameValue {
- String key, value;
-
- public NameValue(final String key, final String value) {
- this.key = key;
- this.value = value;
- }
-
- @Override
- public String toString() {
- return key + "=" + value;
- }
- }
-
- static class PropertyWatchdog extends FileWatchdog {
-
- private final ClassLoader classLoader;
-
- PropertyWatchdog(final String fileName, final ClassLoader classLoader) {
- super(fileName);
- this.classLoader = classLoader;
- }
-
- /**
- * Call {@link PropertyConfigurator#configure(String)} with the filename
to reconfigure log4j.
- */
- @Override
- public void doOnChange() {
- new PropertyConfigurator().doConfigure(filename, LogManager.getLoggerRepository(), classLoader);
- }
- }
-
- class SortedKeyEnumeration implements Enumeration {
-
- private final Enumeration e;
-
- public SortedKeyEnumeration(final Hashtable ht) {
- final Enumeration f = ht.keys();
- final Vector keys = new Vector(ht.size());
- for (int i, last = 0; f.hasMoreElements(); ++last) {
- final String key = (String) f.nextElement();
- for (i = 0; i < last; ++i) {
- final String s = (String) keys.get(i);
- if (key.compareTo(s) <= 0) {
- break;
- }
- }
- keys.add(i, key);
- }
- e = keys.elements();
- }
-
- @Override
- public boolean hasMoreElements() {
- return e.hasMoreElements();
- }
-
- @Override
- public Object nextElement() {
- return e.nextElement();
- }
- }
-
- static final String CATEGORY_PREFIX = "log4j.category.";
- static final String LOGGER_PREFIX = "log4j.logger.";
- static final String FACTORY_PREFIX = "log4j.factory";
- static final String ADDITIVITY_PREFIX = "log4j.additivity.";
- static final String ROOT_CATEGORY_PREFIX = "log4j.rootCategory";
- static final String ROOT_LOGGER_PREFIX = "log4j.rootLogger";
- static final String APPENDER_PREFIX = "log4j.appender.";
- static final String RENDERER_PREFIX = "log4j.renderer.";
- static final String THRESHOLD_PREFIX = "log4j.threshold";
-
- private static final String THROWABLE_RENDERER_PREFIX = "log4j.throwableRenderer";
- private static final String LOGGER_REF = "logger-ref";
- private static final String ROOT_REF = "root-ref";
- private static final String APPENDER_REF_TAG = "appender-ref";
-
- /**
- * Key for specifying the {@link org.apache.log4j.spi.LoggerFactory LoggerFactory}. Currently set to
- * "log4j.loggerFactory
".
- */
- public static final String LOGGER_FACTORY_KEY = "log4j.loggerFactory";
-
- /**
- * If property set to true, then hierarchy will be reset before configuration.
- */
- private static final String RESET_KEY = "log4j.reset";
-
- private static final String INTERNAL_ROOT_NAME = "root";
-
- /**
- * Reads configuration options from an InputStream.
- *
- * @param inputStream The input stream
- */
- public static void configure(final InputStream inputStream) {
- new PropertyConfigurator()
- .doConfigure(inputStream, LogManager.getLoggerRepository(), StackLocatorUtil.getCallerClassLoader(2));
- }
-
- /**
- * Reads configuration options from properties
.
- *
- * See {@link #doConfigure(String, LoggerRepository)} for the expected format.
- *
- * @param properties The properties
- */
- public static void configure(final Properties properties) {
- new PropertyConfigurator()
- .doConfigure(properties, LogManager.getLoggerRepository(), StackLocatorUtil.getCallerClassLoader(2));
- }
-
- /**
- * Reads configuration options from configuration file.
- *
- * @param fileName The configuration file.
- */
- public static void configure(final String fileName) {
- new PropertyConfigurator()
- .doConfigure(fileName, LogManager.getLoggerRepository(), StackLocatorUtil.getCallerClassLoader(2));
- }
-
- /**
- * Reads configuration options from url configURL
.
- *
- * @param configURL The configuration URL
- */
- public static void configure(final URL configURL) {
- new PropertyConfigurator()
- .doConfigure(configURL, LogManager.getLoggerRepository(), StackLocatorUtil.getCallerClassLoader(2));
- }
-
- /**
- * Like {@link #configureAndWatch(String, long)} except that the default delay as defined by FileWatchdog.DEFAULT_DELAY
- * is used.
- *
- * @param configFilename A file in key=value format.
- */
- public static void configureAndWatch(final String configFilename) {
- configureAndWatch(configFilename, FileWatchdog.DEFAULT_DELAY, StackLocatorUtil.getCallerClassLoader(2));
- }
-
- /**
- * Reads the configuration file configFilename
if it exists. Moreover, a thread will be created that will
- * periodically check if configFilename
has been created or modified. The period is determined by the
- * delay
argument. If a change or file creation is detected, then configFilename
is read to
- * configure log4j.
- *
- * @param configFilename A file in key=value format.
- * @param delayMillis The delay in milliseconds to wait between each check.
- */
- public static void configureAndWatch(final String configFilename, final long delayMillis) {
- configureAndWatch(configFilename, delayMillis, StackLocatorUtil.getCallerClassLoader(2));
- }
-
- static void configureAndWatch(final String configFilename, final long delay, final ClassLoader classLoader) {
- final PropertyWatchdog watchdog = new PropertyWatchdog(configFilename, classLoader);
- watchdog.setDelay(delay);
- watchdog.start();
- }
-
- private static Configuration reconfigure(final Configuration configuration) {
- org.apache.logging.log4j.core.config.Configurator.reconfigure(configuration);
- return configuration;
- }
-
- /**
- * Used internally to keep track of configured appenders.
- */
- protected Hashtable registry = new Hashtable(11);
-
- private LoggerRepository repository;
-
- protected LoggerFactory loggerFactory = new DefaultCategoryFactory();
-
- /**
- * Checks the provided Properties
object for a {@link org.apache.log4j.spi.LoggerFactory LoggerFactory}
- * entry specified by {@link #LOGGER_FACTORY_KEY}. If such an entry exists, an attempt is made to create an instance
- * using the default constructor. This instance is used for subsequent Category creations within this configurator.
- *
- * @see #parseCatsAndRenderers
- */
- protected void configureLoggerFactory(final Properties properties) {
- final String factoryClassName = OptionConverter.findAndSubst(LOGGER_FACTORY_KEY, properties);
- if (factoryClassName != null) {
- LogLog.debug("Setting category factory to [" + factoryClassName + "].");
- loggerFactory = (LoggerFactory)
- OptionConverter.instantiateByClassName(factoryClassName, LoggerFactory.class, loggerFactory);
- PropertySetter.setProperties(loggerFactory, properties, FACTORY_PREFIX + ".");
- }
- }
-
- void configureRootCategory(final Properties properties, final LoggerRepository loggerRepository) {
- String effectiveFrefix = ROOT_LOGGER_PREFIX;
- String value = OptionConverter.findAndSubst(ROOT_LOGGER_PREFIX, properties);
-
- if (value == null) {
- value = OptionConverter.findAndSubst(ROOT_CATEGORY_PREFIX, properties);
- effectiveFrefix = ROOT_CATEGORY_PREFIX;
- }
-
- if (value == null) {
- LogLog.debug("Could not find root logger information. Is this OK?");
- } else {
- final Logger root = loggerRepository.getRootLogger();
- synchronized (root) {
- parseCategory(properties, root, effectiveFrefix, INTERNAL_ROOT_NAME, value);
- }
- }
- }
-
- /**
- * Reads configuration options from an InputStream.
- *
- * @param inputStream The input stream
- * @param loggerRepository The hierarchy
- */
- @Override
- public void doConfigure(final InputStream inputStream, final LoggerRepository loggerRepository) {
- doConfigure(inputStream, loggerRepository, StackLocatorUtil.getCallerClassLoader(2));
- }
-
- Configuration doConfigure(
- final InputStream inputStream, final LoggerRepository loggerRepository, final ClassLoader classLoader) {
- return doConfigure(loadProperties(inputStream), loggerRepository, classLoader);
- }
-
- /**
- * Reads configuration options from properties
.
- *
- * See {@link #doConfigure(String, LoggerRepository)} for the expected format.
- *
- * @param properties The properties
- * @param loggerRepository The hierarchy
- */
- public void doConfigure(final Properties properties, final LoggerRepository loggerRepository) {
- doConfigure(properties, loggerRepository, StackLocatorUtil.getCallerClassLoader(2));
- }
-
- /**
- * Reads configuration options from properties
.
- *
- * See {@link #doConfigure(String, LoggerRepository)} for the expected format.
- *
- * @param properties The properties
- * @param loggerRepository The hierarchy
- */
- Configuration doConfigure(
- final Properties properties, final LoggerRepository loggerRepository, final ClassLoader classLoader) {
- final PropertiesConfiguration configuration =
- new PropertiesConfiguration((LoggerContext) LogManager.getContext(classLoader), properties);
- configuration.doConfigure();
-
- repository = loggerRepository;
- // String value = properties.getProperty(LogLog.DEBUG_KEY);
- // if (value == null) {
- // value = properties.getProperty("log4j.configDebug");
- // if (value != null) {
- // LogLog.warn("[log4j.configDebug] is deprecated. Use [log4j.debug] instead.");
- // }
- // }
- //
- // if (value != null) {
- // LogLog.setInternalDebugging(OptionConverter.toBoolean(value, true));
- // }
- //
- // //
- // // if log4j.reset=true then
- // // reset hierarchy
- // final String reset = properties.getProperty(RESET_KEY);
- // if (reset != null && OptionConverter.toBoolean(reset, false)) {
- // hierarchy.resetConfiguration();
- // }
- //
- // final String thresholdStr = OptionConverter.findAndSubst(THRESHOLD_PREFIX, properties);
- // if (thresholdStr != null) {
- // hierarchy.setThreshold(OptionConverter.toLevel(thresholdStr, (Level) Level.ALL));
- // LogLog.debug("Hierarchy threshold set to [" + hierarchy.getThreshold() + "].");
- // }
- //
- // configureRootCategory(properties, hierarchy);
- // configureLoggerFactory(properties);
- // parseCatsAndRenderers(properties, hierarchy);
- //
- // We don't want to hold references to appenders preventing their
- // garbage collection.
- registry.clear();
-
- return reconfigure(configuration);
- }
-
- /**
- * Reads configuration options from configuration file.
- *
- * @param fileName The configuration file
- * @param loggerRepository The hierarchy
- */
- public void doConfigure(final String fileName, final LoggerRepository loggerRepository) {
- doConfigure(fileName, loggerRepository, StackLocatorUtil.getCallerClassLoader(2));
- }
-
- /**
- * Reads configuration options from configuration file.
- *
- * @param fileName The configuration file
- * @param loggerRepository The hierarchy
- */
- @SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "The filename comes from a system property.")
- Configuration doConfigure(
- final String fileName, final LoggerRepository loggerRepository, final ClassLoader classLoader) {
- try (final InputStream inputStream = Files.newInputStream(Paths.get(fileName))) {
- return doConfigure(inputStream, loggerRepository, classLoader);
- } catch (final Exception e) {
- if (e instanceof InterruptedIOException || e instanceof InterruptedException) {
- Thread.currentThread().interrupt();
- }
- LogLog.error("Could not read configuration file [" + fileName + "].", e);
- LogLog.error("Ignoring configuration file [" + fileName + "].");
- return null;
- }
- }
-
- /**
- * Read configuration options from url configURL
.
- *
- * @param url The configuration URL
- * @param loggerRepository The hierarchy
- */
- @Override
- public void doConfigure(final URL url, final LoggerRepository loggerRepository) {
- doConfigure(url, loggerRepository, StackLocatorUtil.getCallerClassLoader(2));
- }
-
- Configuration doConfigure(final URL url, final LoggerRepository loggerRepository, final ClassLoader classLoader) {
- LogLog.debug("Reading configuration from URL " + url);
- try {
- final URLConnection urlConnection = UrlConnectionFactory.createConnection(url);
- try (final InputStream inputStream = urlConnection.getInputStream()) {
- return doConfigure(inputStream, loggerRepository, classLoader);
- }
- } catch (final IOException e) {
- LogLog.error("Could not read configuration file from URL [" + url + "].", e);
- LogLog.error("Ignoring configuration file [" + url + "].");
- return null;
- }
- }
-
- private Properties loadProperties(final InputStream inputStream) {
- final Properties loaded = new Properties();
- try {
- loaded.load(inputStream);
- } catch (final IOException | IllegalArgumentException e) {
- if (e instanceof InterruptedIOException) {
- Thread.currentThread().interrupt();
- }
- LogLog.error("Could not read configuration file from InputStream [" + inputStream + "].", e);
- LogLog.error("Ignoring configuration InputStream [" + inputStream + "].");
- return null;
- }
- return loaded;
- }
-
- /**
- * Parse the additivity option for a non-root category.
- */
- void parseAdditivityForLogger(final Properties properties, final Logger logger, final String loggerName) {
- final String value = OptionConverter.findAndSubst(ADDITIVITY_PREFIX + loggerName, properties);
- LogLog.debug("Handling " + ADDITIVITY_PREFIX + loggerName + "=[" + value + "]");
- // touch additivity only if necessary
- if (value != null && !value.isEmpty()) {
- final boolean additivity = OptionConverter.toBoolean(value, true);
- LogLog.debug("Setting additivity for \"" + loggerName + "\" to " + additivity);
- logger.setAdditivity(additivity);
- }
- }
-
- Appender parseAppender(final Properties properties, final String appenderName) {
- Appender appender = registryGet(appenderName);
- if ((appender != null)) {
- LogLog.debug("Appender \"" + appenderName + "\" was already parsed.");
- return appender;
- }
- // Appender was not previously initialized.
- final String prefix = APPENDER_PREFIX + appenderName;
- final String layoutPrefix = prefix + ".layout";
-
- appender =
- (Appender) OptionConverter.instantiateByKey(properties, prefix, org.apache.log4j.Appender.class, null);
- if (appender == null) {
- LogLog.error("Could not instantiate appender named \"" + appenderName + "\".");
- return null;
- }
- appender.setName(appenderName);
-
- if (appender instanceof OptionHandler) {
- if (appender.requiresLayout()) {
- final Layout layout =
- (Layout) OptionConverter.instantiateByKey(properties, layoutPrefix, Layout.class, null);
- if (layout != null) {
- appender.setLayout(layout);
- LogLog.debug("Parsing layout options for \"" + appenderName + "\".");
- // configureOptionHandler(layout, layoutPrefix + ".", props);
- PropertySetter.setProperties(layout, properties, layoutPrefix + ".");
- LogLog.debug("End of parsing for \"" + appenderName + "\".");
- }
- }
- final String errorHandlerPrefix = prefix + ".errorhandler";
- final String errorHandlerClass = OptionConverter.findAndSubst(errorHandlerPrefix, properties);
- if (errorHandlerClass != null) {
- final ErrorHandler eh = (ErrorHandler)
- OptionConverter.instantiateByKey(properties, errorHandlerPrefix, ErrorHandler.class, null);
- if (eh != null) {
- appender.setErrorHandler(eh);
- LogLog.debug("Parsing errorhandler options for \"" + appenderName + "\".");
- parseErrorHandler(eh, errorHandlerPrefix, properties, repository);
- final Properties edited = new Properties();
- final String[] keys = new String[] {
- errorHandlerPrefix + "." + ROOT_REF,
- errorHandlerPrefix + "." + LOGGER_REF,
- errorHandlerPrefix + "." + APPENDER_REF_TAG
- };
- for (final Object element : properties.entrySet()) {
- final Map.Entry entry = (Map.Entry) element;
- int i = 0;
- for (; i < keys.length; i++) {
- if (keys[i].equals(entry.getKey())) {
- break;
- }
- }
- if (i == keys.length) {
- edited.put(entry.getKey(), entry.getValue());
- }
- }
- PropertySetter.setProperties(eh, edited, errorHandlerPrefix + ".");
- LogLog.debug("End of errorhandler parsing for \"" + appenderName + "\".");
- }
- }
- // configureOptionHandler((OptionHandler) appender, prefix + ".", props);
- PropertySetter.setProperties(appender, properties, prefix + ".");
- LogLog.debug("Parsed \"" + appenderName + "\" options.");
- }
- parseAppenderFilters(properties, appenderName, appender);
- registryPut(appender);
- return appender;
- }
-
- void parseAppenderFilters(final Properties properties, final String appenderName, final Appender appender) {
- // extract filters and filter options from props into a hashtable mapping
- // the property name defining the filter class to a list of pre-parsed
- // name-value pairs associated to that filter
- final String filterPrefix = APPENDER_PREFIX + appenderName + ".filter.";
- final int fIdx = filterPrefix.length();
- final Hashtable filters = new Hashtable();
- final Enumeration e = properties.keys();
- String name = "";
- while (e.hasMoreElements()) {
- final String key = (String) e.nextElement();
- if (key.startsWith(filterPrefix)) {
- final int dotIdx = key.indexOf('.', fIdx);
- String filterKey = key;
- if (dotIdx != -1) {
- filterKey = key.substring(0, dotIdx);
- name = key.substring(dotIdx + 1);
- }
- Vector filterOpts = (Vector) filters.get(filterKey);
- if (filterOpts == null) {
- filterOpts = new Vector();
- filters.put(filterKey, filterOpts);
- }
- if (dotIdx != -1) {
- final String value = OptionConverter.findAndSubst(key, properties);
- filterOpts.add(new NameValue(name, value));
- }
- }
- }
-
- // sort filters by IDs, insantiate filters, set filter options,
- // add filters to the appender
- final Enumeration g = new SortedKeyEnumeration(filters);
- Filter head = null;
- while (g.hasMoreElements()) {
- final String key = (String) g.nextElement();
- final String clazz = properties.getProperty(key);
- if (clazz != null) {
- LogLog.debug("Filter key: [" + key + "] class: [" + properties.getProperty(key) + "] props: "
- + filters.get(key));
- final Filter filter = (Filter) OptionConverter.instantiateByClassName(clazz, Filter.class, null);
- if (filter != null) {
- final PropertySetter propSetter = new PropertySetter(filter);
- final Vector v = (Vector) filters.get(key);
- final Enumeration filterProps = v.elements();
- while (filterProps.hasMoreElements()) {
- final NameValue kv = (NameValue) filterProps.nextElement();
- propSetter.setProperty(kv.key, kv.value);
- }
- propSetter.activate();
- LogLog.debug("Adding filter of type [" + filter.getClass() + "] to appender named ["
- + appender.getName() + "].");
- head = FilterAdapter.addFilter(head, filter);
- }
- } else {
- LogLog.warn("Missing class definition for filter: [" + key + "]");
- }
- }
- appender.addFilter(head);
- }
-
- /**
- * This method must work for the root category as well.
- */
- void parseCategory(
- final Properties properties,
- final Logger logger,
- final String optionKey,
- final String loggerName,
- final String value) {
-
- LogLog.debug("Parsing for [" + loggerName + "] with value=[" + value + "].");
- // We must skip over ',' but not white space
- final StringTokenizer st = new StringTokenizer(value, ",");
-
- // If value is not in the form ", appender.." or "", then we should set
- // the level of the loggeregory.
-
- if (!(value.startsWith(",") || value.isEmpty())) {
-
- // just to be on the safe side...
- if (!st.hasMoreTokens()) {
- return;
- }
-
- final String levelStr = st.nextToken();
- LogLog.debug("Level token is [" + levelStr + "].");
-
- // If the level value is inherited, set category level value to
- // null. We also check that the user has not specified inherited for the
- // root category.
- if (INHERITED.equalsIgnoreCase(levelStr) || NULL.equalsIgnoreCase(levelStr)) {
- if (loggerName.equals(INTERNAL_ROOT_NAME)) {
- LogLog.warn("The root logger cannot be set to null.");
- } else {
- logger.setLevel(null);
- }
- } else {
- logger.setLevel(OptionConverter.toLevel(levelStr, Log4j1Configuration.DEFAULT_LEVEL));
- }
- LogLog.debug("Category " + loggerName + " set to " + logger.getLevel());
- }
-
- // Begin by removing all existing appenders.
- logger.removeAllAppenders();
-
- Appender appender;
- String appenderName;
- while (st.hasMoreTokens()) {
- appenderName = st.nextToken().trim();
- if (appenderName == null || appenderName.equals(",")) {
- continue;
- }
- LogLog.debug("Parsing appender named \"" + appenderName + "\".");
- appender = parseAppender(properties, appenderName);
- if (appender != null) {
- logger.addAppender(appender);
- }
- }
- }
-
- /**
- * Parse non-root elements, such non-root categories and renderers.
- */
- protected void parseCatsAndRenderers(final Properties properties, final LoggerRepository loggerRepository) {
- final Enumeration enumeration = properties.propertyNames();
- while (enumeration.hasMoreElements()) {
- final String key = (String) enumeration.nextElement();
- if (key.startsWith(CATEGORY_PREFIX) || key.startsWith(LOGGER_PREFIX)) {
- String loggerName = null;
- if (key.startsWith(CATEGORY_PREFIX)) {
- loggerName = key.substring(CATEGORY_PREFIX.length());
- } else if (key.startsWith(LOGGER_PREFIX)) {
- loggerName = key.substring(LOGGER_PREFIX.length());
- }
- final String value = OptionConverter.findAndSubst(key, properties);
- final Logger logger = loggerRepository.getLogger(loggerName, loggerFactory);
- synchronized (logger) {
- parseCategory(properties, logger, key, loggerName, value);
- parseAdditivityForLogger(properties, logger, loggerName);
- }
- } else if (key.startsWith(RENDERER_PREFIX)) {
- final String renderedClass = key.substring(RENDERER_PREFIX.length());
- final String renderingClass = OptionConverter.findAndSubst(key, properties);
- if (loggerRepository instanceof RendererSupport) {
- RendererMap.addRenderer((RendererSupport) loggerRepository, renderedClass, renderingClass);
- }
- } else if (key.equals(THROWABLE_RENDERER_PREFIX)) {
- if (loggerRepository instanceof ThrowableRendererSupport) {
- final ThrowableRenderer tr = (ThrowableRenderer) OptionConverter.instantiateByKey(
- properties, THROWABLE_RENDERER_PREFIX, org.apache.log4j.spi.ThrowableRenderer.class, null);
- if (tr == null) {
- LogLog.error("Could not instantiate throwableRenderer.");
- } else {
- final PropertySetter setter = new PropertySetter(tr);
- setter.setProperties(properties, THROWABLE_RENDERER_PREFIX + ".");
- ((ThrowableRendererSupport) loggerRepository).setThrowableRenderer(tr);
- }
- }
- }
- }
- }
-
- private void parseErrorHandler(
- final ErrorHandler errorHandler,
- final String errorHandlerPrefix,
- final Properties props,
- final LoggerRepository loggerRepository) {
- if (errorHandler != null && loggerRepository != null) {
- final boolean rootRef = OptionConverter.toBoolean(
- OptionConverter.findAndSubst(errorHandlerPrefix + ROOT_REF, props), false);
- if (rootRef) {
- errorHandler.setLogger(loggerRepository.getRootLogger());
- }
- final String loggerName = OptionConverter.findAndSubst(errorHandlerPrefix + LOGGER_REF, props);
- if (loggerName != null) {
- final Logger logger = loggerFactory == null
- ? loggerRepository.getLogger(loggerName)
- : loggerRepository.getLogger(loggerName, loggerFactory);
- errorHandler.setLogger(logger);
- }
- final String appenderName = OptionConverter.findAndSubst(errorHandlerPrefix + APPENDER_REF_TAG, props);
- if (appenderName != null) {
- final Appender backup = parseAppender(props, appenderName);
- if (backup != null) {
- errorHandler.setBackupAppender(backup);
- }
- }
- }
- }
-
- Appender registryGet(final String name) {
- return (Appender) registry.get(name);
- }
-
- void registryPut(final Appender appender) {
- registry.put(appender.getName(), appender);
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/ProvisionNode.java b/log4j-1.2-api/src/main/java/org/apache/log4j/ProvisionNode.java
deleted file mode 100644
index 0ac82732e6e..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/ProvisionNode.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-import java.util.Vector;
-
-class ProvisionNode extends Vector {
- private static final long serialVersionUID = -4479121426311014469L;
-
- ProvisionNode(final Logger logger) {
- super();
- this.addElement(logger);
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/RenderedMessage.java b/log4j-1.2-api/src/main/java/org/apache/log4j/RenderedMessage.java
deleted file mode 100644
index 5e6fbcf9d44..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/RenderedMessage.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-import org.apache.log4j.or.ObjectRenderer;
-import org.apache.logging.log4j.message.Message;
-
-/**
- * Implements object rendering for Log4j 1.x compatibility.
- */
-public class RenderedMessage implements Message {
-
- private final ObjectRenderer renderer;
- private final Object object;
- private String rendered = null;
-
- public RenderedMessage(final ObjectRenderer renderer, final Object object) {
- this.renderer = renderer;
- this.object = object;
- }
-
- @Override
- public String getFormattedMessage() {
- if (rendered == null) {
- rendered = renderer.doRender(object);
- }
-
- return rendered;
- }
-
- @Override
- public String getFormat() {
- return getFormattedMessage();
- }
-
- @Override
- public Object[] getParameters() {
- return null;
- }
-
- @Override
- public Throwable getThrowable() {
- return null;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/RollingFileAppender.java b/log4j-1.2-api/src/main/java/org/apache/log4j/RollingFileAppender.java
deleted file mode 100644
index ce03ec2bc8a..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/RollingFileAppender.java
+++ /dev/null
@@ -1,255 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.io.File;
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.io.Writer;
-import org.apache.log4j.helpers.CountingQuietWriter;
-import org.apache.log4j.helpers.LogLog;
-import org.apache.log4j.helpers.OptionConverter;
-import org.apache.log4j.spi.LoggingEvent;
-
-/**
- * RollingFileAppender extends FileAppender to backup the log files when they reach a certain size.
- *
- * The log4j extras companion includes alternatives which should be considered for new deployments and which are
- * discussed in the documentation for org.apache.log4j.rolling.RollingFileAppender.
- */
-public class RollingFileAppender extends FileAppender {
-
- /**
- * The default maximum file size is 10MB.
- */
- protected long maxFileSize = 10 * 1024 * 1024;
-
- /**
- * There is one backup file by default.
- */
- protected int maxBackupIndex = 1;
-
- private long nextRollover = 0;
-
- /**
- * The default constructor simply calls its {@link FileAppender#FileAppender parents constructor}.
- */
- public RollingFileAppender() {
- super();
- }
-
- /**
- * Constructs a RollingFileAppender and open the file designated by filename
. The opened filename will
- * become the ouput destination for this appender.
- *
- *
- * If the append
parameter is true, the file will be appended to. Otherwise, the file desginated by
- * filename
will be truncated before being opened.
- *
- */
- public RollingFileAppender(final Layout layout, final String filename, final boolean append) throws IOException {
- super(layout, filename, append);
- }
-
- /**
- * Constructs a FileAppender and open the file designated by filename
. The opened filename will become the
- * output destination for this appender.
- *
- *
- * The file will be appended to.
- *
- */
- public RollingFileAppender(final Layout layout, final String filename) throws IOException {
- super(layout, filename);
- }
-
- /**
- * Gets the value of the MaxBackupIndex option.
- */
- public int getMaxBackupIndex() {
- return maxBackupIndex;
- }
-
- /**
- * Gets the maximum size that the output file is allowed to reach before being rolled over to backup files.
- *
- * @since 1.1
- */
- public long getMaximumFileSize() {
- return maxFileSize;
- }
-
- /**
- * Implements the usual roll over behaviour.
- *
- * If MaxBackupIndex
is positive, then files {File.1
, ...,
- * File.MaxBackupIndex -1
} are renamed to {File.2
, ..., File.MaxBackupIndex
}.
- * Moreover, File
is renamed File.1
and closed. A new File
is created to receive
- * further log output.
- *
- *
- * If MaxBackupIndex
is equal to zero, then the File
is truncated with no backup files
- * created.
- *
- */
- @SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "The filename comes from a system property.")
- public // synchronization not necessary since doAppend is alreasy synched
- void rollOver() {
- File target;
- File file;
-
- if (qw != null) {
- final long size = ((CountingQuietWriter) qw).getCount();
- LogLog.debug("rolling over count=" + size);
- // if operation fails, do not roll again until
- // maxFileSize more bytes are written
- nextRollover = size + maxFileSize;
- }
- LogLog.debug("maxBackupIndex=" + maxBackupIndex);
-
- boolean renameSucceeded = true;
- // If maxBackups <= 0, then there is no file renaming to be done.
- if (maxBackupIndex > 0) {
- // Delete the oldest file, to keep Windows happy.
- file = new File(fileName + '.' + maxBackupIndex);
- if (file.exists()) renameSucceeded = file.delete();
-
- // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2}
- for (int i = maxBackupIndex - 1; i >= 1 && renameSucceeded; i--) {
- file = new File(fileName + "." + i);
- if (file.exists()) {
- target = new File(fileName + '.' + (i + 1));
- LogLog.debug("Renaming file " + file + " to " + target);
- renameSucceeded = file.renameTo(target);
- }
- }
-
- if (renameSucceeded) {
- // Rename fileName to fileName.1
- target = new File(fileName + "." + 1);
-
- this.closeFile(); // keep windows happy.
-
- file = new File(fileName);
- LogLog.debug("Renaming file " + file + " to " + target);
- renameSucceeded = file.renameTo(target);
- //
- // if file rename failed, reopen file with append = true
- //
- if (!renameSucceeded) {
- try {
- this.setFile(fileName, true, bufferedIO, bufferSize);
- } catch (IOException e) {
- if (e instanceof InterruptedIOException) {
- Thread.currentThread().interrupt();
- }
- LogLog.error("setFile(" + fileName + ", true) call failed.", e);
- }
- }
- }
- }
-
- //
- // if all renames were successful, then
- //
- if (renameSucceeded) {
- try {
- // This will also close the file. This is OK since multiple
- // close operations are safe.
- this.setFile(fileName, false, bufferedIO, bufferSize);
- nextRollover = 0;
- } catch (IOException e) {
- if (e instanceof InterruptedIOException) {
- Thread.currentThread().interrupt();
- }
- LogLog.error("setFile(" + fileName + ", false) call failed.", e);
- }
- }
- }
-
- @SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "The file name comes from a configuration file.")
- public synchronized void setFile(
- final String fileName, final boolean append, final boolean bufferedIO, final int bufferSize)
- throws IOException {
- super.setFile(fileName, append, this.bufferedIO, this.bufferSize);
- if (append) {
- final File f = new File(fileName);
- ((CountingQuietWriter) qw).setCount(f.length());
- }
- }
-
- /**
- * Sets the maximum number of backup files to keep around.
- *
- *
- * The MaxBackupIndex option determines how many backup files are kept before the oldest is erased. This option
- * takes a positive integer value. If set to zero, then there will be no backup files and the log file will be truncated
- * when it reaches MaxFileSize
.
- *
- */
- public void setMaxBackupIndex(final int maxBackups) {
- this.maxBackupIndex = maxBackups;
- }
-
- /**
- * Sets the maximum size that the output file is allowed to reach before being rolled over to backup files.
- *
- *
- * This method is equivalent to {@link #setMaxFileSize} except that it is required for differentiating the setter taking
- * a long
argument from the setter taking a String
argument by the JavaBeans
- * {@link java.beans.Introspector Introspector}.
- *
- *
- * @see #setMaxFileSize(String)
- */
- public void setMaximumFileSize(long maxFileSize) {
- this.maxFileSize = maxFileSize;
- }
-
- /**
- * Sets the maximum size that the output file is allowed to reach before being rolled over to backup files.
- *
- *
- * In configuration files, the MaxFileSize option takes an long integer in the range 0 - 2^63. You can specify
- * the value with the suffixes "KB", "MB" or "GB" so that the integer is interpreted being expressed respectively in
- * kilobytes, megabytes or gigabytes. For example, the value "10KB" will be interpreted as 10240.
- *
- */
- public void setMaxFileSize(final String value) {
- maxFileSize = OptionConverter.toFileSize(value, maxFileSize + 1);
- }
-
- protected void setQWForFiles(final Writer writer) {
- this.qw = new CountingQuietWriter(writer, errorHandler);
- }
-
- /**
- * This method differentiates RollingFileAppender from its super class.
- *
- * @since 0.9.0
- */
- protected void subAppend(final LoggingEvent event) {
- super.subAppend(event);
- if (fileName != null && qw != null) {
- final long size = ((CountingQuietWriter) qw).getCount();
- if (size >= maxFileSize && size >= nextRollover) {
- rollOver();
- }
- }
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/SimpleLayout.java b/log4j-1.2-api/src/main/java/org/apache/log4j/SimpleLayout.java
deleted file mode 100644
index 1fd0ee76f26..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/SimpleLayout.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.logging.log4j.util.Strings;
-
-/**
- * Simple-layout.
- */
-public class SimpleLayout extends Layout {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String format(final LoggingEvent theEvent) {
- return Strings.EMPTY;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean ignoresThrowable() {
- return true;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/VectorAppender.java b/log4j-1.2-api/src/main/java/org/apache/log4j/VectorAppender.java
deleted file mode 100644
index 678705a6f74..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/VectorAppender.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-import java.util.Vector;
-import org.apache.log4j.spi.LoggingEvent;
-
-/**
- * Appends logging events to a vector.
- */
-public class VectorAppender extends AppenderSkeleton {
-
- public Vector vector;
-
- public VectorAppender() {
- vector = new Vector();
- }
-
- /**
- * Does nothing.
- */
- @Override
- public void activateOptions() {
- // noop
- }
-
- /**
- * This method is called by the {@link AppenderSkeleton#doAppend} method.
- *
- */
- @Override
- public void append(final LoggingEvent event) {
- // System.out.println("---Vector appender called with message ["+event.getRenderedMessage()+"].");
- // System.out.flush();
- try {
- Thread.sleep(100);
- } catch (final Exception e) {
- // ignore
- }
- vector.addElement(event);
- }
-
- @Override
- public synchronized void close() {
- if (this.closed) {
- return;
- }
- this.closed = true;
- }
-
- public Vector getVector() {
- return vector;
- }
-
- public boolean isClosed() {
- return closed;
- }
-
- @Override
- public boolean requiresLayout() {
- return false;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/WriterAppender.java b/log4j-1.2-api/src/main/java/org/apache/log4j/WriterAppender.java
deleted file mode 100644
index 23f731077bc..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/WriterAppender.java
+++ /dev/null
@@ -1,381 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-import java.io.Writer;
-import org.apache.log4j.helpers.QuietWriter;
-import org.apache.log4j.spi.ErrorHandler;
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.logging.log4j.status.StatusLogger;
-
-/**
- * WriterAppender appends log events to a {@link Writer} or an
- * {@link OutputStream} depending on the user's choice.
- */
-public class WriterAppender extends AppenderSkeleton {
- private static final org.apache.logging.log4j.Logger LOGGER = StatusLogger.getLogger();
-
- /**
- * Immediate flush means that the underlying writer or output stream
- * will be flushed at the end of each append operation unless shouldFlush()
- * is overridden. Immediate
- * flush is slower but ensures that each append request is actually
- * written. If immediateFlush
is set to
- * false
, then there is a good chance that the last few
- * logs events are not actually written to persistent media if and
- * when the application crashes.
- *
- * The immediateFlush
variable is set to
- * true
by default.
- */
- protected boolean immediateFlush = true;
-
- /**
- * The encoding to use when writing.
The
- * encoding
variable is set to null
by
- * default which results in the utilization of the system's default
- * encoding.
- */
- protected String encoding;
-
- /**
- * This is the {@link QuietWriter quietWriter} where we will write
- * to.
- */
- protected QuietWriter qw;
-
- /**
- * This default constructor does nothing.
- */
- public WriterAppender() {}
-
- /**
- * Instantiate a WriterAppender and set the output destination to a
- * new {@link OutputStreamWriter} initialized with os
- * as its {@link OutputStream}.
- * @param layout The Layout.
- * @param os The OutputStream.
- */
- public WriterAppender(final Layout layout, final OutputStream os) {
- this(layout, new OutputStreamWriter(os));
- }
-
- /**
- * Instantiate a WriterAppender and set the output destination to
- * writer
.
- *
- *
The writer
must have been previously opened by
- * the user.
- *
- * @param layout The Layout.
- * @param writer The Writer.
- */
- public WriterAppender(final Layout layout, final Writer writer) {
- this.layout = layout;
- this.setWriter(writer);
- }
-
- /**
- * Returns value of the ImmediateFlush option.
- * @return the value of the immediate flush setting.
- */
- public boolean getImmediateFlush() {
- return immediateFlush;
- }
-
- /**
- * If the ImmediateFlush option is set to
- * true
, the appender will flush at the end of each
- * write. This is the default behavior. If the option is set to
- * false
, then the underlying stream can defer writing
- * to physical medium to a later time.
- *
- *
Avoiding the flush operation at the end of each append results in
- * a performance gain of 10 to 20 percent. However, there is safety
- * tradeoff involved in skipping flushing. Indeed, when flushing is
- * skipped, then it is likely that the last few log events will not
- * be recorded on disk when the application exits. This is a high
- * price to pay even for a 20% performance gain.
- *
- * @param value the value to set the immediate flush setting to.
- */
- public void setImmediateFlush(final boolean value) {
- immediateFlush = value;
- }
-
- /**
- * Does nothing.
- */
- @Override
- public void activateOptions() {}
-
- /**
- * This method is called by the {@link AppenderSkeleton#doAppend}
- * method.
- *
- *
If the output stream exists and is writable then write a log
- * statement to the output stream. Otherwise, write a single warning
- * message to System.err
.
- *
- *
The format of the output will depend on this appender's
- * layout.
- */
- @Override
- public void append(final LoggingEvent event) {
-
- // Reminder: the nesting of calls is:
- //
- // doAppend()
- // - check threshold
- // - filter
- // - append();
- // - checkEntryConditions();
- // - subAppend();
-
- if (!checkEntryConditions()) {
- return;
- }
- subAppend(event);
- }
-
- /**
- * This method determines if there is a sense in attempting to append.
- *
- *
It checks whether there is a set output target and also if
- * there is a set layout. If these checks fail, then the boolean
- * value false
is returned.
- * @return true if appending is allowed, false otherwise.
- */
- protected boolean checkEntryConditions() {
- if (this.closed) {
- LOGGER.warn("Not allowed to write to a closed appender.");
- return false;
- }
-
- if (this.qw == null) {
- errorHandler.error("No output stream or file set for the appender named [" + name + "].");
- return false;
- }
-
- if (this.layout == null) {
- errorHandler.error("No layout set for the appender named [" + name + "].");
- return false;
- }
- return true;
- }
-
- /**
- * Close this appender instance. The underlying stream or writer is
- * also closed.
- *
- *
Closed appenders cannot be reused.
- *
- * @see #setWriter
- * @since 0.8.4
- */
- @Override
- public synchronized void close() {
- if (this.closed) {
- return;
- }
- this.closed = true;
- writeFooter();
- reset();
- }
-
- /**
- * Close the underlying {@link Writer}.
- */
- protected void closeWriter() {
- if (qw != null) {
- try {
- qw.close();
- } catch (IOException e) {
- if (e instanceof InterruptedIOException) {
- Thread.currentThread().interrupt();
- }
- // There is do need to invoke an error handler at this late
- // stage.
- LOGGER.error("Could not close " + qw, e);
- }
- }
- }
-
- /**
- * Returns an OutputStreamWriter when passed an OutputStream. The
- * encoding used will depend on the value of the
- * encoding
property. If the encoding value is
- * specified incorrectly the writer will be opened using the default
- * system encoding (an error message will be printed to the LOGGER.
- * @param os The OutputStream.
- * @return The OutputStreamWriter.
- */
- protected OutputStreamWriter createWriter(final OutputStream os) {
- OutputStreamWriter retval = null;
-
- final String enc = getEncoding();
- if (enc != null) {
- try {
- retval = new OutputStreamWriter(os, enc);
- } catch (final UnsupportedEncodingException e) {
- LOGGER.warn("Error initializing output writer: encoding {} is not supported.", enc, e);
- }
- }
- if (retval == null) {
- retval = new OutputStreamWriter(os);
- }
- return retval;
- }
-
- public String getEncoding() {
- return encoding;
- }
-
- public void setEncoding(final String value) {
- encoding = value;
- }
-
- /**
- * Set the {@link ErrorHandler} for this WriterAppender and also the
- * underlying {@link QuietWriter} if any.
- */
- @Override
- public synchronized void setErrorHandler(final ErrorHandler eh) {
- if (eh == null) {
- LOGGER.warn("You have tried to set a null error-handler.");
- } else {
- this.errorHandler = eh;
- if (this.qw != null) {
- this.qw.setErrorHandler(eh);
- }
- }
- }
-
- /**
- *
Sets the Writer where the log output will go. The
- * specified Writer must be opened by the user and be
- * writable.
- *
- *
The java.io.Writer
will be closed when the
- * appender instance is closed.
- *
- *
- *
WARNING: Logging to an unopened Writer will fail.
- *
- *
- * @param writer An already opened Writer.
- */
- public synchronized void setWriter(final Writer writer) {
- reset();
- this.qw = new QuietWriter(writer, errorHandler);
- // this.tp = new TracerPrintWriter(qw);
- writeHeader();
- }
-
- /**
- * Actual writing occurs here.
- *
- *
Most subclasses of WriterAppender
will need to
- * override this method.
- * @param event The event to log.
- *
- * @since 0.9.0
- */
- protected void subAppend(final LoggingEvent event) {
- this.qw.write(this.layout.format(event));
-
- if (layout.ignoresThrowable()) {
- final String[] s = event.getThrowableStrRep();
- if (s != null) {
- final int len = s.length;
- for (int i = 0; i < len; i++) {
- this.qw.write(s[i]);
- this.qw.write(Layout.LINE_SEP);
- }
- }
- }
-
- if (shouldFlush(event)) {
- this.qw.flush();
- }
- }
-
- /**
- * The WriterAppender requires a layout. Hence, this method returns
- * true
.
- */
- @Override
- public boolean requiresLayout() {
- return true;
- }
-
- /**
- * Clear internal references to the writer and other variables.
- *
- * Subclasses can override this method for an alternate closing
- * behavior.
- */
- protected void reset() {
- closeWriter();
- this.qw = null;
- // this.tp = null;
- }
-
- /**
- * Write a footer as produced by the embedded layout's {@link
- * Layout#getFooter} method.
- */
- protected void writeFooter() {
- if (layout != null) {
- final String f = layout.getFooter();
- if (f != null && this.qw != null) {
- this.qw.write(f);
- this.qw.flush();
- }
- }
- }
-
- /**
- * Write a header as produced by the embedded layout's {@link
- * Layout#getHeader} method.
- */
- protected void writeHeader() {
- if (layout != null) {
- final String h = layout.getHeader();
- if (h != null && this.qw != null) {
- this.qw.write(h);
- }
- }
- }
-
- /**
- * Determines whether the writer should be flushed after
- * this event is written.
- * @param event The event to log.
- * @return true if the writer should be flushed.
- *
- * @since 1.2.16
- */
- protected boolean shouldFlush(final LoggingEvent event) {
- return immediateFlush;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/AppenderAdapter.java b/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/AppenderAdapter.java
deleted file mode 100644
index 411258e20f0..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/AppenderAdapter.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.bridge;
-
-import org.apache.log4j.Appender;
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.appender.AbstractAppender;
-import org.apache.logging.log4j.core.config.Property;
-import org.apache.logging.log4j.util.Strings;
-
-/**
- * Binds a Log4j 1.x Appender to Log4j 2.
- */
-public final class AppenderAdapter {
-
- private final Appender appender;
- private final Adapter adapter;
-
- /**
- * Adapts a Log4j 1.x appender into a Log4j 2.x appender. Applying this method
- * on the result of
- * {@link AppenderWrapper#adapt(org.apache.logging.log4j.core.Appender)} should
- * return the original Log4j 2.x appender.
- *
- * @param appender a Log4j 1.x appender
- * @return a Log4j 2.x appender or {@code null} if the parameter is {@code null}
- */
- public static org.apache.logging.log4j.core.Appender adapt(final Appender appender) {
- if (appender instanceof org.apache.logging.log4j.core.Appender) {
- return (org.apache.logging.log4j.core.Appender) appender;
- }
- if (appender instanceof AppenderWrapper) {
- return ((AppenderWrapper) appender).getAppender();
- }
- if (appender != null) {
- return new AppenderAdapter(appender).getAdapter();
- }
- return null;
- }
-
- /**
- * Constructor.
- * @param appender The Appender to wrap.
- */
- private AppenderAdapter(final Appender appender) {
- this.appender = appender;
- final org.apache.logging.log4j.core.Filter appenderFilter = FilterAdapter.adapt(appender.getFilter());
- String name = appender.getName();
- if (Strings.isEmpty(name)) {
- name = String.format("0x%08x", appender.hashCode());
- }
- this.adapter = new Adapter(name, appenderFilter, null, true, null);
- }
-
- public Adapter getAdapter() {
- return adapter;
- }
-
- public class Adapter extends AbstractAppender {
-
- protected Adapter(
- final String name,
- final Filter filter,
- final Layout layout,
- final boolean ignoreExceptions,
- final Property[] properties) {
- super(name, filter, layout, ignoreExceptions, properties);
- }
-
- @Override
- public void append(final LogEvent event) {
- appender.doAppend(new LogEventAdapter(event));
- }
-
- @Override
- public void stop() {
- appender.close();
- }
-
- public Appender getAppender() {
- return appender;
- }
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/AppenderWrapper.java b/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/AppenderWrapper.java
deleted file mode 100644
index 36a96be1315..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/AppenderWrapper.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.bridge;
-
-import org.apache.log4j.Appender;
-import org.apache.log4j.Layout;
-import org.apache.log4j.bridge.AppenderAdapter.Adapter;
-import org.apache.log4j.spi.ErrorHandler;
-import org.apache.log4j.spi.Filter;
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.filter.AbstractFilterable;
-import org.apache.logging.log4j.status.StatusLogger;
-
-/**
- * Wraps a Log4j 2 Appender in an empty Log4j 1 Appender so it can be extracted when constructing the configuration.
- * Allows a Log4j 1 Appender to reference a Log4j 2 Appender.
- */
-public class AppenderWrapper implements Appender {
-
- private static final Logger LOGGER = StatusLogger.getLogger();
- private final org.apache.logging.log4j.core.Appender appender;
-
- /**
- * Adapts a Log4j 2.x appender into a Log4j 1.x appender. Applying this method
- * on the result of {@link AppenderAdapter#adapt(Appender)} should return the
- * original Log4j 1.x appender.
- *
- * @param appender a Log4j 2.x appender
- * @return a Log4j 1.x appender or {@code null} if the parameter is {@code null}
- */
- public static Appender adapt(final org.apache.logging.log4j.core.Appender appender) {
- if (appender instanceof Appender) {
- return (Appender) appender;
- }
- if (appender instanceof Adapter) {
- final Adapter adapter = (Adapter) appender;
- // Don't unwrap an appender with filters
- if (!adapter.hasFilter()) {
- return adapter.getAppender();
- }
- }
- if (appender != null) {
- return new AppenderWrapper(appender);
- }
- return null;
- }
-
- /**
- * Constructs a new instance for a Core Appender.
- *
- * @param appender a Core Appender.
- */
- public AppenderWrapper(final org.apache.logging.log4j.core.Appender appender) {
- this.appender = appender;
- }
-
- /**
- * Gets the wrapped Core Appender.
- *
- * @return the wrapped Core Appender.
- */
- public org.apache.logging.log4j.core.Appender getAppender() {
- return appender;
- }
-
- @Override
- public void addFilter(final Filter newFilter) {
- if (appender instanceof AbstractFilterable) {
- ((AbstractFilterable) appender).addFilter(FilterAdapter.adapt(newFilter));
- } else {
- LOGGER.warn("Unable to add filter to appender {}, it does not support filters", appender.getName());
- }
- }
-
- @Override
- public Filter getFilter() {
- return null;
- }
-
- @Override
- public void clearFilters() {
- // noop
- }
-
- @Override
- public void close() {
- // Not supported with Log4j 2.
- }
-
- @Override
- public void doAppend(final LoggingEvent event) {
- if (event instanceof LogEventAdapter) {
- appender.append(((LogEventAdapter) event).getEvent());
- }
- }
-
- @Override
- public String getName() {
- return appender.getName();
- }
-
- @Override
- public void setErrorHandler(final ErrorHandler errorHandler) {
- appender.setHandler(new ErrorHandlerAdapter(errorHandler));
- }
-
- @Override
- public ErrorHandler getErrorHandler() {
- return ((ErrorHandlerAdapter) appender.getHandler()).getHandler();
- }
-
- @Override
- public void setLayout(final Layout layout) {
- // Log4j 2 doesn't support this.
- }
-
- @Override
- public Layout getLayout() {
- return new LayoutWrapper(appender.getLayout());
- }
-
- @Override
- public void setName(final String name) {
- // Log4j 2 doesn't support this.
- }
-
- @Override
- public boolean requiresLayout() {
- return false;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/ErrorHandlerAdapter.java b/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/ErrorHandlerAdapter.java
deleted file mode 100644
index 72354d899b7..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/ErrorHandlerAdapter.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.bridge;
-
-import org.apache.log4j.spi.ErrorHandler;
-import org.apache.logging.log4j.core.LogEvent;
-
-/**
- * Makes a Log4j 1 ErrorHandler usable by a Log4j 2 Appender.
- */
-public class ErrorHandlerAdapter implements org.apache.logging.log4j.core.ErrorHandler {
-
- private final ErrorHandler errorHandler;
-
- public ErrorHandlerAdapter(final ErrorHandler errorHandler) {
- this.errorHandler = errorHandler;
- }
-
- public ErrorHandler getHandler() {
- return errorHandler;
- }
-
- @Override
- public void error(final String msg) {
- errorHandler.error(msg);
- }
-
- @Override
- public void error(final String msg, final Throwable t) {
- if (t instanceof Exception) {
- errorHandler.error(msg, (Exception) t, 0);
- } else {
- errorHandler.error(msg);
- }
- }
-
- @Override
- public void error(final String msg, final LogEvent event, final Throwable t) {
- if (t == null || t instanceof Exception) {
- errorHandler.error(msg, (Exception) t, 0, new LogEventAdapter(event));
- } else {
- errorHandler.error(msg);
- }
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/FilterAdapter.java b/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/FilterAdapter.java
deleted file mode 100644
index c01d179da43..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/FilterAdapter.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.bridge;
-
-import org.apache.log4j.spi.Filter;
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.filter.AbstractFilter;
-import org.apache.logging.log4j.core.filter.CompositeFilter;
-
-/**
- * Binds a Log4j 1.x Filter with Log4j 2.
- */
-public final class FilterAdapter extends AbstractFilter {
-
- private final Filter filter;
-
- /**
- * Adapts a Log4j 1.x filter into a Log4j 2.x filter. Applying this method to
- * the result of
- * {@link FilterWrapper#adapt(org.apache.logging.log4j.core.Filter)} should
- * return the original Log4j 2.x filter.
- *
- * @param filter a Log4j 1.x filter
- * @return a Log4j 2.x filter or {@code null} if the parameter is {@code null}
- */
- public static org.apache.logging.log4j.core.Filter adapt(final Filter filter) {
- if (filter instanceof org.apache.logging.log4j.core.Filter) {
- return (org.apache.logging.log4j.core.Filter) filter;
- }
- // Don't unwrap the head of a filter chain
- if (filter instanceof FilterWrapper && filter.getNext() == null) {
- return ((FilterWrapper) filter).getFilter();
- }
- if (filter != null) {
- return new FilterAdapter(filter);
- }
- return null;
- }
-
- /**
- * Appends one filter to another using Log4j 2.x concatenation utilities.
- * @param first
- * @param second
- * @return
- */
- public static Filter addFilter(final Filter first, final Filter second) {
- if (first == null) {
- return second;
- }
- if (second == null) {
- return first;
- }
- final CompositeFilter composite;
- if (first instanceof FilterWrapper && ((FilterWrapper) first).getFilter() instanceof CompositeFilter) {
- composite = (CompositeFilter) ((FilterWrapper) first).getFilter();
- } else {
- composite = CompositeFilter.createFilters(new org.apache.logging.log4j.core.Filter[] {adapt(first)});
- }
- return FilterWrapper.adapt(composite.addFilter(adapt(second)));
- }
-
- private FilterAdapter(final Filter filter) {
- this.filter = filter;
- }
-
- @Override
- public Result filter(final LogEvent event) {
- final LoggingEvent loggingEvent = new LogEventAdapter(event);
- Filter next = filter;
- while (next != null) {
- switch (next.decide(loggingEvent)) {
- case Filter.ACCEPT:
- return Result.ACCEPT;
- case Filter.DENY:
- return Result.DENY;
- default:
- }
- next = next.getNext();
- }
- return Result.NEUTRAL;
- }
-
- /**
- * Gets the actual filter.
- *
- * @return the actual filter.
- * @since 2.17.1
- */
- public Filter getFilter() {
- return filter;
- }
-
- @Override
- public void start() {
- filter.activateOptions();
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/FilterWrapper.java b/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/FilterWrapper.java
deleted file mode 100644
index aadb2dbdb3e..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/FilterWrapper.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.bridge;
-
-import org.apache.log4j.spi.Filter;
-import org.apache.log4j.spi.LoggingEvent;
-
-/**
- * This acts as a container for Log4j 2 Filters to be attached to Log4j 1 components. However, the Log4j 2
- * Filters will always be called directly so this class just acts as a container.
- */
-public class FilterWrapper extends Filter {
-
- private final org.apache.logging.log4j.core.Filter filter;
-
- /**
- * Adapts a Log4j 2.x filter into a Log4j 1.x filter. Applying this method to
- * the result of {@link FilterAdapter#adapt(Filter)} should return the original
- * Log4j 1.x filter.
- *
- * @param filter a Log4j 2.x filter
- * @return a Log4j 1.x filter or {@code null} if the parameter is {@code null}
- */
- public static Filter adapt(final org.apache.logging.log4j.core.Filter filter) {
- if (filter instanceof Filter) {
- return (Filter) filter;
- }
- if (filter instanceof FilterAdapter) {
- return ((FilterAdapter) filter).getFilter();
- }
- if (filter != null) {
- return new FilterWrapper(filter);
- }
- return null;
- }
-
- public FilterWrapper(final org.apache.logging.log4j.core.Filter filter) {
- this.filter = filter;
- }
-
- public org.apache.logging.log4j.core.Filter getFilter() {
- return filter;
- }
-
- /**
- * This method is never called.
- * @param event The LoggingEvent to decide upon.
- * @return 0
- */
- @Override
- public int decide(final LoggingEvent event) {
- return 0;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/LayoutAdapter.java b/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/LayoutAdapter.java
deleted file mode 100644
index 404f58c4970..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/LayoutAdapter.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.bridge;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.log4j.Layout;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.layout.ByteBufferDestination;
-
-/**
- * Class Description goes here.
- */
-public final class LayoutAdapter implements org.apache.logging.log4j.core.Layout {
- private final Layout layout;
-
- /**
- * Adapts a Log4j 1.x layout into a Log4j 2.x layout. Applying this method to
- * the result of
- * {@link LayoutWrapper#adapt(org.apache.logging.log4j.core.Layout)} should
- * return the original Log4j 2.x layout.
- *
- * @param layout a Log4j 1.x layout
- * @return a Log4j 2.x layout or {@code null} if the parameter is {@code null}
- */
- public static org.apache.logging.log4j.core.Layout adapt(final Layout layout) {
- if (layout instanceof LayoutWrapper) {
- return ((LayoutWrapper) layout).getLayout();
- }
- if (layout != null) {
- return new LayoutAdapter(layout);
- }
- return null;
- }
-
- private LayoutAdapter(final Layout layout) {
- this.layout = layout;
- }
-
- public Layout getLayout() {
- return layout;
- }
-
- @Override
- public byte[] getFooter() {
- return layout.getFooter() == null ? null : layout.getFooter().getBytes();
- }
-
- @Override
- public byte[] getHeader() {
- return layout.getHeader() == null ? null : layout.getHeader().getBytes();
- }
-
- @Override
- public byte[] toByteArray(final LogEvent event) {
- final String result = layout.format(new LogEventAdapter(event));
- return result == null ? null : result.getBytes();
- }
-
- @Override
- public String toSerializable(final LogEvent event) {
- return layout.format(new LogEventAdapter(event));
- }
-
- @Override
- public String getContentType() {
- return layout.getContentType();
- }
-
- @Override
- public Map getContentFormat() {
- return new HashMap<>();
- }
-
- @Override
- public void encode(final LogEvent event, final ByteBufferDestination destination) {
- final byte[] data = toByteArray(event);
- destination.writeBytes(data, 0, data.length);
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/LayoutWrapper.java b/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/LayoutWrapper.java
deleted file mode 100644
index 64439f70a04..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/LayoutWrapper.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.bridge;
-
-import org.apache.log4j.Layout;
-import org.apache.log4j.spi.LoggingEvent;
-
-/**
- * Bridge between the Log4j 1 Layout and a Log4j 2 Layout.
- */
-public class LayoutWrapper extends Layout {
-
- private final org.apache.logging.log4j.core.Layout layout;
-
- /**
- * Adapts a Log4j 2.x layout into a Log4j 1.x layout. Applying this method to
- * the result of {@link LayoutAdapter#adapt(Layout)} should return the original
- * Log4j 1.x layout.
- *
- * @param layout a Log4j 2.x layout
- * @return a Log4j 1.x layout or {@code null} if the parameter is {@code null}
- */
- public static Layout adapt(final org.apache.logging.log4j.core.Layout layout) {
- if (layout instanceof LayoutAdapter) {
- return ((LayoutAdapter) layout).getLayout();
- }
- if (layout != null) {
- return new LayoutWrapper(layout);
- }
- return null;
- }
-
- /**
- * Constructs a new instance.
- *
- * @param layout The layout to wrap.
- */
- public LayoutWrapper(final org.apache.logging.log4j.core.Layout layout) {
- this.layout = layout;
- }
-
- @Override
- public String format(final LoggingEvent event) {
- return layout.toSerializable(((LogEventAdapter) event).getEvent()).toString();
- }
-
- /**
- * Unwraps.
- *
- * @return The wrapped object.
- */
- public org.apache.logging.log4j.core.Layout getLayout() {
- return this.layout;
- }
-
- @Override
- public boolean ignoresThrowable() {
- return false;
- }
-
- @Override
- public String toString() {
- return String.format("LayoutWrapper [layout=%s]", layout);
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/LogEventAdapter.java b/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/LogEventAdapter.java
deleted file mode 100644
index 40209ef8137..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/LogEventAdapter.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.bridge;
-
-import java.lang.reflect.Method;
-import java.util.Map;
-import java.util.Set;
-import org.apache.log4j.Category;
-import org.apache.log4j.Level;
-import org.apache.log4j.helpers.OptionConverter;
-import org.apache.log4j.spi.LocationInfo;
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.log4j.spi.ThrowableInformation;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.util.Loader;
-import org.apache.logging.log4j.core.util.Throwables;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.util.Strings;
-
-/**
- * Converts a Log4j 2 LogEvent into the components needed by a Log4j 1.x LoggingEvent.
- * This class requires Log4j 2.
- */
-public class LogEventAdapter extends LoggingEvent {
-
- private static final long JVM_START_TIME = initStartTime();
-
- private final LogEvent event;
-
- public LogEventAdapter(final LogEvent event) {
- this.event = event;
- }
-
- /**
- * Returns the time when the application started, in milliseconds
- * elapsed since 01.01.1970.
- * @return the time when the JVM started.
- */
- public static long getStartTime() {
- return JVM_START_TIME;
- }
-
- /**
- * Returns the result of {@code ManagementFactory.getRuntimeMXBean().getStartTime()},
- * or the current system time if JMX is not available.
- */
- private static long initStartTime() {
- // We'd like to call ManagementFactory.getRuntimeMXBean().getStartTime(),
- // but Google App Engine throws a java.lang.NoClassDefFoundError
- // "java.lang.management.ManagementFactory is a restricted class".
- // The reflection is necessary because without it, Google App Engine
- // will refuse to initialize this class.
- try {
- final Class> factoryClass = Loader.loadSystemClass("java.lang.management.ManagementFactory");
- final Method getRuntimeMXBean = factoryClass.getMethod("getRuntimeMXBean");
- final Object runtimeMXBean = getRuntimeMXBean.invoke(null);
-
- final Class> runtimeMXBeanClass = Loader.loadSystemClass("java.lang.management.RuntimeMXBean");
- final Method getStartTime = runtimeMXBeanClass.getMethod("getStartTime");
- return (Long) getStartTime.invoke(runtimeMXBean);
- } catch (final Throwable t) {
- StatusLogger.getLogger()
- .error(
- "Unable to call ManagementFactory.getRuntimeMXBean().getStartTime(), "
- + "using system time for OnStartupTriggeringPolicy",
- t);
- // We have little option but to declare "now" as the beginning of time.
- return System.currentTimeMillis();
- }
- }
-
- public LogEvent getEvent() {
- return this.event;
- }
-
- /**
- * Set the location information for this logging event. The collected
- * information is cached for future use.
- */
- @Override
- public LocationInfo getLocationInformation() {
- return new LocationInfo(event.getSource());
- }
-
- /**
- * Return the level of this event. Use this form instead of directly
- * accessing the level
field.
- */
- @Override
- public Level getLevel() {
- return OptionConverter.convertLevel(event.getLevel());
- }
-
- /**
- * Return the name of the logger. Use this form instead of directly
- * accessing the categoryName
field.
- */
- @Override
- public String getLoggerName() {
- return event.getLoggerName();
- }
-
- @Override
- public long getTimeStamp() {
- return event.getTimeMillis();
- }
-
- /**
- * Gets the logger of the event.
- */
- @Override
- public Category getLogger() {
- return Category.getInstance(event.getLoggerName());
- }
-
- /*
- Return the message for this logging event.
- */
- @Override
- public Object getMessage() {
- return event.getMessage();
- }
-
- /*
- * This method returns the NDC for this event.
- */
- @Override
- public String getNDC() {
- return event.getContextStack().toString();
- }
-
- /*
- Returns the context corresponding to the key
parameter.
- */
- @Override
- public Object getMDC(final String key) {
- if (event.getContextData() != null) {
- return event.getContextData().getValue(key);
- }
- return null;
- }
-
- /**
- * Obtain a copy of this thread's MDC prior to serialization or
- * asynchronous logging.
- */
- @Override
- public void getMDCCopy() {}
-
- @Override
- public String getRenderedMessage() {
- return event.getMessage().getFormattedMessage();
- }
-
- @Override
- public String getThreadName() {
- return event.getThreadName();
- }
-
- /**
- * Returns the throwable information contained within this
- * event. May be null
if there is no such information.
- *
- * Note that the {@link Throwable} object contained within a
- * {@link ThrowableInformation} does not survive serialization.
- *
- * @since 1.1
- */
- @Override
- public ThrowableInformation getThrowableInformation() {
- if (event.getThrown() != null) {
- return new ThrowableInformation(event.getThrown());
- }
- return null;
- }
-
- /**
- * Return this event's throwable's string[] representaion.
- */
- @Override
- public String[] getThrowableStrRep() {
- if (event.getThrown() != null) {
- return Throwables.toStringList(event.getThrown()).toArray(Strings.EMPTY_ARRAY);
- }
- return null;
- }
-
- @Override
- public String getProperty(final String key) {
- return event.getContextData().getValue(key);
- }
-
- @Override
- public Set getPropertyKeySet() {
- return event.getContextData().toMap().keySet();
- }
-
- @Override
- public Map getProperties() {
- return event.getContextData().toMap();
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/LogEventWrapper.java b/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/LogEventWrapper.java
deleted file mode 100644
index e0db478fa12..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/LogEventWrapper.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.bridge;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-import org.apache.log4j.NDC;
-import org.apache.log4j.helpers.OptionConverter;
-import org.apache.log4j.spi.LocationInfo;
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.log4j.spi.ThrowableInformation;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.impl.ThrowableProxy;
-import org.apache.logging.log4j.core.time.Instant;
-import org.apache.logging.log4j.core.time.MutableInstant;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.message.SimpleMessage;
-import org.apache.logging.log4j.spi.MutableThreadContextStack;
-import org.apache.logging.log4j.util.BiConsumer;
-import org.apache.logging.log4j.util.ReadOnlyStringMap;
-import org.apache.logging.log4j.util.TriConsumer;
-import org.jspecify.annotations.Nullable;
-
-/**
- * Exposes a Log4j 1 logging event as a Log4j 2 LogEvent.
- */
-public class LogEventWrapper implements LogEvent {
-
- private final LoggingEvent event;
- private final ContextDataMap contextData;
- private final MutableThreadContextStack contextStack;
- private Thread thread;
-
- public LogEventWrapper(final LoggingEvent event) {
- this.event = event;
- this.contextData = new ContextDataMap(event.getProperties());
- this.contextStack = new MutableThreadContextStack(NDC.cloneStack());
- this.thread =
- Objects.equals(event.getThreadName(), Thread.currentThread().getName()) ? Thread.currentThread() : null;
- }
-
- @Override
- public LogEvent toImmutable() {
- return this;
- }
-
- @Override
- public ReadOnlyStringMap getContextData() {
- return contextData;
- }
-
- @Override
- public ThreadContext.ContextStack getContextStack() {
- return contextStack;
- }
-
- @Override
- public String getLoggerFqcn() {
- return null;
- }
-
- @Override
- public Level getLevel() {
- return OptionConverter.convertLevel(event.getLevel());
- }
-
- @Override
- public String getLoggerName() {
- return event.getLoggerName();
- }
-
- @Override
- public Marker getMarker() {
- return null;
- }
-
- @Override
- public Message getMessage() {
- return new SimpleMessage(event.getRenderedMessage());
- }
-
- @Override
- public long getTimeMillis() {
- return event.getTimeStamp();
- }
-
- @Override
- public Instant getInstant() {
- final MutableInstant mutable = new MutableInstant();
- mutable.initFromEpochMilli(event.getTimeStamp(), 0);
- return mutable;
- }
-
- @Override
- public @Nullable StackTraceElement peekSource() {
- final LocationInfo info = event.getLocationInformation();
- return new StackTraceElement(
- info.getClassName(), info.getMethodName(), info.getFileName(), Integer.parseInt(info.getLineNumber()));
- }
-
- @Override
- public @Nullable StackTraceElement getSource() {
- return peekSource();
- }
-
- @Override
- public String getThreadName() {
- return event.getThreadName();
- }
-
- @Override
- public long getThreadId() {
- final Thread thread = getThread();
- return thread != null ? thread.getId() : 0;
- }
-
- @Override
- public int getThreadPriority() {
- final Thread thread = getThread();
- return thread != null ? thread.getPriority() : 0;
- }
-
- private Thread getThread() {
- if (thread == null && event.getThreadName() != null) {
- for (Thread thread : Thread.getAllStackTraces().keySet()) {
- if (thread.getName().equals(event.getThreadName())) {
- this.thread = thread;
- return thread;
- }
- }
- }
- return thread;
- }
-
- @Override
- public Throwable getThrown() {
- final ThrowableInformation throwableInformation = event.getThrowableInformation();
- return throwableInformation == null ? null : throwableInformation.getThrowable();
- }
-
- @Override
- public ThrowableProxy getThrownProxy() {
- return null;
- }
-
- @Override
- public boolean isEndOfBatch() {
- return false;
- }
-
- @Override
- public boolean isIncludeLocation() {
- return false;
- }
-
- @Override
- public void setEndOfBatch(final boolean endOfBatch) {}
-
- @Override
- public void setIncludeLocation(final boolean locationRequired) {}
-
- @Override
- public long getNanoTime() {
- return 0;
- }
-
- private static class ContextDataMap extends HashMap implements ReadOnlyStringMap {
-
- ContextDataMap(final Map map) {
- if (map != null) {
- super.putAll(map);
- }
- }
-
- @Override
- public Map toMap() {
- return this;
- }
-
- @Override
- public boolean containsKey(final String key) {
- return super.containsKey(key);
- }
-
- @Override
- public void forEach(final BiConsumer action) {
- super.forEach((k, v) -> action.accept(k, (V) v));
- }
-
- @Override
- public void forEach(final TriConsumer action, final S state) {
- super.forEach((k, v) -> action.accept(k, (V) v, state));
- }
-
- @Override
- public V getValue(final String key) {
- return (V) super.get(key);
- }
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/RewritePolicyAdapter.java b/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/RewritePolicyAdapter.java
deleted file mode 100644
index 8e82ece2c26..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/RewritePolicyAdapter.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.bridge;
-
-import org.apache.log4j.rewrite.RewritePolicy;
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.logging.log4j.core.LogEvent;
-
-/**
- * Binds a Log4j 1.x RewritePolicy to Log4j 2.
- */
-public class RewritePolicyAdapter implements org.apache.logging.log4j.core.appender.rewrite.RewritePolicy {
-
- private final RewritePolicy policy;
-
- /**
- * Constructor.
- * @param policy The Rewrite policy.
- */
- public RewritePolicyAdapter(final RewritePolicy policy) {
- this.policy = policy;
- }
-
- @Override
- public LogEvent rewrite(final LogEvent source) {
- final LoggingEvent event = policy.rewrite(new LogEventAdapter(source));
- return event instanceof LogEventAdapter ? ((LogEventAdapter) event).getEvent() : new LogEventWrapper(event);
- }
-
- public RewritePolicy getPolicy() {
- return this.policy;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/RewritePolicyWrapper.java b/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/RewritePolicyWrapper.java
deleted file mode 100644
index 64f4dfe4e9c..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/bridge/RewritePolicyWrapper.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.bridge;
-
-import org.apache.log4j.rewrite.RewritePolicy;
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.logging.log4j.core.LogEvent;
-
-/**
- * Binds a Log4j 2 RewritePolicy to Log4j 1.
- */
-public class RewritePolicyWrapper implements RewritePolicy {
-
- private final org.apache.logging.log4j.core.appender.rewrite.RewritePolicy policy;
-
- public RewritePolicyWrapper(final org.apache.logging.log4j.core.appender.rewrite.RewritePolicy policy) {
- this.policy = policy;
- }
-
- @Override
- public LoggingEvent rewrite(final LoggingEvent source) {
- final LogEvent event =
- source instanceof LogEventAdapter ? ((LogEventAdapter) source).getEvent() : new LogEventWrapper(source);
- return new LogEventAdapter(policy.rewrite(event));
- }
-
- public org.apache.logging.log4j.core.appender.rewrite.RewritePolicy getPolicy() {
- return policy;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/AbstractBuilder.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/AbstractBuilder.java
deleted file mode 100644
index dfd4319b409..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/AbstractBuilder.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders;
-
-import static org.apache.log4j.xml.XmlConfiguration.NAME_ATTR;
-import static org.apache.log4j.xml.XmlConfiguration.VALUE_ATTR;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.atomic.AtomicReference;
-import org.apache.log4j.bridge.FilterAdapter;
-import org.apache.log4j.bridge.FilterWrapper;
-import org.apache.log4j.helpers.OptionConverter;
-import org.apache.log4j.spi.Filter;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.filter.ThresholdFilter;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.util.Strings;
-import org.w3c.dom.Element;
-
-/**
- * Base class for Log4j 1 component builders.
- *
- * @param The type to build.
- */
-public abstract class AbstractBuilder implements Builder {
-
- private static final Logger LOGGER = StatusLogger.getLogger();
- protected static final String FILE_PARAM = "File";
- protected static final String APPEND_PARAM = "Append";
- protected static final String BUFFERED_IO_PARAM = "BufferedIO";
- protected static final String BUFFER_SIZE_PARAM = "BufferSize";
- protected static final String IMMEDIATE_FLUSH_PARAM = "ImmediateFlush";
- protected static final String MAX_SIZE_PARAM = "MaxFileSize";
- protected static final String MAX_BACKUP_INDEX = "MaxBackupIndex";
- protected static final String RELATIVE = "RELATIVE";
- protected static final String NULL = "NULL";
-
- private final String prefix;
- private final Properties properties;
-
- public AbstractBuilder() {
- this(null, new Properties());
- }
-
- public AbstractBuilder(final String prefix, final Properties props) {
- this.prefix = prefix != null ? prefix + "." : null;
- this.properties = (Properties) props.clone();
- final Map map = new HashMap<>();
- System.getProperties().forEach((k, v) -> map.put(k.toString(), v.toString()));
- props.forEach((k, v) -> map.put(k.toString(), v.toString()));
- // normalize keys to lower case for case-insensitive access.
- props.forEach((k, v) -> map.put(toBeanKey(k.toString()), v.toString()));
- props.entrySet().forEach(e -> this.properties.put(toBeanKey(e.getKey().toString()), e.getValue()));
- }
-
- protected static org.apache.logging.log4j.core.Filter buildFilters(final String level, final Filter filter) {
- Filter head = null;
- if (level != null) {
- final org.apache.logging.log4j.core.Filter thresholdFilter = ThresholdFilter.createFilter(
- OptionConverter.convertLevel(level, Level.TRACE),
- org.apache.logging.log4j.core.Filter.Result.NEUTRAL,
- org.apache.logging.log4j.core.Filter.Result.DENY);
- head = new FilterWrapper(thresholdFilter);
- }
- if (filter != null) {
- head = FilterAdapter.addFilter(head, filter);
- }
- return FilterAdapter.adapt(head);
- }
-
- private String capitalize(final String value) {
- if (Strings.isEmpty(value) || Character.isUpperCase(value.charAt(0))) {
- return value;
- }
- final char[] chars = value.toCharArray();
- chars[0] = Character.toUpperCase(chars[0]);
- return new String(chars);
- }
-
- public boolean getBooleanProperty(final String key, final boolean defaultValue) {
- return Boolean.parseBoolean(getProperty(key, Boolean.toString(defaultValue)));
- }
-
- public boolean getBooleanProperty(final String key) {
- return getBooleanProperty(key, false);
- }
-
- protected boolean getBooleanValueAttribute(final Element element) {
- return Boolean.parseBoolean(getValueAttribute(element));
- }
-
- public int getIntegerProperty(final String key, final int defaultValue) {
- String value = null;
- try {
- value = getProperty(key);
- if (value != null) {
- return Integer.parseInt(value);
- }
- } catch (final Exception ex) {
- LOGGER.warn("Error converting value {} of {} to an integer: {}", value, key, ex.getMessage());
- }
- return defaultValue;
- }
-
- public long getLongProperty(final String key, final long defaultValue) {
- String value = null;
- try {
- value = getProperty(key);
- if (value != null) {
- return Long.parseLong(value);
- }
- } catch (final Exception ex) {
- LOGGER.warn("Error converting value {} of {} to a long: {}", value, key, ex.getMessage());
- }
- return defaultValue;
- }
-
- protected String getNameAttribute(final Element element) {
- return element.getAttribute(NAME_ATTR);
- }
-
- protected String getNameAttributeKey(final Element element) {
- return toBeanKey(element.getAttribute(NAME_ATTR));
- }
-
- public Properties getProperties() {
- return properties;
- }
-
- public String getProperty(final String key) {
- return getProperty(key, null);
- }
-
- public String getProperty(final String key, final String defaultValue) {
- String value = properties.getProperty(prefix + toJavaKey(key));
- value = value != null ? value : properties.getProperty(prefix + toBeanKey(key), defaultValue);
- value = value != null ? substVars(value) : defaultValue;
- return value != null ? value.trim() : defaultValue;
- }
-
- protected String getValueAttribute(final Element element) {
- return getValueAttribute(element, null);
- }
-
- protected String getValueAttribute(final Element element, final String defaultValue) {
- final String attribute = element.getAttribute(VALUE_ATTR);
- return substVars(attribute != null ? attribute.trim() : defaultValue);
- }
-
- protected String substVars(final String value) {
- return OptionConverter.substVars(value, properties);
- }
-
- String toBeanKey(final String value) {
- return capitalize(value);
- }
-
- String toJavaKey(final String value) {
- return uncapitalize(value);
- }
-
- private String uncapitalize(final String value) {
- if (Strings.isEmpty(value) || Character.isLowerCase(value.charAt(0))) {
- return value;
- }
- final char[] chars = value.toCharArray();
- chars[0] = Character.toLowerCase(chars[0]);
- return new String(chars);
- }
-
- protected void set(final String name, final Element element, final AtomicBoolean ref) {
- final String value = getValueAttribute(element);
- if (value == null) {
- LOGGER.warn("No value for {} parameter, using default {}", name, ref);
- } else {
- ref.set(Boolean.parseBoolean(value));
- }
- }
-
- protected void set(final String name, final Element element, final AtomicInteger ref) {
- final String value = getValueAttribute(element);
- if (value == null) {
- LOGGER.warn("No value for {} parameter, using default {}", name, ref);
- } else {
- try {
- ref.set(Integer.parseInt(value));
- } catch (NumberFormatException e) {
- LOGGER.warn(
- "{} parsing {} parameter, using default {}: {}",
- e.getClass().getName(),
- name,
- ref,
- e.getMessage(),
- e);
- }
- }
- }
-
- protected void set(final String name, final Element element, final AtomicLong ref) {
- final String value = getValueAttribute(element);
- if (value == null) {
- LOGGER.warn("No value for {} parameter, using default {}", name, ref);
- } else {
- try {
- ref.set(Long.parseLong(value));
- } catch (NumberFormatException e) {
- LOGGER.warn(
- "{} parsing {} parameter, using default {}: {}",
- e.getClass().getName(),
- name,
- ref,
- e.getMessage(),
- e);
- }
- }
- }
-
- protected void set(final String name, final Element element, final AtomicReference ref) {
- final String value = getValueAttribute(element);
- if (value == null) {
- LOGGER.warn("No value for {} parameter, using default {}", name, ref);
- } else {
- ref.set(value);
- }
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/Builder.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/Builder.java
deleted file mode 100644
index a829b7afbc9..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/Builder.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders;
-
-/**
- * A marker interface for Log4j 1.x component builders.
- *
- * @param The type to build.
- */
-public interface Builder {
- // empty
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/BuilderManager.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/BuilderManager.java
deleted file mode 100644
index 86b63b17b4d..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/BuilderManager.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders;
-
-import static org.apache.logging.log4j.util.Strings.toRootLowerCase;
-
-import java.util.Objects;
-import java.util.Properties;
-import java.util.function.Function;
-import org.apache.log4j.Appender;
-import org.apache.log4j.Layout;
-import org.apache.log4j.bridge.AppenderWrapper;
-import org.apache.log4j.bridge.FilterWrapper;
-import org.apache.log4j.bridge.LayoutWrapper;
-import org.apache.log4j.bridge.RewritePolicyWrapper;
-import org.apache.log4j.builders.appender.AppenderBuilder;
-import org.apache.log4j.builders.filter.FilterBuilder;
-import org.apache.log4j.builders.layout.LayoutBuilder;
-import org.apache.log4j.builders.rewrite.RewritePolicyBuilder;
-import org.apache.log4j.builders.rolling.TriggeringPolicyBuilder;
-import org.apache.log4j.config.PropertiesConfiguration;
-import org.apache.log4j.rewrite.RewritePolicy;
-import org.apache.log4j.spi.Filter;
-import org.apache.log4j.xml.XmlConfiguration;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.appender.rolling.TriggeringPolicy;
-import org.apache.logging.log4j.plugins.Inject;
-import org.apache.logging.log4j.plugins.Namespace;
-import org.apache.logging.log4j.plugins.di.ConfigurableInstanceFactory;
-import org.apache.logging.log4j.plugins.model.PluginNamespace;
-import org.apache.logging.log4j.plugins.model.PluginType;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.util.Cast;
-import org.w3c.dom.Element;
-
-/**
- *
- */
-public class BuilderManager {
-
- /** Plugin namespace. */
- public static final String NAMESPACE = "Log4j Builder";
-
- public static final Appender INVALID_APPENDER = new AppenderWrapper(null);
- public static final Filter INVALID_FILTER = new FilterWrapper(null);
- public static final Layout INVALID_LAYOUT = new LayoutWrapper(null);
- public static final RewritePolicy INVALID_REWRITE_POLICY = new RewritePolicyWrapper(null);
- private static final Logger LOGGER = StatusLogger.getLogger();
- private static final Class>[] CONSTRUCTOR_PARAMS = new Class[] {String.class, Properties.class};
- private final ConfigurableInstanceFactory instanceFactory;
- private final PluginNamespace plugins;
-
- /**
- * Constructs a new instance.
- */
- @Inject
- public BuilderManager(
- final ConfigurableInstanceFactory instanceFactory, @Namespace(NAMESPACE) final PluginNamespace plugins) {
- this.instanceFactory = instanceFactory;
- this.plugins = plugins;
- }
-
- private , U> T createBuilder(
- final PluginType plugin, final String prefix, final Properties props) {
- if (plugin == null) {
- return null;
- }
- try {
- final Class clazz = plugin.getPluginClass();
- if (AbstractBuilder.class.isAssignableFrom(clazz)) {
- return clazz.getConstructor(CONSTRUCTOR_PARAMS).newInstance(prefix, props);
- }
- final T builder = instanceFactory.getInstance(clazz);
- // Reasonable message instead of `ClassCastException`
- if (!Builder.class.isAssignableFrom(clazz)) {
- LOGGER.warn("Unable to load plugin: builder {} does not implement {}", clazz, Builder.class);
- return null;
- }
- return builder;
- } catch (final ReflectiveOperationException ex) {
- LOGGER.warn("Unable to load plugin: {} due to: {}", plugin.getKey(), ex.getMessage());
- return null;
- }
- }
-
- private PluginType getPlugin(final String className) {
- Objects.requireNonNull(plugins, "plugins");
- Objects.requireNonNull(className, "className");
- final String key = toRootLowerCase(className).trim();
- final PluginType> pluginType = plugins.get(key);
- if (pluginType == null) {
- LOGGER.warn("Unable to load plugin class name {} with key {}", className, key);
- }
- return Cast.cast(pluginType);
- }
-
- private , U> U newInstance(
- final PluginType plugin, final Function consumer, final U invalidValue) {
- if (plugin != null) {
- final T builder = instanceFactory.getInstance(plugin.getPluginClass());
- if (builder != null) {
- final U result = consumer.apply(builder);
- // returning an empty wrapper is short for "we support this legacy class, but it has validation errors"
- return result != null ? result : invalidValue;
- }
- }
- return null;
- }
-
- public , T> T parse(
- final String className,
- final String prefix,
- final Properties props,
- final PropertiesConfiguration config,
- final T invalidValue) {
- final P parser = createBuilder(getPlugin(className), prefix, props);
- if (parser != null) {
- final T value = parser.parse(config);
- return value != null ? value : invalidValue;
- }
- return null;
- }
-
- public Appender parseAppender(
- final String className, final Element appenderElement, final XmlConfiguration config) {
- return newInstance(
- this.>getPlugin(className),
- b -> b.parseAppender(appenderElement, config),
- INVALID_APPENDER);
- }
-
- public Appender parseAppender(
- final String name,
- final String className,
- final String prefix,
- final String layoutPrefix,
- final String filterPrefix,
- final Properties props,
- final PropertiesConfiguration config) {
- final AppenderBuilder builder = createBuilder(getPlugin(className), prefix, props);
- if (builder != null) {
- final Appender appender = builder.parseAppender(name, prefix, layoutPrefix, filterPrefix, props, config);
- return appender != null ? appender : INVALID_APPENDER;
- }
- return null;
- }
-
- public Filter parseFilter(final String className, final Element filterElement, final XmlConfiguration config) {
- return newInstance(
- this.getPlugin(className), b -> b.parse(filterElement, config), INVALID_FILTER);
- }
-
- public Layout parseLayout(final String className, final Element layoutElement, final XmlConfiguration config) {
- return newInstance(
- this.getPlugin(className), b -> b.parse(layoutElement, config), INVALID_LAYOUT);
- }
-
- public RewritePolicy parseRewritePolicy(
- final String className, final Element rewriteElement, final XmlConfiguration config) {
- return newInstance(
- this.getPlugin(className),
- b -> b.parse(rewriteElement, config),
- INVALID_REWRITE_POLICY);
- }
-
- public TriggeringPolicy parseTriggeringPolicy(
- final String className, final Element policyElement, final XmlConfiguration config) {
- return newInstance(
- this.getPlugin(className),
- b -> b.parse(policyElement, config),
- (TriggeringPolicy) null);
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/Parser.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/Parser.java
deleted file mode 100644
index c4b2ee590ff..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/Parser.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders;
-
-import org.apache.log4j.config.PropertiesConfiguration;
-import org.apache.log4j.xml.XmlConfiguration;
-import org.w3c.dom.Element;
-
-/**
- * Parses DOM and properties.
- *
- * @param The type to build.
- */
-public interface Parser extends Builder {
-
- /**
- * Parses a DOM Element.
- *
- * @param element the DOM Element.
- * @param config the XML configuration.
- * @return parse result.
- */
- T parse(Element element, XmlConfiguration config);
-
- /**
- * Parses a PropertiesConfigurationt.
- *
- * @param element the PropertiesConfiguration.
- * @return parse result.
- */
- T parse(PropertiesConfiguration config);
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/AppenderBuilder.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/AppenderBuilder.java
deleted file mode 100644
index c19e2c12ba2..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/AppenderBuilder.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders.appender;
-
-import java.util.Properties;
-import org.apache.log4j.Appender;
-import org.apache.log4j.builders.Builder;
-import org.apache.log4j.config.PropertiesConfiguration;
-import org.apache.log4j.xml.XmlConfiguration;
-import org.w3c.dom.Element;
-
-/**
- * Define an Appender Builder.
- *
- * @param The type to build.
- */
-public interface AppenderBuilder extends Builder {
-
- Appender parseAppender(Element element, XmlConfiguration configuration);
-
- Appender parseAppender(
- String name,
- String appenderPrefix,
- String layoutPrefix,
- String filterPrefix,
- Properties props,
- PropertiesConfiguration configuration);
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/AsyncAppenderBuilder.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/AsyncAppenderBuilder.java
deleted file mode 100644
index bc18bf6ce6e..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/AsyncAppenderBuilder.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders.appender;
-
-import static org.apache.log4j.builders.BuilderManager.NAMESPACE;
-import static org.apache.log4j.config.Log4j1Configuration.APPENDER_REF_TAG;
-import static org.apache.log4j.config.Log4j1Configuration.THRESHOLD_PARAM;
-import static org.apache.log4j.xml.XmlConfiguration.FILTER_TAG;
-import static org.apache.log4j.xml.XmlConfiguration.PARAM_TAG;
-import static org.apache.log4j.xml.XmlConfiguration.forEachElement;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
-import org.apache.log4j.Appender;
-import org.apache.log4j.bridge.AppenderWrapper;
-import org.apache.log4j.bridge.FilterAdapter;
-import org.apache.log4j.builders.AbstractBuilder;
-import org.apache.log4j.config.Log4j1Configuration;
-import org.apache.log4j.config.PropertiesConfiguration;
-import org.apache.log4j.helpers.OptionConverter;
-import org.apache.log4j.spi.Filter;
-import org.apache.log4j.xml.XmlConfiguration;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.appender.AsyncAppender;
-import org.apache.logging.log4j.core.appender.AsyncAppender.Builder;
-import org.apache.logging.log4j.core.config.AppenderRef;
-import org.apache.logging.log4j.plugins.Namespace;
-import org.apache.logging.log4j.plugins.Plugin;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.util.Strings;
-import org.w3c.dom.Element;
-
-/**
- * Build an Async Appender
- */
-@Namespace(NAMESPACE)
-@Plugin("org.apache.log4j.AsyncAppender")
-public class AsyncAppenderBuilder extends AbstractBuilder implements AppenderBuilder {
-
- private static final Logger LOGGER = StatusLogger.getLogger();
- private static final String BLOCKING_PARAM = "Blocking";
- private static final String INCLUDE_LOCATION_PARAM = "IncludeLocation";
-
- public AsyncAppenderBuilder() {}
-
- public AsyncAppenderBuilder(final String prefix, final Properties props) {
- super(prefix, props);
- }
-
- @Override
- public Appender parseAppender(final Element appenderElement, final XmlConfiguration config) {
- final String name = getNameAttribute(appenderElement);
- final AtomicReference> appenderRefs = new AtomicReference<>(new ArrayList<>());
- final AtomicBoolean blocking = new AtomicBoolean();
- final AtomicBoolean includeLocation = new AtomicBoolean();
- final AtomicReference level = new AtomicReference<>("trace");
- final AtomicInteger bufferSize = new AtomicInteger(1024);
- final AtomicReference filter = new AtomicReference<>();
- forEachElement(appenderElement.getChildNodes(), currentElement -> {
- switch (currentElement.getTagName()) {
- case APPENDER_REF_TAG:
- final Appender appender = config.findAppenderByReference(currentElement);
- if (appender != null) {
- appenderRefs.get().add(appender.getName());
- }
- break;
- case FILTER_TAG:
- config.addFilter(filter, currentElement);
- break;
- case PARAM_TAG: {
- switch (getNameAttributeKey(currentElement)) {
- case BUFFER_SIZE_PARAM:
- set(BUFFER_SIZE_PARAM, currentElement, bufferSize);
- break;
- case BLOCKING_PARAM:
- set(BLOCKING_PARAM, currentElement, blocking);
- break;
- case INCLUDE_LOCATION_PARAM:
- set(INCLUDE_LOCATION_PARAM, currentElement, includeLocation);
- break;
- case THRESHOLD_PARAM:
- set(THRESHOLD_PARAM, currentElement, level);
- break;
- }
- break;
- }
- }
- });
- return createAppender(
- name,
- level.get(),
- appenderRefs.get().toArray(Strings.EMPTY_ARRAY),
- blocking.get(),
- bufferSize.get(),
- includeLocation.get(),
- filter.get(),
- config);
- }
-
- @Override
- public Appender parseAppender(
- final String name,
- final String appenderPrefix,
- final String layoutPrefix,
- final String filterPrefix,
- final Properties props,
- final PropertiesConfiguration configuration) {
- final String appenderRef = getProperty(APPENDER_REF_TAG);
- final Filter filter = configuration.parseAppenderFilters(props, filterPrefix, name);
- final boolean blocking = getBooleanProperty(BLOCKING_PARAM);
- final boolean includeLocation = getBooleanProperty(INCLUDE_LOCATION_PARAM);
- final String level = getProperty(THRESHOLD_PARAM);
- final int bufferSize = getIntegerProperty(BUFFER_SIZE_PARAM, 1024);
- if (appenderRef == null) {
- LOGGER.error("No appender references configured for AsyncAppender {}", name);
- return null;
- }
- final Appender appender = configuration.parseAppender(props, appenderRef);
- if (appender == null) {
- LOGGER.error("Cannot locate Appender {}", appenderRef);
- return null;
- }
- return createAppender(
- name, level, new String[] {appenderRef}, blocking, bufferSize, includeLocation, filter, configuration);
- }
-
- private Appender createAppender(
- final String name,
- final String level,
- final String[] appenderRefs,
- final boolean blocking,
- final int bufferSize,
- final boolean includeLocation,
- final Filter filter,
- final T configuration) {
- if (appenderRefs.length == 0) {
- LOGGER.error("No appender references configured for AsyncAppender {}", name);
- return null;
- }
- final Level logLevel = OptionConverter.convertLevel(level, Level.TRACE);
- final AppenderRef[] refs = new AppenderRef[appenderRefs.length];
- int index = 0;
- for (final String appenderRef : appenderRefs) {
- refs[index++] = AppenderRef.createAppenderRef(appenderRef, logLevel, null);
- }
- final Builder builder = AsyncAppender.newBuilder();
- builder.setFilter(FilterAdapter.adapt(filter));
- return AppenderWrapper.adapt(builder.setName(name)
- .setAppenderRefs(refs)
- .setBlocking(blocking)
- .setBufferSize(bufferSize)
- .setIncludeLocation(includeLocation)
- .setConfiguration(configuration)
- .build());
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/ConsoleAppenderBuilder.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/ConsoleAppenderBuilder.java
deleted file mode 100644
index e1273c1b1be..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/ConsoleAppenderBuilder.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders.appender;
-
-import static org.apache.log4j.builders.BuilderManager.NAMESPACE;
-import static org.apache.log4j.config.Log4j1Configuration.THRESHOLD_PARAM;
-import static org.apache.log4j.xml.XmlConfiguration.FILTER_TAG;
-import static org.apache.log4j.xml.XmlConfiguration.LAYOUT_TAG;
-import static org.apache.log4j.xml.XmlConfiguration.PARAM_TAG;
-import static org.apache.log4j.xml.XmlConfiguration.forEachElement;
-
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicReference;
-import org.apache.log4j.Appender;
-import org.apache.log4j.Layout;
-import org.apache.log4j.bridge.AppenderWrapper;
-import org.apache.log4j.bridge.LayoutAdapter;
-import org.apache.log4j.builders.AbstractBuilder;
-import org.apache.log4j.config.Log4j1Configuration;
-import org.apache.log4j.config.PropertiesConfiguration;
-import org.apache.log4j.spi.Filter;
-import org.apache.log4j.xml.XmlConfiguration;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.appender.ConsoleAppender;
-import org.apache.logging.log4j.plugins.Namespace;
-import org.apache.logging.log4j.plugins.Plugin;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.w3c.dom.Element;
-
-/**
- * Build a Console Appender
- */
-@Namespace(NAMESPACE)
-@Plugin("org.apache.log4j.ConsoleAppender")
-public class ConsoleAppenderBuilder extends AbstractBuilder implements AppenderBuilder {
-
- private static final String SYSTEM_OUT = "System.out";
- private static final String SYSTEM_ERR = "System.err";
- private static final String TARGET_PARAM = "Target";
- private static final String FOLLOW_PARAM = "Follow";
-
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- public ConsoleAppenderBuilder() {}
-
- public ConsoleAppenderBuilder(final String prefix, final Properties props) {
- super(prefix, props);
- }
-
- @Override
- public Appender parseAppender(final Element appenderElement, final XmlConfiguration config) {
- final String name = getNameAttribute(appenderElement);
- final AtomicReference target = new AtomicReference<>(SYSTEM_OUT);
- final AtomicReference layout = new AtomicReference<>();
- final AtomicReference filter = new AtomicReference<>();
- final AtomicReference level = new AtomicReference<>();
- final AtomicBoolean follow = new AtomicBoolean();
- final AtomicBoolean immediateFlush = new AtomicBoolean(true);
- forEachElement(appenderElement.getChildNodes(), currentElement -> {
- switch (currentElement.getTagName()) {
- case LAYOUT_TAG:
- layout.set(config.parseLayout(currentElement));
- break;
- case FILTER_TAG:
- config.addFilter(filter, currentElement);
- break;
- case PARAM_TAG: {
- switch (getNameAttributeKey(currentElement)) {
- case TARGET_PARAM:
- final String value = getValueAttribute(currentElement);
- if (value == null) {
- LOGGER.warn("No value supplied for target parameter. Defaulting to " + SYSTEM_OUT);
- } else {
- switch (value) {
- case SYSTEM_OUT:
- target.set(SYSTEM_OUT);
- break;
- case SYSTEM_ERR:
- target.set(SYSTEM_ERR);
- break;
- default:
- LOGGER.warn(
- "Invalid value \"{}\" for target parameter. Using default of {}",
- value,
- SYSTEM_OUT);
- }
- }
- break;
- case THRESHOLD_PARAM:
- set(THRESHOLD_PARAM, currentElement, level);
- break;
- case FOLLOW_PARAM:
- set(FOLLOW_PARAM, currentElement, follow);
- break;
- case IMMEDIATE_FLUSH_PARAM:
- set(IMMEDIATE_FLUSH_PARAM, currentElement, immediateFlush);
- break;
- }
- break;
- }
- }
- });
- return createAppender(
- name,
- layout.get(),
- filter.get(),
- level.get(),
- target.get(),
- immediateFlush.get(),
- follow.get(),
- config);
- }
-
- @Override
- public Appender parseAppender(
- final String name,
- final String appenderPrefix,
- final String layoutPrefix,
- final String filterPrefix,
- final Properties props,
- final PropertiesConfiguration configuration) {
- final Layout layout = configuration.parseLayout(layoutPrefix, name, props);
- final Filter filter = configuration.parseAppenderFilters(props, filterPrefix, name);
- final String level = getProperty(THRESHOLD_PARAM);
- final String target = getProperty(TARGET_PARAM);
- final boolean follow = getBooleanProperty(FOLLOW_PARAM);
- final boolean immediateFlush = getBooleanProperty(IMMEDIATE_FLUSH_PARAM);
- return createAppender(name, layout, filter, level, target, immediateFlush, follow, configuration);
- }
-
- private Appender createAppender(
- final String name,
- final Layout layout,
- final Filter filter,
- final String level,
- final String target,
- final boolean immediateFlush,
- final boolean follow,
- final T configuration) {
- final org.apache.logging.log4j.core.Layout consoleLayout = LayoutAdapter.adapt(layout);
-
- final org.apache.logging.log4j.core.Filter consoleFilter = buildFilters(level, filter);
- final ConsoleAppender.Target consoleTarget =
- SYSTEM_ERR.equals(target) ? ConsoleAppender.Target.SYSTEM_ERR : ConsoleAppender.Target.SYSTEM_OUT;
- return AppenderWrapper.adapt(ConsoleAppender.newBuilder()
- .setName(name)
- .setTarget(consoleTarget)
- .setFollow(follow)
- .setLayout(consoleLayout)
- .setFilter(consoleFilter)
- .setConfiguration(configuration)
- .setImmediateFlush(immediateFlush)
- .build());
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/DailyRollingFileAppenderBuilder.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/DailyRollingFileAppenderBuilder.java
deleted file mode 100644
index 1d5611f2974..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/DailyRollingFileAppenderBuilder.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders.appender;
-
-import static org.apache.log4j.builders.BuilderManager.NAMESPACE;
-import static org.apache.log4j.config.Log4j1Configuration.THRESHOLD_PARAM;
-import static org.apache.log4j.xml.XmlConfiguration.FILTER_TAG;
-import static org.apache.log4j.xml.XmlConfiguration.LAYOUT_TAG;
-import static org.apache.log4j.xml.XmlConfiguration.PARAM_TAG;
-import static org.apache.log4j.xml.XmlConfiguration.forEachElement;
-
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
-import org.apache.log4j.Appender;
-import org.apache.log4j.Layout;
-import org.apache.log4j.bridge.AppenderWrapper;
-import org.apache.log4j.bridge.LayoutAdapter;
-import org.apache.log4j.builders.AbstractBuilder;
-import org.apache.log4j.config.Log4j1Configuration;
-import org.apache.log4j.config.PropertiesConfiguration;
-import org.apache.log4j.spi.Filter;
-import org.apache.log4j.xml.XmlConfiguration;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.appender.RollingFileAppender;
-import org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy;
-import org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy;
-import org.apache.logging.log4j.core.appender.rolling.RolloverStrategy;
-import org.apache.logging.log4j.core.appender.rolling.TimeBasedTriggeringPolicy;
-import org.apache.logging.log4j.core.appender.rolling.TriggeringPolicy;
-import org.apache.logging.log4j.core.time.Clock;
-import org.apache.logging.log4j.plugins.Namespace;
-import org.apache.logging.log4j.plugins.Plugin;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.w3c.dom.Element;
-
-/**
- * Build a Daily Rolling File Appender
- */
-@Namespace(NAMESPACE)
-@Plugin("org.apache.log4j.DailyRollingFileAppender")
-public class DailyRollingFileAppenderBuilder extends AbstractBuilder implements AppenderBuilder {
-
- private static final String DEFAULT_DATE_PATTERN = ".yyyy-MM-dd";
- private static final String DATE_PATTERN_PARAM = "DatePattern";
-
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- public DailyRollingFileAppenderBuilder() {}
-
- public DailyRollingFileAppenderBuilder(final String prefix, final Properties props) {
- super(prefix, props);
- }
-
- @Override
- public Appender parseAppender(final Element appenderElement, final XmlConfiguration config) {
- final String name = getNameAttribute(appenderElement);
- final AtomicReference layout = new AtomicReference<>();
- final AtomicReference filter = new AtomicReference<>();
- final AtomicReference fileName = new AtomicReference<>();
- final AtomicReference level = new AtomicReference<>();
- final AtomicBoolean immediateFlush = new AtomicBoolean(true);
- final AtomicBoolean append = new AtomicBoolean(true);
- final AtomicBoolean bufferedIo = new AtomicBoolean();
- final AtomicInteger bufferSize = new AtomicInteger(8192);
- final AtomicReference datePattern = new AtomicReference<>(DEFAULT_DATE_PATTERN);
- forEachElement(appenderElement.getChildNodes(), currentElement -> {
- switch (currentElement.getTagName()) {
- case LAYOUT_TAG:
- layout.set(config.parseLayout(currentElement));
- break;
- case FILTER_TAG:
- config.addFilter(filter, currentElement);
- break;
- case PARAM_TAG:
- switch (getNameAttributeKey(currentElement)) {
- case FILE_PARAM:
- set(FILE_PARAM, currentElement, fileName);
- break;
- case APPEND_PARAM:
- set(APPEND_PARAM, currentElement, append);
- break;
- case BUFFERED_IO_PARAM:
- set(BUFFERED_IO_PARAM, currentElement, bufferedIo);
- break;
- case BUFFER_SIZE_PARAM:
- set(BUFFER_SIZE_PARAM, currentElement, bufferSize);
- break;
- case THRESHOLD_PARAM:
- set(THRESHOLD_PARAM, currentElement, level);
- break;
- case DATE_PATTERN_PARAM:
- set(DATE_PATTERN_PARAM, currentElement, datePattern);
- break;
- case IMMEDIATE_FLUSH_PARAM:
- set(IMMEDIATE_FLUSH_PARAM, currentElement, immediateFlush);
- break;
- }
- break;
- }
- });
- return createAppender(
- name,
- layout.get(),
- filter.get(),
- fileName.get(),
- append.get(),
- immediateFlush.get(),
- level.get(),
- bufferedIo.get(),
- bufferSize.get(),
- datePattern.get(),
- config,
- config.getComponent(Clock.KEY));
- }
-
- @Override
- public Appender parseAppender(
- final String name,
- final String appenderPrefix,
- final String layoutPrefix,
- final String filterPrefix,
- final Properties props,
- final PropertiesConfiguration configuration) {
- final Layout layout = configuration.parseLayout(layoutPrefix, name, props);
- final Filter filter = configuration.parseAppenderFilters(props, filterPrefix, name);
- final String fileName = getProperty(FILE_PARAM);
- final String level = getProperty(THRESHOLD_PARAM);
- final boolean append = getBooleanProperty(APPEND_PARAM, true);
- final boolean immediateFlush = getBooleanProperty(IMMEDIATE_FLUSH_PARAM, true);
- final boolean bufferedIo = getBooleanProperty(BUFFERED_IO_PARAM, false);
- final int bufferSize = getIntegerProperty(BUFFER_SIZE_PARAM, 8192);
- final String datePattern = getProperty(DATE_PATTERN_PARAM, DEFAULT_DATE_PATTERN);
- return createAppender(
- name,
- layout,
- filter,
- fileName,
- append,
- immediateFlush,
- level,
- bufferedIo,
- bufferSize,
- datePattern,
- configuration,
- configuration.getComponent(Clock.KEY));
- }
-
- private Appender createAppender(
- final String name,
- final Layout layout,
- final Filter filter,
- final String fileName,
- final boolean append,
- boolean immediateFlush,
- final String level,
- final boolean bufferedIo,
- final int bufferSize,
- final String datePattern,
- final T configuration,
- final Clock clock) {
-
- final org.apache.logging.log4j.core.Layout fileLayout = LayoutAdapter.adapt(layout);
- if (bufferedIo) {
- immediateFlush = false;
- }
- final org.apache.logging.log4j.core.Filter fileFilter = buildFilters(level, filter);
- if (fileName == null) {
- LOGGER.error("Unable to create DailyRollingFileAppender, no file name provided");
- return null;
- }
- final String filePattern = fileName + "%d{" + datePattern + "}";
- final TriggeringPolicy timePolicy = TimeBasedTriggeringPolicy.newBuilder()
- .setClock(clock)
- .setModulate(true)
- .build();
- final TriggeringPolicy policy = CompositeTriggeringPolicy.createPolicy(timePolicy);
- final RolloverStrategy strategy = DefaultRolloverStrategy.newBuilder()
- .setConfig(configuration)
- .setMax(Integer.toString(Integer.MAX_VALUE))
- .build();
- return AppenderWrapper.adapt(RollingFileAppender.newBuilder()
- .setName(name)
- .setConfiguration(configuration)
- .setLayout(fileLayout)
- .setFilter(fileFilter)
- .setFileName(fileName)
- .setAppend(append)
- .setBufferedIo(bufferedIo)
- .setBufferSize(bufferSize)
- .setImmediateFlush(immediateFlush)
- .setFilePattern(filePattern)
- .setPolicy(policy)
- .setStrategy(strategy)
- .build());
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/EnhancedRollingFileAppenderBuilder.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/EnhancedRollingFileAppenderBuilder.java
deleted file mode 100644
index 2c97bf170af..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/EnhancedRollingFileAppenderBuilder.java
+++ /dev/null
@@ -1,295 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders.appender;
-
-import static org.apache.log4j.builders.BuilderManager.NAMESPACE;
-import static org.apache.log4j.config.Log4j1Configuration.THRESHOLD_PARAM;
-import static org.apache.log4j.xml.XmlConfiguration.FILTER_TAG;
-import static org.apache.log4j.xml.XmlConfiguration.LAYOUT_TAG;
-import static org.apache.log4j.xml.XmlConfiguration.PARAM_TAG;
-import static org.apache.log4j.xml.XmlConfiguration.forEachElement;
-
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
-import org.apache.log4j.Appender;
-import org.apache.log4j.Layout;
-import org.apache.log4j.bridge.AppenderWrapper;
-import org.apache.log4j.bridge.LayoutAdapter;
-import org.apache.log4j.builders.AbstractBuilder;
-import org.apache.log4j.config.PropertiesConfiguration;
-import org.apache.log4j.spi.Filter;
-import org.apache.log4j.xml.XmlConfiguration;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.appender.RollingFileAppender;
-import org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy;
-import org.apache.logging.log4j.core.appender.rolling.TimeBasedTriggeringPolicy;
-import org.apache.logging.log4j.core.appender.rolling.TriggeringPolicy;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.plugins.Namespace;
-import org.apache.logging.log4j.plugins.Plugin;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.w3c.dom.Element;
-
-/**
- * Build a File Appender
- */
-@Plugin("org.apache.log4j.rolling.RollingFileAppender")
-@Namespace(NAMESPACE)
-public class EnhancedRollingFileAppenderBuilder extends AbstractBuilder implements AppenderBuilder {
-
- private static final String TIME_BASED_ROLLING_POLICY = "org.apache.log4j.rolling.TimeBasedRollingPolicy";
- private static final String FIXED_WINDOW_ROLLING_POLICY = "org.apache.log4j.rolling.FixedWindowRollingPolicy";
- private static final Logger LOGGER = StatusLogger.getLogger();
- private static final String TRIGGERING_TAG = "triggeringPolicy";
- private static final String ROLLING_TAG = "rollingPolicy";
- private static final int DEFAULT_MIN_INDEX = 1;
- private static final int DEFAULT_MAX_INDEX = 7;
- private static final String ACTIVE_FILE_PARAM = "ActiveFileName";
- private static final String FILE_PATTERN_PARAM = "FileNamePattern";
- private static final String MIN_INDEX_PARAM = "MinIndex";
- private static final String MAX_INDEX_PARAM = "MaxIndex";
-
- public EnhancedRollingFileAppenderBuilder() {}
-
- public EnhancedRollingFileAppenderBuilder(final String prefix, final Properties properties) {
- super(prefix, properties);
- }
-
- private void parseRollingPolicy(
- final Element element,
- final XmlConfiguration configuration,
- final AtomicReference rollingPolicyClassName,
- final AtomicReference activeFileName,
- final AtomicReference fileNamePattern,
- final AtomicInteger minIndex,
- final AtomicInteger maxIndex) {
- rollingPolicyClassName.set(configuration.subst(element.getAttribute("class"), getProperties()));
- forEachElement(element.getChildNodes(), currentElement -> {
- switch (currentElement.getTagName()) {
- case PARAM_TAG:
- switch (getNameAttributeKey(currentElement)) {
- case ACTIVE_FILE_PARAM:
- set(ACTIVE_FILE_PARAM, currentElement, activeFileName);
- break;
- case FILE_PATTERN_PARAM:
- set(FILE_PATTERN_PARAM, currentElement, fileNamePattern);
- break;
- case MIN_INDEX_PARAM:
- set(MIN_INDEX_PARAM, currentElement, minIndex);
- break;
- case MAX_INDEX_PARAM:
- set(MAX_INDEX_PARAM, currentElement, maxIndex);
- }
- }
- });
- }
-
- @Override
- public Appender parseAppender(final Element element, final XmlConfiguration configuration) {
- // FileAppender
- final String name = getNameAttribute(element);
- final AtomicReference layout = new AtomicReference<>();
- final AtomicReference filter = new AtomicReference<>();
- final AtomicReference fileName = new AtomicReference<>();
- final AtomicReference level = new AtomicReference<>();
- final AtomicBoolean immediateFlush = new AtomicBoolean(true);
- final AtomicBoolean append = new AtomicBoolean(true);
- final AtomicBoolean bufferedIo = new AtomicBoolean();
- final AtomicInteger bufferSize = new AtomicInteger(8192);
- // specific to RollingFileAppender
- final AtomicReference rollingPolicyClassName = new AtomicReference<>();
- final AtomicReference activeFileName = new AtomicReference<>();
- final AtomicReference fileNamePattern = new AtomicReference<>();
- final AtomicInteger minIndex = new AtomicInteger(DEFAULT_MIN_INDEX);
- final AtomicInteger maxIndex = new AtomicInteger(DEFAULT_MAX_INDEX);
- final AtomicReference triggeringPolicy = new AtomicReference<>();
- forEachElement(element.getChildNodes(), currentElement -> {
- switch (currentElement.getTagName()) {
- case ROLLING_TAG:
- parseRollingPolicy(
- currentElement,
- configuration,
- rollingPolicyClassName,
- activeFileName,
- fileNamePattern,
- minIndex,
- maxIndex);
- break;
- case TRIGGERING_TAG:
- triggeringPolicy.set(configuration.parseTriggeringPolicy(currentElement));
- break;
- case LAYOUT_TAG:
- layout.set(configuration.parseLayout(currentElement));
- break;
- case FILTER_TAG:
- configuration.addFilter(filter, currentElement);
- break;
- case PARAM_TAG:
- switch (getNameAttributeKey(currentElement)) {
- case FILE_PARAM:
- set(FILE_PARAM, currentElement, fileName);
- break;
- case APPEND_PARAM:
- set(APPEND_PARAM, currentElement, append);
- break;
- case BUFFERED_IO_PARAM:
- set(BUFFERED_IO_PARAM, currentElement, bufferedIo);
- break;
- case BUFFER_SIZE_PARAM:
- set(BUFFER_SIZE_PARAM, currentElement, bufferSize);
- break;
- case THRESHOLD_PARAM:
- set(THRESHOLD_PARAM, currentElement, level);
- break;
- case IMMEDIATE_FLUSH_PARAM:
- set(IMMEDIATE_FLUSH_PARAM, currentElement, immediateFlush);
- break;
- }
- break;
- }
- });
- return createAppender(
- name,
- layout.get(),
- filter.get(),
- fileName.get(),
- level.get(),
- immediateFlush.get(),
- append.get(),
- bufferedIo.get(),
- bufferSize.get(),
- rollingPolicyClassName.get(),
- activeFileName.get(),
- fileNamePattern.get(),
- minIndex.get(),
- maxIndex.get(),
- triggeringPolicy.get(),
- configuration);
- }
-
- @Override
- public Appender parseAppender(
- final String name,
- final String appenderPrefix,
- final String layoutPrefix,
- final String filterPrefix,
- final Properties props,
- final PropertiesConfiguration configuration) {
- final Layout layout = configuration.parseLayout(layoutPrefix, name, props);
- final Filter filter = configuration.parseAppenderFilters(props, filterPrefix, name);
- final String level = getProperty(THRESHOLD_PARAM);
- final String fileName = getProperty(FILE_PARAM);
- final boolean append = getBooleanProperty(APPEND_PARAM, true);
- final boolean immediateFlush = getBooleanProperty(IMMEDIATE_FLUSH_PARAM, true);
- final boolean bufferedIo = getBooleanProperty(BUFFERED_IO_PARAM, false);
- final int bufferSize = Integer.parseInt(getProperty(BUFFER_SIZE_PARAM, "8192"));
- final String rollingPolicyClassName = getProperty(ROLLING_TAG);
- final int minIndex = getIntegerProperty(ROLLING_TAG + "." + MIN_INDEX_PARAM, DEFAULT_MIN_INDEX);
- final int maxIndex = getIntegerProperty(ROLLING_TAG + "." + MAX_INDEX_PARAM, DEFAULT_MAX_INDEX);
- final String activeFileName = getProperty(ROLLING_TAG + "." + ACTIVE_FILE_PARAM);
- final String fileNamePattern = getProperty(ROLLING_TAG + "." + FILE_PATTERN_PARAM);
- final TriggeringPolicy triggeringPolicy =
- configuration.parseTriggeringPolicy(props, appenderPrefix + "." + TRIGGERING_TAG);
- return createAppender(
- name,
- layout,
- filter,
- fileName,
- level,
- immediateFlush,
- append,
- bufferedIo,
- bufferSize,
- rollingPolicyClassName,
- activeFileName,
- fileNamePattern,
- minIndex,
- maxIndex,
- triggeringPolicy,
- configuration);
- }
-
- private Appender createAppender(
- final String name,
- final Layout layout,
- final Filter filter,
- final String fileName,
- final String level,
- final boolean immediateFlush,
- final boolean append,
- final boolean bufferedIo,
- final int bufferSize,
- final String rollingPolicyClassName,
- final String activeFileName,
- final String fileNamePattern,
- final int minIndex,
- final int maxIndex,
- final TriggeringPolicy triggeringPolicy,
- final Configuration configuration) {
- final org.apache.logging.log4j.core.Layout fileLayout = LayoutAdapter.adapt(layout);
- final boolean actualImmediateFlush = bufferedIo ? false : immediateFlush;
- final org.apache.logging.log4j.core.Filter fileFilter = buildFilters(level, filter);
- if (rollingPolicyClassName == null) {
- LOGGER.error("Unable to create RollingFileAppender, no rolling policy provided.");
- return null;
- }
- final String actualFileName = activeFileName != null ? activeFileName : fileName;
- if (actualFileName == null) {
- LOGGER.error("Unable to create RollingFileAppender, no file name provided.");
- return null;
- }
- if (fileNamePattern == null) {
- LOGGER.error("Unable to create RollingFileAppender, no file name pattern provided.");
- return null;
- }
- final DefaultRolloverStrategy.Builder rolloverStrategyBuilder = DefaultRolloverStrategy.newBuilder();
- switch (rollingPolicyClassName) {
- case FIXED_WINDOW_ROLLING_POLICY:
- rolloverStrategyBuilder.setMin(Integer.toString(minIndex)).setMax(Integer.toString(maxIndex));
- break;
- case TIME_BASED_ROLLING_POLICY:
- break;
- default:
- LOGGER.warn("Unsupported rolling policy: {}", rollingPolicyClassName);
- }
- final TriggeringPolicy actualTriggeringPolicy;
- if (triggeringPolicy != null) {
- actualTriggeringPolicy = triggeringPolicy;
- } else if (rollingPolicyClassName.equals(TIME_BASED_ROLLING_POLICY)) {
- actualTriggeringPolicy = TimeBasedTriggeringPolicy.newBuilder().build();
- } else {
- LOGGER.error("Unable to create RollingFileAppender, no triggering policy provided.");
- return null;
- }
- return AppenderWrapper.adapt(RollingFileAppender.newBuilder()
- .setAppend(append)
- .setBufferedIo(bufferedIo)
- .setBufferSize(bufferedIo ? bufferSize : 0)
- .setConfiguration(configuration)
- .setFileName(actualFileName)
- .setFilePattern(fileNamePattern)
- .setFilter(fileFilter)
- .setImmediateFlush(actualImmediateFlush)
- .setLayout(fileLayout)
- .setName(name)
- .setPolicy(actualTriggeringPolicy)
- .setStrategy(rolloverStrategyBuilder.build())
- .build());
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/FileAppenderBuilder.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/FileAppenderBuilder.java
deleted file mode 100644
index 608ede4a458..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/FileAppenderBuilder.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders.appender;
-
-import static org.apache.log4j.builders.BuilderManager.NAMESPACE;
-import static org.apache.log4j.config.Log4j1Configuration.THRESHOLD_PARAM;
-import static org.apache.log4j.xml.XmlConfiguration.FILTER_TAG;
-import static org.apache.log4j.xml.XmlConfiguration.LAYOUT_TAG;
-import static org.apache.log4j.xml.XmlConfiguration.PARAM_TAG;
-import static org.apache.log4j.xml.XmlConfiguration.forEachElement;
-
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
-import org.apache.log4j.Appender;
-import org.apache.log4j.Layout;
-import org.apache.log4j.bridge.AppenderWrapper;
-import org.apache.log4j.bridge.LayoutAdapter;
-import org.apache.log4j.builders.AbstractBuilder;
-import org.apache.log4j.config.Log4j1Configuration;
-import org.apache.log4j.config.PropertiesConfiguration;
-import org.apache.log4j.spi.Filter;
-import org.apache.log4j.xml.XmlConfiguration;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.appender.FileAppender;
-import org.apache.logging.log4j.plugins.Namespace;
-import org.apache.logging.log4j.plugins.Plugin;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.w3c.dom.Element;
-
-/**
- * Build a File Appender
- */
-@Namespace(NAMESPACE)
-@Plugin("org.apache.log4j.FileAppender")
-public class FileAppenderBuilder extends AbstractBuilder implements AppenderBuilder {
-
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- public FileAppenderBuilder() {}
-
- public FileAppenderBuilder(final String prefix, final Properties props) {
- super(prefix, props);
- }
-
- @Override
- public Appender parseAppender(final Element appenderElement, final XmlConfiguration config) {
- final String name = getNameAttribute(appenderElement);
- final AtomicReference layout = new AtomicReference<>();
- final AtomicReference filter = new AtomicReference<>();
- final AtomicReference fileName = new AtomicReference<>();
- final AtomicReference level = new AtomicReference<>();
- final AtomicBoolean immediateFlush = new AtomicBoolean(true);
- final AtomicBoolean append = new AtomicBoolean(true);
- final AtomicBoolean bufferedIo = new AtomicBoolean();
- final AtomicInteger bufferSize = new AtomicInteger(8192);
- forEachElement(appenderElement.getChildNodes(), currentElement -> {
- switch (currentElement.getTagName()) {
- case LAYOUT_TAG:
- layout.set(config.parseLayout(currentElement));
- break;
- case FILTER_TAG:
- config.addFilter(filter, currentElement);
- break;
- case PARAM_TAG:
- switch (getNameAttributeKey(currentElement)) {
- case FILE_PARAM:
- set(FILE_PARAM, currentElement, fileName);
- break;
- case APPEND_PARAM:
- set(APPEND_PARAM, currentElement, append);
- break;
- case BUFFERED_IO_PARAM:
- set(BUFFERED_IO_PARAM, currentElement, bufferedIo);
- break;
- case BUFFER_SIZE_PARAM:
- set(BUFFER_SIZE_PARAM, currentElement, bufferSize);
- break;
- case THRESHOLD_PARAM:
- set(THRESHOLD_PARAM, currentElement, level);
- break;
- case IMMEDIATE_FLUSH_PARAM:
- set(IMMEDIATE_FLUSH_PARAM, currentElement, immediateFlush);
- break;
- }
- break;
- }
- });
-
- return createAppender(
- name,
- config,
- layout.get(),
- filter.get(),
- fileName.get(),
- level.get(),
- immediateFlush.get(),
- append.get(),
- bufferedIo.get(),
- bufferSize.get());
- }
-
- @Override
- public Appender parseAppender(
- final String name,
- final String appenderPrefix,
- final String layoutPrefix,
- final String filterPrefix,
- final Properties props,
- final PropertiesConfiguration configuration) {
- final Layout layout = configuration.parseLayout(layoutPrefix, name, props);
- final Filter filter = configuration.parseAppenderFilters(props, filterPrefix, name);
- final String level = getProperty(THRESHOLD_PARAM);
- final String fileName = getProperty(FILE_PARAM);
- final boolean append = getBooleanProperty(APPEND_PARAM, true);
- final boolean immediateFlush = getBooleanProperty(IMMEDIATE_FLUSH_PARAM, true);
- final boolean bufferedIo = getBooleanProperty(BUFFERED_IO_PARAM, false);
- final int bufferSize = Integer.parseInt(getProperty(BUFFER_SIZE_PARAM, "8192"));
- return createAppender(
- name, configuration, layout, filter, fileName, level, immediateFlush, append, bufferedIo, bufferSize);
- }
-
- private Appender createAppender(
- final String name,
- final Log4j1Configuration configuration,
- final Layout layout,
- final Filter filter,
- final String fileName,
- final String level,
- boolean immediateFlush,
- final boolean append,
- final boolean bufferedIo,
- final int bufferSize) {
- final org.apache.logging.log4j.core.Layout fileLayout = LayoutAdapter.adapt(layout);
- if (bufferedIo) {
- immediateFlush = false;
- }
- final org.apache.logging.log4j.core.Filter fileFilter = buildFilters(level, filter);
- if (fileName == null) {
- LOGGER.error("Unable to create FileAppender, no file name provided");
- return null;
- }
- return AppenderWrapper.adapt(FileAppender.newBuilder()
- .setName(name)
- .setConfiguration(configuration)
- .setLayout(fileLayout)
- .setFilter(fileFilter)
- .setFileName(fileName)
- .setImmediateFlush(immediateFlush)
- .setAppend(append)
- .setBufferedIo(bufferedIo)
- .setBufferSize(bufferSize)
- .build());
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/NullAppenderBuilder.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/NullAppenderBuilder.java
deleted file mode 100644
index fa561e53779..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/NullAppenderBuilder.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders.appender;
-
-import static org.apache.log4j.builders.BuilderManager.NAMESPACE;
-
-import java.util.Properties;
-import org.apache.log4j.Appender;
-import org.apache.log4j.bridge.AppenderWrapper;
-import org.apache.log4j.config.PropertiesConfiguration;
-import org.apache.log4j.xml.XmlConfiguration;
-import org.apache.logging.log4j.core.appender.NullAppender;
-import org.apache.logging.log4j.plugins.Namespace;
-import org.apache.logging.log4j.plugins.Plugin;
-import org.w3c.dom.Element;
-
-/**
- * Build a Null Appender
- */
-@Namespace(NAMESPACE)
-@Plugin("org.apache.log4j.varia.NullAppender")
-public class NullAppenderBuilder implements AppenderBuilder {
-
- @Override
- public Appender parseAppender(final Element appenderElement, final XmlConfiguration config) {
- final String name = appenderElement.getAttribute("name");
- return AppenderWrapper.adapt(NullAppender.createAppender(name));
- }
-
- @Override
- public Appender parseAppender(
- final String name,
- final String appenderPrefix,
- final String layoutPrefix,
- final String filterPrefix,
- final Properties props,
- final PropertiesConfiguration configuration) {
- return AppenderWrapper.adapt(NullAppender.createAppender(name));
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/RewriteAppenderBuilder.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/RewriteAppenderBuilder.java
deleted file mode 100644
index fafad7f2d4d..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/RewriteAppenderBuilder.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders.appender;
-
-import static org.apache.log4j.builders.BuilderManager.NAMESPACE;
-import static org.apache.log4j.config.Log4j1Configuration.APPENDER_REF_TAG;
-import static org.apache.log4j.config.Log4j1Configuration.THRESHOLD_PARAM;
-import static org.apache.log4j.xml.XmlConfiguration.FILTER_TAG;
-import static org.apache.log4j.xml.XmlConfiguration.PARAM_TAG;
-import static org.apache.log4j.xml.XmlConfiguration.forEachElement;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicReference;
-import org.apache.log4j.Appender;
-import org.apache.log4j.bridge.AppenderWrapper;
-import org.apache.log4j.bridge.RewritePolicyAdapter;
-import org.apache.log4j.bridge.RewritePolicyWrapper;
-import org.apache.log4j.builders.AbstractBuilder;
-import org.apache.log4j.builders.BuilderManager;
-import org.apache.log4j.config.Log4j1Configuration;
-import org.apache.log4j.config.PropertiesConfiguration;
-import org.apache.log4j.helpers.OptionConverter;
-import org.apache.log4j.rewrite.RewritePolicy;
-import org.apache.log4j.spi.Filter;
-import org.apache.log4j.xml.XmlConfiguration;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.appender.rewrite.RewriteAppender;
-import org.apache.logging.log4j.core.config.AppenderRef;
-import org.apache.logging.log4j.plugins.Namespace;
-import org.apache.logging.log4j.plugins.Plugin;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.util.Strings;
-import org.w3c.dom.Element;
-
-/**
- * Build an Rewrite Appender
- */
-@Namespace(NAMESPACE)
-@Plugin("org.apache.log4j.rewrite.RewriteAppender")
-public class RewriteAppenderBuilder extends AbstractBuilder implements AppenderBuilder {
-
- private static final Logger LOGGER = StatusLogger.getLogger();
- private static final String REWRITE_POLICY_TAG = "rewritePolicy";
-
- public RewriteAppenderBuilder() {}
-
- public RewriteAppenderBuilder(final String prefix, final Properties props) {
- super(prefix, props);
- }
-
- @Override
- public Appender parseAppender(final Element appenderElement, final XmlConfiguration config) {
- final String name = getNameAttribute(appenderElement);
- final AtomicReference> appenderRefs = new AtomicReference<>(new ArrayList<>());
- final AtomicReference rewritePolicyHolder = new AtomicReference<>();
- final AtomicReference level = new AtomicReference<>();
- final AtomicReference filter = new AtomicReference<>();
- forEachElement(appenderElement.getChildNodes(), currentElement -> {
- switch (currentElement.getTagName()) {
- case APPENDER_REF_TAG:
- final Appender appender = config.findAppenderByReference(currentElement);
- if (appender != null) {
- appenderRefs.get().add(appender.getName());
- }
- break;
- case REWRITE_POLICY_TAG:
- final RewritePolicy policy = config.parseRewritePolicy(currentElement);
- if (policy != null) {
- rewritePolicyHolder.set(policy);
- }
- break;
- case FILTER_TAG:
- config.addFilter(filter, currentElement);
- break;
- case PARAM_TAG:
- if (getNameAttributeKey(currentElement).equalsIgnoreCase(THRESHOLD_PARAM)) {
- set(THRESHOLD_PARAM, currentElement, level);
- }
- break;
- }
- });
- return createAppender(
- name,
- level.get(),
- appenderRefs.get().toArray(Strings.EMPTY_ARRAY),
- rewritePolicyHolder.get(),
- filter.get(),
- config);
- }
-
- @Override
- public Appender parseAppender(
- final String name,
- final String appenderPrefix,
- final String layoutPrefix,
- final String filterPrefix,
- final Properties props,
- final PropertiesConfiguration configuration) {
- final String appenderRef = getProperty(APPENDER_REF_TAG);
- final Filter filter = configuration.parseAppenderFilters(props, filterPrefix, name);
- final String policyPrefix = appenderPrefix + ".rewritePolicy";
- final String className = getProperty(policyPrefix);
- final RewritePolicy policy = configuration
- .getBuilderManager()
- .parse(className, policyPrefix, props, configuration, BuilderManager.INVALID_REWRITE_POLICY);
- final String level = getProperty(THRESHOLD_PARAM);
- if (appenderRef == null) {
- LOGGER.error("No appender references configured for RewriteAppender {}", name);
- return null;
- }
- final Appender appender = configuration.parseAppender(props, appenderRef);
- if (appender == null) {
- LOGGER.error("Cannot locate Appender {}", appenderRef);
- return null;
- }
- return createAppender(name, level, new String[] {appenderRef}, policy, filter, configuration);
- }
-
- private Appender createAppender(
- final String name,
- final String level,
- final String[] appenderRefs,
- final RewritePolicy policy,
- final Filter filter,
- final T configuration) {
- if (appenderRefs.length == 0) {
- LOGGER.error("No appender references configured for RewriteAppender {}", name);
- return null;
- }
- final Level logLevel = OptionConverter.convertLevel(level, Level.TRACE);
- final AppenderRef[] refs = new AppenderRef[appenderRefs.length];
- int index = 0;
- for (final String appenderRef : appenderRefs) {
- refs[index++] = AppenderRef.createAppenderRef(appenderRef, logLevel, null);
- }
- final org.apache.logging.log4j.core.Filter rewriteFilter = buildFilters(level, filter);
- org.apache.logging.log4j.core.appender.rewrite.RewritePolicy rewritePolicy;
- if (policy instanceof RewritePolicyWrapper) {
- rewritePolicy = ((RewritePolicyWrapper) policy).getPolicy();
- } else {
- rewritePolicy = new RewritePolicyAdapter(policy);
- }
- return AppenderWrapper.adapt(
- RewriteAppender.createAppender(name, true, refs, configuration, rewritePolicy, rewriteFilter));
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/RollingFileAppenderBuilder.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/RollingFileAppenderBuilder.java
deleted file mode 100644
index 897d7d598f4..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/RollingFileAppenderBuilder.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders.appender;
-
-import static org.apache.log4j.builders.BuilderManager.NAMESPACE;
-import static org.apache.log4j.config.Log4j1Configuration.THRESHOLD_PARAM;
-import static org.apache.log4j.xml.XmlConfiguration.FILTER_TAG;
-import static org.apache.log4j.xml.XmlConfiguration.LAYOUT_TAG;
-import static org.apache.log4j.xml.XmlConfiguration.PARAM_TAG;
-import static org.apache.log4j.xml.XmlConfiguration.forEachElement;
-
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
-import org.apache.log4j.Appender;
-import org.apache.log4j.Layout;
-import org.apache.log4j.bridge.AppenderWrapper;
-import org.apache.log4j.bridge.LayoutAdapter;
-import org.apache.log4j.builders.AbstractBuilder;
-import org.apache.log4j.config.Log4j1Configuration;
-import org.apache.log4j.config.PropertiesConfiguration;
-import org.apache.log4j.spi.Filter;
-import org.apache.log4j.xml.XmlConfiguration;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.appender.RollingFileAppender;
-import org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy;
-import org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy;
-import org.apache.logging.log4j.core.appender.rolling.RolloverStrategy;
-import org.apache.logging.log4j.core.appender.rolling.SizeBasedTriggeringPolicy;
-import org.apache.logging.log4j.core.time.Clock;
-import org.apache.logging.log4j.plugins.Namespace;
-import org.apache.logging.log4j.plugins.Plugin;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.w3c.dom.Element;
-
-/**
- * Build a File Appender
- */
-@Namespace(NAMESPACE)
-@Plugin("org.apache.log4j.RollingFileAppender")
-public class RollingFileAppenderBuilder extends AbstractBuilder implements AppenderBuilder {
-
- private static final String DEFAULT_MAX_SIZE = "10 MB";
- private static final String DEFAULT_MAX_BACKUPS = "1";
-
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- public RollingFileAppenderBuilder() {}
-
- public RollingFileAppenderBuilder(final String prefix, final Properties properties) {
- super(prefix, properties);
- }
-
- @Override
- public Appender parseAppender(final Element appenderElement, final XmlConfiguration config) {
- final String name = getNameAttribute(appenderElement);
- final AtomicReference layout = new AtomicReference<>();
- final AtomicReference filter = new AtomicReference<>();
- final AtomicReference fileName = new AtomicReference<>();
- final AtomicBoolean immediateFlush = new AtomicBoolean(true);
- final AtomicBoolean append = new AtomicBoolean(true);
- final AtomicBoolean bufferedIo = new AtomicBoolean();
- final AtomicInteger bufferSize = new AtomicInteger(8192);
- final AtomicReference maxSize = new AtomicReference<>(DEFAULT_MAX_SIZE);
- final AtomicReference maxBackups = new AtomicReference<>(DEFAULT_MAX_BACKUPS);
- final AtomicReference level = new AtomicReference<>();
- forEachElement(appenderElement.getChildNodes(), currentElement -> {
- switch (currentElement.getTagName()) {
- case LAYOUT_TAG:
- layout.set(config.parseLayout(currentElement));
- break;
- case FILTER_TAG:
- config.addFilter(filter, currentElement);
- break;
- case PARAM_TAG:
- switch (getNameAttributeKey(currentElement)) {
- case FILE_PARAM:
- set(FILE_PARAM, currentElement, fileName);
- break;
- case APPEND_PARAM:
- set(APPEND_PARAM, currentElement, append);
- break;
- case BUFFERED_IO_PARAM:
- set(BUFFERED_IO_PARAM, currentElement, bufferedIo);
- break;
- case BUFFER_SIZE_PARAM:
- set(BUFFER_SIZE_PARAM, currentElement, bufferSize);
- break;
- case MAX_BACKUP_INDEX:
- set(MAX_BACKUP_INDEX, currentElement, maxBackups);
- break;
- case MAX_SIZE_PARAM:
- set(MAX_SIZE_PARAM, currentElement, maxSize);
- break;
- case THRESHOLD_PARAM:
- set(THRESHOLD_PARAM, currentElement, level);
- break;
- case IMMEDIATE_FLUSH_PARAM:
- set(IMMEDIATE_FLUSH_PARAM, currentElement, immediateFlush);
- break;
- }
- break;
- }
- });
- return createAppender(
- name,
- config,
- layout.get(),
- filter.get(),
- append.get(),
- bufferedIo.get(),
- bufferSize.get(),
- immediateFlush.get(),
- fileName.get(),
- level.get(),
- maxSize.get(),
- maxBackups.get(),
- config.getComponent(Clock.KEY));
- }
-
- @Override
- public Appender parseAppender(
- final String name,
- final String appenderPrefix,
- final String layoutPrefix,
- final String filterPrefix,
- final Properties props,
- final PropertiesConfiguration configuration) {
- final Layout layout = configuration.parseLayout(layoutPrefix, name, props);
- final Filter filter = configuration.parseAppenderFilters(props, filterPrefix, name);
- final String fileName = getProperty(FILE_PARAM);
- final String level = getProperty(THRESHOLD_PARAM);
- final boolean append = getBooleanProperty(APPEND_PARAM, true);
- final boolean immediateFlush = getBooleanProperty(IMMEDIATE_FLUSH_PARAM, true);
- final boolean bufferedIo = getBooleanProperty(BUFFERED_IO_PARAM, false);
- final int bufferSize = getIntegerProperty(BUFFER_SIZE_PARAM, 8192);
- final String maxSize = getProperty(MAX_SIZE_PARAM, DEFAULT_MAX_SIZE);
- final String maxBackups = getProperty(MAX_BACKUP_INDEX, DEFAULT_MAX_BACKUPS);
- return createAppender(
- name,
- configuration,
- layout,
- filter,
- append,
- bufferedIo,
- bufferSize,
- immediateFlush,
- fileName,
- level,
- maxSize,
- maxBackups,
- configuration.getComponent(Clock.KEY));
- }
-
- private Appender createAppender(
- final String name,
- final Log4j1Configuration config,
- final Layout layout,
- final Filter filter,
- final boolean append,
- final boolean bufferedIo,
- final int bufferSize,
- boolean immediateFlush,
- final String fileName,
- final String level,
- final String maxSize,
- final String maxBackups,
- final Clock clock) {
- final org.apache.logging.log4j.core.Layout fileLayout = LayoutAdapter.adapt(layout);
- if (!bufferedIo) {
- immediateFlush = false;
- }
- final org.apache.logging.log4j.core.Filter fileFilter = buildFilters(level, filter);
- if (fileName == null) {
- LOGGER.error("Unable to create RollingFileAppender, no file name provided");
- return null;
- }
- final String filePattern = fileName + ".%i";
- final SizeBasedTriggeringPolicy sizePolicy = SizeBasedTriggeringPolicy.createPolicy(maxSize);
- final CompositeTriggeringPolicy policy = CompositeTriggeringPolicy.createPolicy(sizePolicy);
- final RolloverStrategy strategy = DefaultRolloverStrategy.newBuilder()
- .setConfig(config)
- .setMax(maxBackups)
- .setFileIndex("min")
- .build();
- return AppenderWrapper.adapt(RollingFileAppender.newBuilder()
- .setName(name)
- .setConfiguration(config)
- .setLayout(fileLayout)
- .setFilter(fileFilter)
- .setAppend(append)
- .setBufferedIo(bufferedIo)
- .setBufferSize(bufferSize)
- .setImmediateFlush(immediateFlush)
- .setFileName(fileName)
- .setFilePattern(filePattern)
- .setPolicy(policy)
- .setStrategy(strategy)
- .build());
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/SocketAppenderBuilder.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/SocketAppenderBuilder.java
deleted file mode 100644
index e9253d515ef..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/SocketAppenderBuilder.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders.appender;
-
-import static org.apache.log4j.builders.BuilderManager.NAMESPACE;
-import static org.apache.log4j.config.Log4j1Configuration.THRESHOLD_PARAM;
-import static org.apache.log4j.xml.XmlConfiguration.FILTER_TAG;
-import static org.apache.log4j.xml.XmlConfiguration.LAYOUT_TAG;
-import static org.apache.log4j.xml.XmlConfiguration.PARAM_TAG;
-import static org.apache.log4j.xml.XmlConfiguration.forEachElement;
-
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
-import org.apache.log4j.Appender;
-import org.apache.log4j.Layout;
-import org.apache.log4j.bridge.AppenderWrapper;
-import org.apache.log4j.bridge.LayoutAdapter;
-import org.apache.log4j.builders.AbstractBuilder;
-import org.apache.log4j.config.Log4j1Configuration;
-import org.apache.log4j.config.PropertiesConfiguration;
-import org.apache.log4j.spi.Filter;
-import org.apache.log4j.xml.XmlConfiguration;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.appender.SocketAppender;
-import org.apache.logging.log4j.plugins.Namespace;
-import org.apache.logging.log4j.plugins.Plugin;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.w3c.dom.Element;
-
-/**
- * Build a Console Appender
- */
-@Namespace(NAMESPACE)
-@Plugin("org.apache.log4j.net.SocketAppender")
-public class SocketAppenderBuilder extends AbstractBuilder implements AppenderBuilder {
-
- private static final String HOST_PARAM = "RemoteHost";
- private static final String PORT_PARAM = "Port";
- private static final String RECONNECTION_DELAY_PARAM = "ReconnectionDelay";
- private static final int DEFAULT_PORT = 4560;
-
- /**
- * The default reconnection delay (30000 milliseconds or 30 seconds).
- */
- private static final int DEFAULT_RECONNECTION_DELAY = 30_000;
-
- public static final Logger LOGGER = StatusLogger.getLogger();
-
- public SocketAppenderBuilder() {}
-
- public SocketAppenderBuilder(final String prefix, final Properties props) {
- super(prefix, props);
- }
-
- private Appender createAppender(
- final String name,
- final String host,
- final int port,
- final Layout layout,
- final Filter filter,
- final String level,
- final boolean immediateFlush,
- final int reconnectDelayMillis,
- final T configuration) {
- final org.apache.logging.log4j.core.Layout actualLayout = LayoutAdapter.adapt(layout);
- final org.apache.logging.log4j.core.Filter actualFilter = buildFilters(level, filter);
- // @formatter:off
- return AppenderWrapper.adapt(SocketAppender.newBuilder()
- .setHost(host)
- .setPort(port)
- .setReconnectDelayMillis(reconnectDelayMillis)
- .setName(name)
- .setLayout(actualLayout)
- .setFilter(actualFilter)
- .setConfiguration(configuration)
- .setImmediateFlush(immediateFlush)
- .build());
- // @formatter:on
- }
-
- @Override
- public Appender parseAppender(final Element appenderElement, final XmlConfiguration config) {
- final String name = getNameAttribute(appenderElement);
- final AtomicReference host = new AtomicReference<>("localhost");
- final AtomicInteger port = new AtomicInteger(DEFAULT_PORT);
- final AtomicInteger reconnectDelay = new AtomicInteger(DEFAULT_RECONNECTION_DELAY);
- final AtomicReference layout = new AtomicReference<>();
- final AtomicReference filter = new AtomicReference<>();
- final AtomicReference level = new AtomicReference<>();
- final AtomicBoolean immediateFlush = new AtomicBoolean(true);
- forEachElement(appenderElement.getChildNodes(), currentElement -> {
- switch (currentElement.getTagName()) {
- case LAYOUT_TAG:
- layout.set(config.parseLayout(currentElement));
- break;
- case FILTER_TAG:
- config.addFilter(filter, currentElement);
- break;
- case PARAM_TAG:
- switch (getNameAttributeKey(currentElement)) {
- case HOST_PARAM:
- set(HOST_PARAM, currentElement, host);
- break;
- case PORT_PARAM:
- set(PORT_PARAM, currentElement, port);
- break;
- case RECONNECTION_DELAY_PARAM:
- set(RECONNECTION_DELAY_PARAM, currentElement, reconnectDelay);
- break;
- case THRESHOLD_PARAM:
- set(THRESHOLD_PARAM, currentElement, level);
- break;
- case IMMEDIATE_FLUSH_PARAM:
- set(IMMEDIATE_FLUSH_PARAM, currentElement, immediateFlush);
- break;
- }
- break;
- }
- });
- return createAppender(
- name,
- host.get(),
- port.get(),
- layout.get(),
- filter.get(),
- level.get(),
- immediateFlush.get(),
- reconnectDelay.get(),
- config);
- }
-
- @Override
- public Appender parseAppender(
- final String name,
- final String appenderPrefix,
- final String layoutPrefix,
- final String filterPrefix,
- final Properties props,
- final PropertiesConfiguration configuration) {
- // @formatter:off
- return createAppender(
- name,
- getProperty(HOST_PARAM),
- getIntegerProperty(PORT_PARAM, DEFAULT_PORT),
- configuration.parseLayout(layoutPrefix, name, props),
- configuration.parseAppenderFilters(props, filterPrefix, name),
- getProperty(THRESHOLD_PARAM),
- getBooleanProperty(IMMEDIATE_FLUSH_PARAM),
- getIntegerProperty(RECONNECTION_DELAY_PARAM, DEFAULT_RECONNECTION_DELAY),
- configuration);
- // @formatter:on
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/SyslogAppenderBuilder.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/SyslogAppenderBuilder.java
deleted file mode 100644
index 462de5a5633..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/SyslogAppenderBuilder.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders.appender;
-
-import static org.apache.log4j.builders.BuilderManager.NAMESPACE;
-import static org.apache.log4j.config.Log4j1Configuration.THRESHOLD_PARAM;
-import static org.apache.log4j.xml.XmlConfiguration.FILTER_TAG;
-import static org.apache.log4j.xml.XmlConfiguration.LAYOUT_TAG;
-import static org.apache.log4j.xml.XmlConfiguration.PARAM_TAG;
-import static org.apache.log4j.xml.XmlConfiguration.forEachElement;
-
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
-import org.apache.log4j.Appender;
-import org.apache.log4j.Layout;
-import org.apache.log4j.bridge.AppenderWrapper;
-import org.apache.log4j.bridge.LayoutAdapter;
-import org.apache.log4j.builders.AbstractBuilder;
-import org.apache.log4j.config.Log4j1Configuration;
-import org.apache.log4j.config.PropertiesConfiguration;
-import org.apache.log4j.layout.Log4j1SyslogLayout;
-import org.apache.log4j.spi.Filter;
-import org.apache.log4j.xml.XmlConfiguration;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.appender.SyslogAppender;
-import org.apache.logging.log4j.core.net.Facility;
-import org.apache.logging.log4j.core.net.Protocol;
-import org.apache.logging.log4j.plugins.Namespace;
-import org.apache.logging.log4j.plugins.Plugin;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.util.Strings;
-import org.w3c.dom.Element;
-
-/**
- * Build a File Appender
- */
-@Namespace(NAMESPACE)
-@Plugin("org.apache.log4j.net.SyslogAppender")
-public class SyslogAppenderBuilder extends AbstractBuilder implements AppenderBuilder {
-
- private static final String DEFAULT_HOST = "localhost";
- private static int DEFAULT_PORT = 514;
- private static final String DEFAULT_FACILITY = "LOCAL0";
- private static final Logger LOGGER = StatusLogger.getLogger();
- private static final String FACILITY_PARAM = "Facility";
- private static final String FACILITY_PRINTING_PARAM = "FacilityPrinting";
- private static final String HEADER_PARAM = "Header";
- private static final String PROTOCOL_PARAM = "Protocol";
- private static final String SYSLOG_HOST_PARAM = "SyslogHost";
-
- public SyslogAppenderBuilder() {}
-
- public SyslogAppenderBuilder(final String prefix, final Properties props) {
- super(prefix, props);
- }
-
- @Override
- public Appender parseAppender(final Element appenderElement, final XmlConfiguration config) {
- final String name = getNameAttribute(appenderElement);
- final AtomicReference layout = new AtomicReference<>();
- final AtomicReference filter = new AtomicReference<>();
- final AtomicReference facility = new AtomicReference<>();
- final AtomicReference level = new AtomicReference<>();
- final AtomicReference host = new AtomicReference<>();
- final AtomicReference protocol = new AtomicReference<>(Protocol.TCP);
- final AtomicBoolean header = new AtomicBoolean(false);
- final AtomicBoolean facilityPrinting = new AtomicBoolean(false);
- forEachElement(appenderElement.getChildNodes(), currentElement -> {
- switch (currentElement.getTagName()) {
- case LAYOUT_TAG:
- layout.set(config.parseLayout(currentElement));
- break;
- case FILTER_TAG:
- config.addFilter(filter, currentElement);
- break;
- case PARAM_TAG:
- switch (getNameAttributeKey(currentElement)) {
- case FACILITY_PARAM:
- set(FACILITY_PARAM, currentElement, facility);
- break;
- case FACILITY_PRINTING_PARAM:
- set(FACILITY_PRINTING_PARAM, currentElement, facilityPrinting);
- break;
- case HEADER_PARAM:
- set(HEADER_PARAM, currentElement, header);
- break;
- case PROTOCOL_PARAM:
- protocol.set(Protocol.valueOf(getValueAttribute(currentElement, Protocol.TCP.name())));
- break;
- case SYSLOG_HOST_PARAM:
- set(SYSLOG_HOST_PARAM, currentElement, host);
- break;
- case THRESHOLD_PARAM:
- set(THRESHOLD_PARAM, currentElement, level);
- break;
- }
- break;
- }
- });
-
- return createAppender(
- name,
- config,
- layout.get(),
- facility.get(),
- filter.get(),
- host.get(),
- level.get(),
- protocol.get(),
- header.get(),
- facilityPrinting.get());
- }
-
- @Override
- public Appender parseAppender(
- final String name,
- final String appenderPrefix,
- final String layoutPrefix,
- final String filterPrefix,
- final Properties props,
- final PropertiesConfiguration configuration) {
- final Filter filter = configuration.parseAppenderFilters(props, filterPrefix, name);
- final Layout layout = configuration.parseLayout(layoutPrefix, name, props);
- final String level = getProperty(THRESHOLD_PARAM);
- final String facility = getProperty(FACILITY_PARAM, DEFAULT_FACILITY);
- final boolean facilityPrinting = getBooleanProperty(FACILITY_PRINTING_PARAM, false);
- final boolean header = getBooleanProperty(HEADER_PARAM, false);
- final String protocol = getProperty(PROTOCOL_PARAM, Protocol.TCP.name());
- final String syslogHost = getProperty(SYSLOG_HOST_PARAM, DEFAULT_HOST + ":" + DEFAULT_PORT);
-
- return createAppender(
- name,
- configuration,
- layout,
- facility,
- filter,
- syslogHost,
- level,
- Protocol.valueOf(protocol),
- header,
- facilityPrinting);
- }
-
- private Appender createAppender(
- final String name,
- final Log4j1Configuration configuration,
- final Layout layout,
- final String facility,
- final Filter filter,
- final String syslogHost,
- final String level,
- final Protocol protocol,
- final boolean header,
- final boolean facilityPrinting) {
- final AtomicReference host = new AtomicReference<>();
- final AtomicInteger port = new AtomicInteger();
- resolveSyslogHost(syslogHost, host, port);
- final org.apache.logging.log4j.core.Layout messageLayout = LayoutAdapter.adapt(layout);
- final Log4j1SyslogLayout appenderLayout = Log4j1SyslogLayout.newBuilder()
- .setConfiguration(configuration)
- .setHeader(header)
- .setFacility(Facility.toFacility(facility))
- .setFacilityPrinting(facilityPrinting)
- .setMessageLayout(messageLayout)
- .build();
-
- final org.apache.logging.log4j.core.Filter fileFilter = buildFilters(level, filter);
- return AppenderWrapper.adapt(SyslogAppender.newSyslogAppenderBuilder()
- .setName(name)
- .setConfiguration(configuration)
- .setLayout(appenderLayout)
- .setFilter(fileFilter)
- .setPort(port.get())
- .setProtocol(protocol)
- .setHost(host.get())
- .build());
- }
-
- private void resolveSyslogHost(
- final String syslogHost, final AtomicReference host, final AtomicInteger port) {
- //
- // If not an unbracketed IPv6 address then
- // parse as a URL
- //
- final String[] parts = syslogHost != null ? syslogHost.split(":") : Strings.EMPTY_ARRAY;
- if (parts.length == 1) {
- host.set(parts[0]);
- port.set(DEFAULT_PORT);
- } else if (parts.length == 2) {
- host.set(parts[0]);
- port.set(Integer.parseInt(parts[1].trim()));
- } else {
- LOGGER.warn("Invalid {} setting: {}. Using default.", SYSLOG_HOST_PARAM, syslogHost);
- host.set(DEFAULT_HOST);
- port.set(DEFAULT_PORT);
- }
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/package-info.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/package-info.java
deleted file mode 100644
index 49a049a8390..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/appender/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-@Open("org.apache.logging.log4j.core")
-package org.apache.log4j.builders.appender;
-
-import aQute.bnd.annotation.jpms.Open;
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/filter/DenyAllFilterBuilder.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/filter/DenyAllFilterBuilder.java
deleted file mode 100644
index 9f674ddeac9..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/filter/DenyAllFilterBuilder.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders.filter;
-
-import static org.apache.log4j.builders.BuilderManager.NAMESPACE;
-
-import org.apache.log4j.bridge.FilterWrapper;
-import org.apache.log4j.config.PropertiesConfiguration;
-import org.apache.log4j.spi.Filter;
-import org.apache.log4j.xml.XmlConfiguration;
-import org.apache.logging.log4j.core.filter.DenyAllFilter;
-import org.apache.logging.log4j.plugins.Namespace;
-import org.apache.logging.log4j.plugins.Plugin;
-import org.w3c.dom.Element;
-
-/**
- * Build a Pattern Layout
- */
-@Namespace(NAMESPACE)
-@Plugin("org.apache.log4j.varia.DenyAllFilter")
-public class DenyAllFilterBuilder implements FilterBuilder {
-
- @Override
- public Filter parse(final Element filterElement, final XmlConfiguration config) {
- return new FilterWrapper(DenyAllFilter.newBuilder().build());
- }
-
- @Override
- public Filter parse(final PropertiesConfiguration config) {
- return new FilterWrapper(DenyAllFilter.newBuilder().build());
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/filter/FilterBuilder.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/filter/FilterBuilder.java
deleted file mode 100644
index 9db96a971da..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/filter/FilterBuilder.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders.filter;
-
-import org.apache.log4j.builders.Parser;
-import org.apache.log4j.spi.Filter;
-
-/**
- * Define a Filter Builder.
- */
-public interface FilterBuilder extends Parser {
- // empty
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/filter/LevelMatchFilterBuilder.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/filter/LevelMatchFilterBuilder.java
deleted file mode 100644
index 4fc8b71478b..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/filter/LevelMatchFilterBuilder.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders.filter;
-
-import static org.apache.log4j.builders.BuilderManager.NAMESPACE;
-import static org.apache.log4j.xml.XmlConfiguration.forEachElement;
-
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicReference;
-import org.apache.log4j.bridge.FilterWrapper;
-import org.apache.log4j.builders.AbstractBuilder;
-import org.apache.log4j.config.PropertiesConfiguration;
-import org.apache.log4j.helpers.OptionConverter;
-import org.apache.log4j.spi.Filter;
-import org.apache.log4j.xml.XmlConfiguration;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.filter.LevelMatchFilter;
-import org.apache.logging.log4j.plugins.Namespace;
-import org.apache.logging.log4j.plugins.Plugin;
-import org.w3c.dom.Element;
-
-/**
- * Build a Level match filter.
- */
-@Namespace(NAMESPACE)
-@Plugin("org.apache.log4j.varia.LevelMatchFilter")
-public class LevelMatchFilterBuilder extends AbstractBuilder implements FilterBuilder {
-
- private static final String LEVEL = "LevelToMatch";
- private static final String ACCEPT_ON_MATCH = "AcceptOnMatch";
-
- public LevelMatchFilterBuilder() {}
-
- public LevelMatchFilterBuilder(final String prefix, final Properties props) {
- super(prefix, props);
- }
-
- @Override
- public Filter parse(final Element filterElement, final XmlConfiguration config) {
- final AtomicReference level = new AtomicReference<>();
- final AtomicBoolean acceptOnMatch = new AtomicBoolean();
- forEachElement(filterElement.getElementsByTagName("param"), currentElement -> {
- if (currentElement.getTagName().equals("param")) {
- switch (getNameAttributeKey(currentElement)) {
- case LEVEL:
- level.set(getValueAttribute(currentElement));
- break;
- case ACCEPT_ON_MATCH:
- acceptOnMatch.set(getBooleanValueAttribute(currentElement));
- break;
- }
- }
- });
- return createFilter(level.get(), acceptOnMatch.get());
- }
-
- @Override
- public Filter parse(final PropertiesConfiguration config) {
- final String level = getProperty(LEVEL);
- final boolean acceptOnMatch = getBooleanProperty(ACCEPT_ON_MATCH);
- return createFilter(level, acceptOnMatch);
- }
-
- private Filter createFilter(final String level, final boolean acceptOnMatch) {
- Level lvl = Level.ERROR;
- if (level != null) {
- lvl = OptionConverter.toLevel(level, org.apache.log4j.Level.ERROR).getVersion2Level();
- }
- final org.apache.logging.log4j.core.Filter.Result onMatch = acceptOnMatch
- ? org.apache.logging.log4j.core.Filter.Result.ACCEPT
- : org.apache.logging.log4j.core.Filter.Result.DENY;
- return FilterWrapper.adapt(LevelMatchFilter.newBuilder()
- .setLevel(lvl)
- .setOnMatch(onMatch)
- .setOnMismatch(org.apache.logging.log4j.core.Filter.Result.NEUTRAL)
- .build());
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/filter/LevelRangeFilterBuilder.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/filter/LevelRangeFilterBuilder.java
deleted file mode 100644
index 781665ab1bb..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/filter/LevelRangeFilterBuilder.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders.filter;
-
-import static org.apache.log4j.builders.BuilderManager.NAMESPACE;
-import static org.apache.log4j.xml.XmlConfiguration.forEachElement;
-
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicReference;
-import org.apache.log4j.bridge.FilterWrapper;
-import org.apache.log4j.builders.AbstractBuilder;
-import org.apache.log4j.config.PropertiesConfiguration;
-import org.apache.log4j.helpers.OptionConverter;
-import org.apache.log4j.spi.Filter;
-import org.apache.log4j.xml.XmlConfiguration;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.filter.LevelRangeFilter;
-import org.apache.logging.log4j.plugins.Namespace;
-import org.apache.logging.log4j.plugins.Plugin;
-import org.w3c.dom.Element;
-
-/**
- * Build a Level range filter.
- * In this class, order of {@link Level} is log4j1 way, i.e.,
- * {@link Level#ALL} and {@link Level#OFF} have minimum and maximum order, respectively.
- * (see: LOG4J2-2315)
- */
-@Namespace(NAMESPACE)
-@Plugin("org.apache.log4j.varia.LevelRangeFilter")
-public class LevelRangeFilterBuilder extends AbstractBuilder implements FilterBuilder {
-
- private static final String LEVEL_MAX = "LevelMax";
- private static final String LEVEL_MIN = "LevelMin";
- private static final String ACCEPT_ON_MATCH = "AcceptOnMatch";
-
- public LevelRangeFilterBuilder() {}
-
- public LevelRangeFilterBuilder(final String prefix, final Properties props) {
- super(prefix, props);
- }
-
- @Override
- public Filter parse(final Element filterElement, final XmlConfiguration config) {
- final AtomicReference levelMax = new AtomicReference<>();
- final AtomicReference levelMin = new AtomicReference<>();
- final AtomicBoolean acceptOnMatch = new AtomicBoolean();
- forEachElement(filterElement.getElementsByTagName("param"), currentElement -> {
- if (currentElement.getTagName().equals("param")) {
- switch (getNameAttributeKey(currentElement)) {
- case LEVEL_MAX:
- levelMax.set(getValueAttribute(currentElement));
- break;
- case LEVEL_MIN:
- levelMin.set(getValueAttribute(currentElement));
- break;
- case ACCEPT_ON_MATCH:
- acceptOnMatch.set(getBooleanValueAttribute(currentElement));
- break;
- }
- }
- });
- return createFilter(levelMax.get(), levelMin.get(), acceptOnMatch.get());
- }
-
- @Override
- public Filter parse(final PropertiesConfiguration config) {
- final String levelMax = getProperty(LEVEL_MAX);
- final String levelMin = getProperty(LEVEL_MIN);
- final boolean acceptOnMatch = getBooleanProperty(ACCEPT_ON_MATCH);
- return createFilter(levelMax, levelMin, acceptOnMatch);
- }
-
- private Filter createFilter(final String levelMax, final String levelMin, final boolean acceptOnMatch) {
- Level max = Level.OFF;
- Level min = Level.ALL;
- if (levelMax != null) {
- max = OptionConverter.toLevel(levelMax, org.apache.log4j.Level.OFF).getVersion2Level();
- }
- if (levelMin != null) {
- min = OptionConverter.toLevel(levelMin, org.apache.log4j.Level.ALL).getVersion2Level();
- }
- final org.apache.logging.log4j.core.Filter.Result onMatch = acceptOnMatch
- ? org.apache.logging.log4j.core.Filter.Result.ACCEPT
- : org.apache.logging.log4j.core.Filter.Result.NEUTRAL;
-
- // XXX: LOG4J2-2315
- // log4j1 order: ALL < TRACE < DEBUG < ... < FATAL < OFF
- // log4j2 order: ALL > TRACE > DEBUG > ... > FATAL > OFF
- // So we create as LevelRangeFilter.createFilter(minLevel=max, maxLevel=min, ...)
- return FilterWrapper.adapt(
- LevelRangeFilter.createFilter(max, min, onMatch, org.apache.logging.log4j.core.Filter.Result.DENY));
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/filter/StringMatchFilterBuilder.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/filter/StringMatchFilterBuilder.java
deleted file mode 100644
index 9a77e3b6159..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/filter/StringMatchFilterBuilder.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders.filter;
-
-import static org.apache.log4j.builders.BuilderManager.NAMESPACE;
-import static org.apache.log4j.xml.XmlConfiguration.forEachElement;
-
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicReference;
-import org.apache.log4j.bridge.FilterWrapper;
-import org.apache.log4j.builders.AbstractBuilder;
-import org.apache.log4j.config.PropertiesConfiguration;
-import org.apache.log4j.spi.Filter;
-import org.apache.log4j.xml.XmlConfiguration;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.filter.StringMatchFilter;
-import org.apache.logging.log4j.plugins.Namespace;
-import org.apache.logging.log4j.plugins.Plugin;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.w3c.dom.Element;
-
-/**
- * Build a String match filter.
- */
-@Namespace(NAMESPACE)
-@Plugin("org.apache.log4j.varia.StringMatchFilter")
-public class StringMatchFilterBuilder extends AbstractBuilder implements FilterBuilder {
-
- private static final Logger LOGGER = StatusLogger.getLogger();
- private static final String STRING_TO_MATCH = "StringToMatch";
- private static final String ACCEPT_ON_MATCH = "AcceptOnMatch";
-
- public StringMatchFilterBuilder() {
- super();
- }
-
- public StringMatchFilterBuilder(final String prefix, final Properties props) {
- super(prefix, props);
- }
-
- @Override
- public Filter parse(final Element filterElement, final XmlConfiguration config) {
- final AtomicBoolean acceptOnMatch = new AtomicBoolean();
- final AtomicReference text = new AtomicReference<>();
- forEachElement(filterElement.getElementsByTagName("param"), currentElement -> {
- if (currentElement.getTagName().equals("param")) {
- switch (getNameAttributeKey(currentElement)) {
- case STRING_TO_MATCH:
- text.set(getValueAttribute(currentElement));
- break;
- case ACCEPT_ON_MATCH:
- acceptOnMatch.set(getBooleanValueAttribute(currentElement));
- break;
- }
- }
- });
- return createFilter(text.get(), acceptOnMatch.get());
- }
-
- @Override
- public Filter parse(final PropertiesConfiguration config) {
- final String text = getProperty(STRING_TO_MATCH);
- final boolean acceptOnMatch = getBooleanProperty(ACCEPT_ON_MATCH);
- return createFilter(text, acceptOnMatch);
- }
-
- private Filter createFilter(final String text, final boolean acceptOnMatch) {
- if (text == null) {
- LOGGER.error("No text provided for StringMatchFilter");
- return null;
- }
- final org.apache.logging.log4j.core.Filter.Result onMatch = acceptOnMatch
- ? org.apache.logging.log4j.core.Filter.Result.ACCEPT
- : org.apache.logging.log4j.core.Filter.Result.DENY;
- return FilterWrapper.adapt(StringMatchFilter.newBuilder()
- .setMatchString(text)
- .setOnMatch(onMatch)
- .setOnMismatch(org.apache.logging.log4j.core.Filter.Result.NEUTRAL)
- .build());
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/filter/package-info.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/filter/package-info.java
deleted file mode 100644
index 1051cdee9e8..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/filter/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-@Open("org.apache.logging.log4j.core")
-package org.apache.log4j.builders.filter;
-
-import aQute.bnd.annotation.jpms.Open;
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/layout/HtmlLayoutBuilder.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/layout/HtmlLayoutBuilder.java
deleted file mode 100644
index e389485b5d6..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/layout/HtmlLayoutBuilder.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders.layout;
-
-import static org.apache.log4j.builders.BuilderManager.NAMESPACE;
-import static org.apache.log4j.xml.XmlConfiguration.PARAM_TAG;
-import static org.apache.log4j.xml.XmlConfiguration.forEachElement;
-
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicReference;
-import org.apache.log4j.Layout;
-import org.apache.log4j.bridge.LayoutWrapper;
-import org.apache.log4j.builders.AbstractBuilder;
-import org.apache.log4j.config.PropertiesConfiguration;
-import org.apache.log4j.xml.XmlConfiguration;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.layout.HtmlLayout;
-import org.apache.logging.log4j.plugins.Namespace;
-import org.apache.logging.log4j.plugins.Plugin;
-import org.w3c.dom.Element;
-
-/**
- * Build a Pattern Layout
- */
-@Namespace(NAMESPACE)
-@Plugin("org.apache.log4j.HTMLLayout")
-public class HtmlLayoutBuilder extends AbstractBuilder implements LayoutBuilder {
-
- private static final String DEFAULT_TITLE = "Log4J Log Messages";
- private static final String TITLE_PARAM = "Title";
- private static final String LOCATION_INFO_PARAM = "LocationInfo";
-
- public HtmlLayoutBuilder() {}
-
- public HtmlLayoutBuilder(final String prefix, final Properties props) {
- super(prefix, props);
- }
-
- @Override
- public Layout parse(final Element layoutElement, final XmlConfiguration config) {
- final AtomicReference title = new AtomicReference<>("Log4J Log Messages");
- final AtomicBoolean locationInfo = new AtomicBoolean();
- forEachElement(layoutElement.getElementsByTagName("param"), currentElement -> {
- if (currentElement.getTagName().equals(PARAM_TAG)) {
- if (TITLE_PARAM.equalsIgnoreCase(currentElement.getAttribute("name"))) {
- title.set(currentElement.getAttribute("value"));
- } else if (LOCATION_INFO_PARAM.equalsIgnoreCase(currentElement.getAttribute("name"))) {
- locationInfo.set(getBooleanValueAttribute(currentElement));
- }
- }
- });
- return createLayout(config, title.get(), locationInfo.get());
- }
-
- @Override
- public Layout parse(final PropertiesConfiguration config) {
- final String title = getProperty(TITLE_PARAM, DEFAULT_TITLE);
- final boolean locationInfo = getBooleanProperty(LOCATION_INFO_PARAM);
- return createLayout(config, title, locationInfo);
- }
-
- private static Layout createLayout(
- final Configuration configuration, final String title, final boolean locationInfo) {
- return LayoutWrapper.adapt(HtmlLayout.newBuilder()
- .setConfiguration(configuration)
- .setTitle(title)
- .setLocationInfo(locationInfo)
- .build());
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/layout/LayoutBuilder.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/layout/LayoutBuilder.java
deleted file mode 100644
index 3eceb5d732f..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/layout/LayoutBuilder.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders.layout;
-
-import org.apache.log4j.Layout;
-import org.apache.log4j.builders.Parser;
-
-/**
- * Define a Layout Builder.
- */
-public interface LayoutBuilder extends Parser {
- // empty
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/layout/PatternLayoutBuilder.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/layout/PatternLayoutBuilder.java
deleted file mode 100644
index d30511e0585..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/layout/PatternLayoutBuilder.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders.layout;
-
-import static org.apache.log4j.builders.BuilderManager.NAMESPACE;
-import static org.apache.log4j.xml.XmlConfiguration.PARAM_TAG;
-
-import java.util.Properties;
-import org.apache.log4j.Layout;
-import org.apache.log4j.bridge.LayoutWrapper;
-import org.apache.log4j.builders.AbstractBuilder;
-import org.apache.log4j.config.Log4j1Configuration;
-import org.apache.log4j.config.PropertiesConfiguration;
-import org.apache.log4j.xml.XmlConfiguration;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.layout.PatternLayout;
-import org.apache.logging.log4j.plugins.Namespace;
-import org.apache.logging.log4j.plugins.Plugin;
-import org.apache.logging.log4j.plugins.PluginAliases;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * Build a Pattern Layout
- */
-@Namespace(NAMESPACE)
-@Plugin("org.apache.log4j.PatternLayout")
-@PluginAliases("org.apache.log4j.EnhancedPatternLayout")
-public class PatternLayoutBuilder extends AbstractBuilder implements LayoutBuilder {
-
- private static final Logger LOGGER = StatusLogger.getLogger();
- private static final String PATTERN = "ConversionPattern";
-
- public PatternLayoutBuilder() {}
-
- public PatternLayoutBuilder(final String prefix, final Properties props) {
- super(prefix, props);
- }
-
- @Override
- public Layout parse(final Element layoutElement, final XmlConfiguration config) {
- final NodeList params = layoutElement.getElementsByTagName("param");
- final int length = params.getLength();
- String pattern = null;
- for (int index = 0; index < length; ++index) {
- final Node currentNode = params.item(index);
- if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
- final Element currentElement = (Element) currentNode;
- if (currentElement.getTagName().equals(PARAM_TAG)) {
- if (PATTERN.equalsIgnoreCase(currentElement.getAttribute("name"))) {
- pattern = currentElement.getAttribute("value");
- break;
- }
- }
- }
- }
- return createLayout(pattern, config);
- }
-
- @Override
- public Layout parse(final PropertiesConfiguration config) {
- final String pattern = getProperty(PATTERN);
- return createLayout(pattern, config);
- }
-
- Layout createLayout(String pattern, final Log4j1Configuration config) {
- if (pattern == null) {
- LOGGER.info("No pattern provided for pattern layout, using default pattern");
- pattern = PatternLayout.DEFAULT_CONVERSION_PATTERN;
- }
- return LayoutWrapper.adapt(PatternLayout.newBuilder()
- .setPattern(pattern
- // Log4j 2 and Log4j 1 level names differ for custom levels
- .replaceAll("%([-\\.\\d]*)p(?!\\w)", "%$1v1Level")
- // Log4j 2's %x (NDC) is not compatible with Log4j 1's
- // %x
- // Log4j 1: "foo bar baz"
- // Log4j 2: "[foo, bar, baz]"
- // Use %ndc to get the Log4j 1 format
- .replaceAll("%([-\\.\\d]*)x(?!\\w)", "%$1ndc")
-
- // Log4j 2's %X (MDC) is not compatible with Log4j 1's
- // %X
- // Log4j 1: "{{foo,bar}{hoo,boo}}"
- // Log4j 2: "{foo=bar,hoo=boo}"
- // Use %properties to get the Log4j 1 format
- .replaceAll("%([-\\.\\d]*)X(?!\\w)", "%$1properties"))
- .setConfiguration(config)
- .build());
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/layout/SimpleLayoutBuilder.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/layout/SimpleLayoutBuilder.java
deleted file mode 100644
index 1c2d577f0a4..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/layout/SimpleLayoutBuilder.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders.layout;
-
-import static org.apache.log4j.builders.BuilderManager.NAMESPACE;
-
-import org.apache.log4j.Layout;
-import org.apache.log4j.bridge.LayoutWrapper;
-import org.apache.log4j.config.PropertiesConfiguration;
-import org.apache.log4j.xml.XmlConfiguration;
-import org.apache.logging.log4j.core.layout.PatternLayout;
-import org.apache.logging.log4j.plugins.Namespace;
-import org.apache.logging.log4j.plugins.Plugin;
-import org.w3c.dom.Element;
-
-/**
- * Build a Pattern Layout
- */
-@Namespace(NAMESPACE)
-@Plugin("org.apache.log4j.SimpleLayout")
-public class SimpleLayoutBuilder implements LayoutBuilder {
-
- @Override
- public Layout parse(final Element layoutElement, final XmlConfiguration config) {
- return new LayoutWrapper(PatternLayout.newBuilder()
- .setPattern("%v1Level - %m%n")
- .setConfiguration(config)
- .build());
- }
-
- @Override
- public Layout parse(final PropertiesConfiguration config) {
- return new LayoutWrapper(PatternLayout.newBuilder()
- .setPattern("%v1Level - %m%n")
- .setConfiguration(config)
- .build());
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/layout/TTCCLayoutBuilder.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/layout/TTCCLayoutBuilder.java
deleted file mode 100644
index 459d0fa62b1..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/layout/TTCCLayoutBuilder.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders.layout;
-
-import static org.apache.log4j.builders.BuilderManager.NAMESPACE;
-import static org.apache.log4j.xml.XmlConfiguration.PARAM_TAG;
-import static org.apache.log4j.xml.XmlConfiguration.forEachElement;
-
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicReference;
-import org.apache.log4j.Layout;
-import org.apache.log4j.bridge.LayoutWrapper;
-import org.apache.log4j.builders.AbstractBuilder;
-import org.apache.log4j.config.Log4j1Configuration;
-import org.apache.log4j.config.PropertiesConfiguration;
-import org.apache.log4j.xml.XmlConfiguration;
-import org.apache.logging.log4j.core.layout.PatternLayout;
-import org.apache.logging.log4j.plugins.Namespace;
-import org.apache.logging.log4j.plugins.Plugin;
-import org.w3c.dom.Element;
-
-/**
- * Build a Pattern Layout
- */
-@Namespace(NAMESPACE)
-@Plugin("org.apache.log4j.TTCCLayout")
-public class TTCCLayoutBuilder extends AbstractBuilder implements LayoutBuilder {
-
- private static final String THREAD_PRINTING_PARAM = "ThreadPrinting";
- private static final String CATEGORY_PREFIXING_PARAM = "CategoryPrefixing";
- private static final String CONTEXT_PRINTING_PARAM = "ContextPrinting";
- private static final String DATE_FORMAT_PARAM = "DateFormat";
- private static final String TIMEZONE_FORMAT = "TimeZone";
-
- public TTCCLayoutBuilder() {}
-
- public TTCCLayoutBuilder(final String prefix, final Properties props) {
- super(prefix, props);
- }
-
- @Override
- public Layout parse(final Element layoutElement, final XmlConfiguration config) {
- final AtomicBoolean threadPrinting = new AtomicBoolean(Boolean.TRUE);
- final AtomicBoolean categoryPrefixing = new AtomicBoolean(Boolean.TRUE);
- final AtomicBoolean contextPrinting = new AtomicBoolean(Boolean.TRUE);
- final AtomicReference dateFormat = new AtomicReference<>(RELATIVE);
- final AtomicReference timezone = new AtomicReference<>();
- forEachElement(layoutElement.getElementsByTagName("param"), currentElement -> {
- if (currentElement.getTagName().equals(PARAM_TAG)) {
- switch (getNameAttributeKey(currentElement)) {
- case THREAD_PRINTING_PARAM:
- threadPrinting.set(getBooleanValueAttribute(currentElement));
- break;
- case CATEGORY_PREFIXING_PARAM:
- categoryPrefixing.set(getBooleanValueAttribute(currentElement));
- break;
- case CONTEXT_PRINTING_PARAM:
- contextPrinting.set(getBooleanValueAttribute(currentElement));
- break;
- case DATE_FORMAT_PARAM:
- dateFormat.set(getValueAttribute(currentElement));
- break;
- case TIMEZONE_FORMAT:
- timezone.set(getValueAttribute(currentElement));
- break;
- }
- }
- });
- return createLayout(
- threadPrinting.get(),
- categoryPrefixing.get(),
- contextPrinting.get(),
- dateFormat.get(),
- timezone.get(),
- config);
- }
-
- @Override
- public Layout parse(final PropertiesConfiguration config) {
- final boolean threadPrinting = getBooleanProperty(THREAD_PRINTING_PARAM, true);
- final boolean categoryPrefixing = getBooleanProperty(CATEGORY_PREFIXING_PARAM, true);
- final boolean contextPrinting = getBooleanProperty(CONTEXT_PRINTING_PARAM, true);
- final String dateFormat = getProperty(DATE_FORMAT_PARAM, RELATIVE);
- final String timezone = getProperty(TIMEZONE_FORMAT);
-
- return createLayout(threadPrinting, categoryPrefixing, contextPrinting, dateFormat, timezone, config);
- }
-
- private Layout createLayout(
- final boolean threadPrinting,
- final boolean categoryPrefixing,
- final boolean contextPrinting,
- final String dateFormat,
- final String timezone,
- final Log4j1Configuration config) {
- final StringBuilder sb = new StringBuilder();
- if (dateFormat != null) {
- if (RELATIVE.equalsIgnoreCase(dateFormat)) {
- sb.append("%r ");
- } else if (!NULL.equalsIgnoreCase(dateFormat)) {
- sb.append("%d{").append(dateFormat).append("}");
- if (timezone != null) {
- sb.append("{").append(timezone).append("}");
- }
- sb.append(" ");
- }
- }
- if (threadPrinting) {
- sb.append("[%t] ");
- }
- sb.append("%p ");
- if (categoryPrefixing) {
- sb.append("%c ");
- }
- if (contextPrinting) {
- sb.append("%notEmpty{%ndc }");
- }
- sb.append("- %m%n");
- return LayoutWrapper.adapt(PatternLayout.newBuilder()
- .setPattern(sb.toString())
- .setConfiguration(config)
- .build());
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/layout/XmlLayoutBuilder.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/layout/XmlLayoutBuilder.java
deleted file mode 100644
index 37b8da819bb..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/layout/XmlLayoutBuilder.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders.layout;
-
-import static org.apache.log4j.builders.BuilderManager.NAMESPACE;
-import static org.apache.log4j.xml.XmlConfiguration.PARAM_TAG;
-import static org.apache.log4j.xml.XmlConfiguration.forEachElement;
-
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicBoolean;
-import org.apache.log4j.Layout;
-import org.apache.log4j.bridge.LayoutWrapper;
-import org.apache.log4j.builders.AbstractBuilder;
-import org.apache.log4j.config.PropertiesConfiguration;
-import org.apache.log4j.layout.Log4j1XmlLayout;
-import org.apache.log4j.xml.XmlConfiguration;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.plugins.Namespace;
-import org.apache.logging.log4j.plugins.Plugin;
-import org.w3c.dom.Element;
-
-/**
- * Build an XML Layout
- */
-@Namespace(NAMESPACE)
-@Plugin("org.apache.log4j.xml.XMLLayout")
-public class XmlLayoutBuilder extends AbstractBuilder implements LayoutBuilder {
-
- private static final String LOCATION_INFO = "LocationInfo";
- private static final String PROPERTIES = "Properties";
-
- public XmlLayoutBuilder() {}
-
- public XmlLayoutBuilder(final String prefix, final Properties props) {
- super(prefix, props);
- }
-
- @Override
- public Layout parse(final Element layoutElement, final XmlConfiguration config) {
- final AtomicBoolean properties = new AtomicBoolean();
- final AtomicBoolean locationInfo = new AtomicBoolean();
- forEachElement(layoutElement.getElementsByTagName(PARAM_TAG), currentElement -> {
- if (PROPERTIES.equalsIgnoreCase(currentElement.getAttribute("name"))) {
- properties.set(getBooleanValueAttribute(currentElement));
- } else if (LOCATION_INFO.equalsIgnoreCase(currentElement.getAttribute("name"))) {
- locationInfo.set(getBooleanValueAttribute(currentElement));
- }
- });
- return createLayout(config, properties.get(), locationInfo.get());
- }
-
- @Override
- public Layout parse(final PropertiesConfiguration config) {
- final boolean properties = getBooleanProperty(PROPERTIES);
- final boolean locationInfo = getBooleanProperty(LOCATION_INFO);
- return createLayout(config, properties, locationInfo);
- }
-
- private Layout createLayout(final Configuration config, final boolean properties, final boolean locationInfo) {
- return LayoutWrapper.adapt(Log4j1XmlLayout.createLayout(config, locationInfo, properties));
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/layout/package-info.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/layout/package-info.java
deleted file mode 100644
index d87f91dc2e1..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/layout/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-@Open("org.apache.logging.log4j.core")
-package org.apache.log4j.builders.layout;
-
-import aQute.bnd.annotation.jpms.Open;
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/package-info.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/package-info.java
deleted file mode 100644
index 8ee863c334c..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-@Export
-@Version("2.20.1")
-package org.apache.log4j.builders;
-
-import org.osgi.annotation.bundle.Export;
-import org.osgi.annotation.versioning.Version;
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/rewrite/RewritePolicyBuilder.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/rewrite/RewritePolicyBuilder.java
deleted file mode 100644
index b88581f2e26..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/rewrite/RewritePolicyBuilder.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders.rewrite;
-
-import org.apache.log4j.builders.Parser;
-import org.apache.log4j.rewrite.RewritePolicy;
-
-/**
- * Define a RewritePolicy Builder.
- */
-public interface RewritePolicyBuilder extends Parser {
- // empty
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/rewrite/package-info.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/rewrite/package-info.java
deleted file mode 100644
index f8eb75121fe..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/rewrite/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-@Open("org.apache.logging.log4j.core")
-package org.apache.log4j.builders.rewrite;
-
-import aQute.bnd.annotation.jpms.Open;
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/rolling/CompositeTriggeringPolicyBuilder.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/rolling/CompositeTriggeringPolicyBuilder.java
deleted file mode 100644
index 1eeab59d405..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/rolling/CompositeTriggeringPolicyBuilder.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders.rolling;
-
-import static org.apache.log4j.builders.BuilderManager.NAMESPACE;
-import static org.apache.log4j.xml.XmlConfiguration.forEachElement;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Properties;
-import org.apache.log4j.builders.AbstractBuilder;
-import org.apache.log4j.config.PropertiesConfiguration;
-import org.apache.log4j.xml.XmlConfiguration;
-import org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy;
-import org.apache.logging.log4j.core.appender.rolling.TriggeringPolicy;
-import org.apache.logging.log4j.plugins.Namespace;
-import org.apache.logging.log4j.plugins.Plugin;
-import org.w3c.dom.Element;
-
-@Plugin("org.apache.log4j.rolling.CompositeTriggeringPolicy")
-@Namespace(NAMESPACE)
-public class CompositeTriggeringPolicyBuilder extends AbstractBuilder
- implements TriggeringPolicyBuilder {
-
- private static final TriggeringPolicy[] EMPTY_TRIGGERING_POLICIES = new TriggeringPolicy[0];
- private static final String POLICY_TAG = "triggeringPolicy";
-
- public CompositeTriggeringPolicyBuilder() {
- super();
- }
-
- public CompositeTriggeringPolicyBuilder(final String prefix, final Properties props) {
- super(prefix, props);
- }
-
- @Override
- public CompositeTriggeringPolicy parse(final Element element, final XmlConfiguration configuration) {
- final List policies = new ArrayList<>();
- forEachElement(element.getChildNodes(), currentElement -> {
- switch (currentElement.getTagName()) {
- case POLICY_TAG:
- final TriggeringPolicy policy = configuration.parseTriggeringPolicy(currentElement);
- if (policy != null) {
- policies.add(policy);
- }
- break;
- }
- });
- return createTriggeringPolicy(policies);
- }
-
- @Override
- public CompositeTriggeringPolicy parse(final PropertiesConfiguration configuration) {
- return createTriggeringPolicy(Collections.emptyList());
- }
-
- private CompositeTriggeringPolicy createTriggeringPolicy(final List policies) {
- return CompositeTriggeringPolicy.createPolicy(policies.toArray(EMPTY_TRIGGERING_POLICIES));
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/rolling/SizeBasedTriggeringPolicyBuilder.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/rolling/SizeBasedTriggeringPolicyBuilder.java
deleted file mode 100644
index fc531d5c9a5..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/rolling/SizeBasedTriggeringPolicyBuilder.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders.rolling;
-
-import static org.apache.log4j.builders.BuilderManager.NAMESPACE;
-import static org.apache.log4j.xml.XmlConfiguration.PARAM_TAG;
-import static org.apache.log4j.xml.XmlConfiguration.forEachElement;
-
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicLong;
-import org.apache.log4j.builders.AbstractBuilder;
-import org.apache.log4j.config.PropertiesConfiguration;
-import org.apache.log4j.xml.XmlConfiguration;
-import org.apache.logging.log4j.core.appender.rolling.SizeBasedTriggeringPolicy;
-import org.apache.logging.log4j.core.appender.rolling.TriggeringPolicy;
-import org.apache.logging.log4j.plugins.Namespace;
-import org.apache.logging.log4j.plugins.Plugin;
-import org.w3c.dom.Element;
-
-@Plugin("org.apache.log4j.rolling.SizeBasedTriggeringPolicy")
-@Namespace(NAMESPACE)
-public class SizeBasedTriggeringPolicyBuilder extends AbstractBuilder
- implements TriggeringPolicyBuilder {
-
- private static final String MAX_SIZE_PARAM = "MaxFileSize";
- private static final long DEFAULT_MAX_SIZE = 10 * 1024 * 1024;
-
- public SizeBasedTriggeringPolicyBuilder() {
- super();
- }
-
- public SizeBasedTriggeringPolicyBuilder(final String prefix, final Properties props) {
- super(prefix, props);
- }
-
- @Override
- public SizeBasedTriggeringPolicy parse(final Element element, final XmlConfiguration configuration) {
- final AtomicLong maxSize = new AtomicLong(DEFAULT_MAX_SIZE);
- forEachElement(element.getChildNodes(), currentElement -> {
- switch (currentElement.getTagName()) {
- case PARAM_TAG:
- switch (getNameAttributeKey(currentElement)) {
- case MAX_SIZE_PARAM:
- set(MAX_SIZE_PARAM, currentElement, maxSize);
- break;
- }
- break;
- }
- });
- return createTriggeringPolicy(maxSize.get());
- }
-
- @Override
- public SizeBasedTriggeringPolicy parse(final PropertiesConfiguration configuration) {
- final long maxSize = getLongProperty(MAX_SIZE_PARAM, DEFAULT_MAX_SIZE);
- return createTriggeringPolicy(maxSize);
- }
-
- private SizeBasedTriggeringPolicy createTriggeringPolicy(final long maxSize) {
- return SizeBasedTriggeringPolicy.createPolicy(Long.toString(maxSize));
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/rolling/TimeBasedRollingPolicyBuilder.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/rolling/TimeBasedRollingPolicyBuilder.java
deleted file mode 100644
index c53e9ace482..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/rolling/TimeBasedRollingPolicyBuilder.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders.rolling;
-
-import static org.apache.log4j.builders.BuilderManager.NAMESPACE;
-
-import java.util.Properties;
-import org.apache.log4j.builders.AbstractBuilder;
-import org.apache.log4j.config.PropertiesConfiguration;
-import org.apache.log4j.xml.XmlConfiguration;
-import org.apache.logging.log4j.core.appender.rolling.TimeBasedTriggeringPolicy;
-import org.apache.logging.log4j.core.appender.rolling.TriggeringPolicy;
-import org.apache.logging.log4j.plugins.Namespace;
-import org.apache.logging.log4j.plugins.Plugin;
-import org.w3c.dom.Element;
-
-@Plugin("org.apache.log4j.rolling.TimeBasedRollingPolicy")
-@Namespace(NAMESPACE)
-public class TimeBasedRollingPolicyBuilder extends AbstractBuilder
- implements TriggeringPolicyBuilder {
-
- public TimeBasedRollingPolicyBuilder(final String prefix, final Properties props) {
- super(prefix, props);
- }
-
- public TimeBasedRollingPolicyBuilder() {
- super();
- }
-
- @Override
- public TimeBasedTriggeringPolicy parse(final Element element, final XmlConfiguration configuration) {
- return createTriggeringPolicy();
- }
-
- @Override
- public TimeBasedTriggeringPolicy parse(final PropertiesConfiguration configuration) {
- return createTriggeringPolicy();
- }
-
- private TimeBasedTriggeringPolicy createTriggeringPolicy() {
- return TimeBasedTriggeringPolicy.newBuilder().build();
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/rolling/TriggeringPolicyBuilder.java b/log4j-1.2-api/src/main/java/org/apache/log4j/builders/rolling/TriggeringPolicyBuilder.java
deleted file mode 100644
index 931ad08b405..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/builders/rolling/TriggeringPolicyBuilder.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders.rolling;
-
-import org.apache.log4j.builders.Parser;
-import org.apache.logging.log4j.core.appender.rolling.TriggeringPolicy;
-
-public interface TriggeringPolicyBuilder extends Parser {
- // NOP
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/component/helpers/Constants.java b/log4j-1.2-api/src/main/java/org/apache/log4j/component/helpers/Constants.java
deleted file mode 100644
index 8e0f0a8934a..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/component/helpers/Constants.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.component.helpers;
-
-/**
- * Constants used internally throughout log4j.
- *
- */
-public interface Constants {
-
- /**
- * log4j package name string literal.
- */
- String LOG4J_PACKAGE_NAME = "org.apache.log4j";
-
- /**
- * The name of the default repository is "default" (without the quotes).
- */
- String DEFAULT_REPOSITORY_NAME = "default";
-
- /**
- * application string literal.
- */
- String APPLICATION_KEY = "application";
- /**
- * hostname string literal.
- */
- String HOSTNAME_KEY = "hostname";
- /**
- * receiver string literal.
- */
- String RECEIVER_NAME_KEY = "receiver";
- /**
- * log4jid string literal.
- */
- String LOG4J_ID_KEY = "log4jid";
- /**
- * time stamp pattern string literal.
- */
- String TIMESTAMP_RULE_FORMAT = "yyyy/MM/dd HH:mm:ss";
-
- /**
- * The default property file name for automatic configuration.
- */
- String DEFAULT_CONFIGURATION_FILE = "log4j.properties";
- /**
- * The default XML configuration file name for automatic configuration.
- */
- String DEFAULT_XML_CONFIGURATION_FILE = "log4j.xml";
- /**
- * log4j.configuration string literal.
- */
- String DEFAULT_CONFIGURATION_KEY = "log4j.configuration";
- /**
- * log4j.configuratorClass string literal.
- */
- String CONFIGURATOR_CLASS_KEY = "log4j.configuratorClass";
-
- /**
- * JNDI context name string literal.
- */
- String JNDI_CONTEXT_NAME = "java:comp/env/log4j/context-name";
-
- /**
- * TEMP_LIST_APPENDER string literal.
- */
- String TEMP_LIST_APPENDER_NAME = "TEMP_LIST_APPENDER";
- /**
- * TEMP_CONSOLE_APPENDER string literal.
- */
- String TEMP_CONSOLE_APPENDER_NAME = "TEMP_CONSOLE_APPENDER";
- /**
- * Codes URL string literal.
- */
- String CODES_HREF = "http://logging.apache.org/log4j/docs/codes.html";
-
- /**
- * ABSOLUTE string literal.
- */
- String ABSOLUTE_FORMAT = "ABSOLUTE";
- /**
- * SimpleTimePattern for ABSOLUTE.
- */
- String ABSOLUTE_TIME_PATTERN = "HH:mm:ss,SSS";
-
- /**
- * SimpleTimePattern for ABSOLUTE.
- */
- String SIMPLE_TIME_PATTERN = "HH:mm:ss";
-
- /**
- * DATE string literal.
- */
- String DATE_AND_TIME_FORMAT = "DATE";
- /**
- * SimpleTimePattern for DATE.
- */
- String DATE_AND_TIME_PATTERN = "dd MMM yyyy HH:mm:ss,SSS";
-
- /**
- * ISO8601 string literal.
- */
- String ISO8601_FORMAT = "ISO8601";
- /**
- * SimpleTimePattern for ISO8601.
- */
- String ISO8601_PATTERN = "yyyy-MM-dd HH:mm:ss,SSS";
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1Configuration.java b/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1Configuration.java
deleted file mode 100644
index a581f35a77e..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/config/Log4j1Configuration.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.config;
-
-import java.util.Optional;
-import org.apache.log4j.Level;
-import org.apache.log4j.builders.BuilderManager;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.AbstractConfiguration;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.ConfigurationSource;
-import org.apache.logging.log4j.core.config.Reconfigurable;
-import org.apache.logging.log4j.kit.env.PropertyEnvironment;
-import org.apache.logging.log4j.plugins.di.ConfigurableInstanceFactory;
-import org.apache.logging.log4j.plugins.di.DI;
-
-/**
- * Base Configuration for Log4j 1.
- */
-public class Log4j1Configuration extends AbstractConfiguration implements Reconfigurable {
-
- public static final String APPENDER_REF_TAG = "appender-ref";
- public static final String THRESHOLD_PARAM = "Threshold";
-
- public static final String INHERITED = "inherited";
-
- public static final String NULL = "null";
-
- /**
- * The effective level used, when the configuration uses a non-existent custom
- * level.
- */
- public static final Level DEFAULT_LEVEL = Level.DEBUG;
-
- protected final BuilderManager manager;
-
- public Log4j1Configuration(
- final LoggerContext loggerContext,
- final ConfigurationSource configurationSource,
- final int monitorIntervalSeconds) {
- super(
- loggerContext,
- configurationSource,
- Optional.ofNullable(loggerContext)
- .map(LoggerContext::getEnvironment)
- .orElseGet(PropertyEnvironment::getGlobal),
- Optional.ofNullable(loggerContext)
- .map(ctx -> (ConfigurableInstanceFactory) ctx.getInstanceFactory())
- .orElseGet(DI::createInitializedFactory));
- initializeWatchers(this, configurationSource, monitorIntervalSeconds);
- manager = instanceFactory.getInstance(BuilderManager.class);
- }
-
- public BuilderManager getBuilderManager() {
- return manager;
- }
-
- /**
- * Initialize the configuration.
- */
- @Override
- public void initialize() {
- instanceFactory.registerBinding(Configuration.KEY, () -> this);
- getStrSubstitutor().setConfiguration(this);
- getConfigurationStrSubstitutor().setConfiguration(this);
- super.getScheduler().start();
- doConfigure();
- setState(State.INITIALIZED);
- LOGGER.debug("Configuration {} initialized", this);
- }
-
- @Override
- public Configuration reconfigure() {
- return null;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/config/PropertiesConfiguration.java b/log4j-1.2-api/src/main/java/org/apache/log4j/config/PropertiesConfiguration.java
deleted file mode 100644
index 3bc29f95870..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/config/PropertiesConfiguration.java
+++ /dev/null
@@ -1,652 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.config;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Properties;
-import java.util.SortedMap;
-import java.util.StringTokenizer;
-import java.util.TreeMap;
-import org.apache.log4j.Appender;
-import org.apache.log4j.Layout;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.PatternLayout;
-import org.apache.log4j.bridge.AppenderAdapter;
-import org.apache.log4j.bridge.FilterAdapter;
-import org.apache.log4j.builders.BuilderManager;
-import org.apache.log4j.helpers.OptionConverter;
-import org.apache.log4j.spi.ErrorHandler;
-import org.apache.log4j.spi.Filter;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.Filter.Result;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.appender.rolling.TriggeringPolicy;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.ConfigurationSource;
-import org.apache.logging.log4j.core.config.LoggerConfig;
-import org.apache.logging.log4j.core.config.status.StatusConfiguration;
-import org.apache.logging.log4j.core.filter.ThresholdFilter;
-import org.apache.logging.log4j.util.LoaderUtil;
-
-/**
- * Constructs a configuration based on Log4j 1 properties.
- */
-public class PropertiesConfiguration extends Log4j1Configuration {
-
- private static final String CATEGORY_PREFIX = "log4j.category.";
- private static final String LOGGER_PREFIX = "log4j.logger.";
- private static final String ADDITIVITY_PREFIX = "log4j.additivity.";
- private static final String ROOT_CATEGORY_PREFIX = "log4j.rootCategory";
- private static final String ROOT_LOGGER_PREFIX = "log4j.rootLogger";
- private static final String APPENDER_PREFIX = "log4j.appender.";
- private static final String LOGGER_REF = "logger-ref";
- private static final String ROOT_REF = "root-ref";
- private static final String APPENDER_REF_TAG = "appender-ref";
-
- /**
- * If property set to true, then hierarchy will be reset before configuration.
- */
- private static final String RESET_KEY = "log4j.reset";
-
- public static final String THRESHOLD_KEY = "log4j.threshold";
- public static final String DEBUG_KEY = "log4j.debug";
-
- private static final String INTERNAL_ROOT_NAME = "root";
-
- private final Map registry = new HashMap<>();
- private Properties properties;
-
- /**
- * Constructs a new instance.
- *
- * @param loggerContext The LoggerContext.
- * @param configurationSource The ConfigurationSource.
- * @param monitorIntervalSeconds The monitoring interval in seconds.
- */
- public PropertiesConfiguration(
- final LoggerContext loggerContext,
- final ConfigurationSource configurationSource,
- final int monitorIntervalSeconds) {
- this(loggerContext, configurationSource, monitorIntervalSeconds, null);
- }
-
- /**
- * Constructs a new instance.
- *
- * @param loggerContext The LoggerContext.
- * @param properties The ConfigurationSource, may be null.
- */
- public PropertiesConfiguration(final LoggerContext loggerContext, final Properties properties) {
- this(loggerContext, ConfigurationSource.NULL_SOURCE, 0, properties);
- }
-
- private PropertiesConfiguration(
- final LoggerContext loggerContext,
- final ConfigurationSource configurationSource,
- final int monitorIntervalSeconds,
- final Properties properties) {
- super(loggerContext, configurationSource, monitorIntervalSeconds);
- this.properties = properties;
- }
-
- @Override
- public void doConfigure() {
- if (properties == null) {
- properties = new Properties();
- final InputStream inputStream = getConfigurationSource().getInputStream();
- if (inputStream != null) {
- try {
- properties.load(inputStream);
- } catch (final Exception e) {
- LOGGER.error(
- "Could not read configuration file [{}].",
- getConfigurationSource().toString(),
- e);
- return;
- }
- }
- }
- // If we reach here, then the config file is alright.
- doConfigure(properties);
- }
-
- @Override
- public Configuration reconfigure() {
- try {
- final ConfigurationSource source = getConfigurationSource().resetInputStream();
- if (source == null) {
- return null;
- }
- final Configuration config =
- new PropertiesConfigurationFactory().getConfiguration(getLoggerContext(), source);
- return config == null || config.getState() != State.INITIALIZING ? null : config;
- } catch (final IOException ex) {
- LOGGER.error("Cannot locate file {}: {}", getConfigurationSource(), ex);
- }
- return null;
- }
-
- /**
- * Reads a configuration from a file. The existing configuration is not cleared nor reset. If you require a
- * different behavior, then call {@link LogManager#resetConfiguration()} resetConfiguration} method before calling
- * doConfigure
.
- *
- * The configuration file consists of statements in the format key=value
. The syntax of different
- * configuration elements are discussed below.
- *
- *
- * The level value can consist of the string values OFF, FATAL, ERROR, WARN, INFO, DEBUG, ALL or a custom level
- * value. A custom level value can be specified in the form level#classname. By default the repository-wide threshold is
- * set to the lowest possible value, namely the level ALL
.
- *
- *
- * Appender configuration
- *
- * Appender configuration syntax is:
- *
- *
- * # For appender named appenderName , set its class.
- * # Note: The appender name can contain dots.
- * log4j.appender.appenderName=fully.qualified.name.of.appender.class
- *
- * # Set appender specific options.
- * log4j.appender.appenderName.option1=value1
- * ...
- * log4j.appender.appenderName.optionN=valueN
- *
- *
- * For each named appender you can configure its {@link Layout}. The syntax for configuring an appender's layout is:
- *
- *
- * log4j.appender.appenderName.layout=fully.qualified.name.of.layout.class
- * log4j.appender.appenderName.layout.option1=value1
- * ....
- * log4j.appender.appenderName.layout.optionN=valueN
- *
- *
- * The syntax for adding {@link Filter}s to an appender is:
- *
- *
- * log4j.appender.appenderName.filter.ID=fully.qualified.name.of.filter.class
- * log4j.appender.appenderName.filter.ID.option1=value1
- * ...
- * log4j.appender.appenderName.filter.ID.optionN=valueN
- *
- *
- * The first line defines the class name of the filter identified by ID; subsequent lines with the same ID specify
- * filter option - value pairs. Multiple filters are added to the appender in the lexicographic order of IDs.
- *
- *
- * The syntax for adding an {@link ErrorHandler} to an appender is:
- *
- *
- * log4j.appender.appenderName.errorhandler=fully.qualified.name.of.errorhandler.class
- * log4j.appender.appenderName.errorhandler.appender-ref=appenderName
- * log4j.appender.appenderName.errorhandler.option1=value1
- * ...
- * log4j.appender.appenderName.errorhandler.optionN=valueN
- *
- *
- * Configuring loggers
- *
- * The syntax for configuring the root logger is:
- *
- *
- * log4j.rootLogger=[level], appenderName, appenderName, ...
- *
- *
- * This syntax means that an optional level can be supplied followed by appender names separated by commas.
- *
- *
- * The level value can consist of the string values OFF, FATAL, ERROR, WARN, INFO, DEBUG, ALL or a custom level
- * value. A custom level value can be specified in the form level#classname
.
- *
- *
- * If a level value is specified, then the root level is set to the corresponding level. If no level value is specified,
- * then the root level remains untouched.
- *
- *
- * The root logger can be assigned multiple appenders.
- *
- *
- * Each appenderName (separated by commas) will be added to the root logger. The named appender is defined using
- * the appender syntax defined above.
- *
- *
- * For non-root categories the syntax is almost the same:
- *
- *
- * log4j.logger.logger_name=[level|INHERITED|NULL], appenderName, appenderName, ...
- *
- *
- * The meaning of the optional level value is discussed above in relation to the root logger. In addition however, the
- * value INHERITED can be specified meaning that the named logger should inherit its level from the logger hierarchy.
- *
- *
- * If no level value is supplied, then the level of the named logger remains untouched.
- *
- *
- * By default categories inherit their level from the hierarchy. However, if you set the level of a logger and later
- * decide that that logger should inherit its level, then you should specify INHERITED as the value for the level value.
- * NULL is a synonym for INHERITED.
- *
- *
- * Similar to the root logger syntax, each appenderName (separated by commas) will be attached to the named
- * logger.
- *
- *
- * See the appender additivity rule in the user manual for the meaning
- * of the additivity
flag.
- *
- *
- * # Set options for appender named "A1". # Appender "A1" will be a SyslogAppender
- * log4j.appender.A1=org.apache.log4j.net.SyslogAppender
- *
- * # The syslog daemon resides on www.abc.net log4j.appender.A1.SyslogHost=www.abc.net
- *
- * # A1's layout is a PatternLayout, using the conversion pattern # %r %-5p %c{2} %M.%L %x - %m\n . Thus, the log
- * output will # include # the relative time since the start of the application in # milliseconds, followed by the level
- * of the log request, # followed by the two rightmost components of the logger name, # followed by the callers method
- * name, followed by the line number, # the nested diagnostic context and finally the message itself. # Refer to the
- * documentation of {@link PatternLayout} for further information # on the syntax of the ConversionPattern key.
- * log4j.appender.A1.layout=org.apache.log4j.PatternLayout log4j.appender.A1.layout.ConversionPattern=%-4r %-5p %c{2}
- * %M.%L %x - %m\n
- *
- * # Set options for appender named "A2" # A2 should be a RollingFileAppender, with maximum file size of 10 MB # using
- * at most one backup file. A2's layout is TTCC, using the # ISO8061 date format with context printing enabled.
- * log4j.appender.A2=org.apache.log4j.RollingFileAppender log4j.appender.A2.MaxFileSize=10MB
- * log4j.appender.A2.MaxBackupIndex=1 log4j.appender.A2.layout=org.apache.log4j.TTCCLayout
- * log4j.appender.A2.layout.ContextPrinting=enabled log4j.appender.A2.layout.DateFormat=ISO8601
- *
- * # Root logger set to DEBUG using the A2 appender defined above. log4j.rootLogger=DEBUG, A2
- *
- * # Logger definitions: # The SECURITY logger inherits is level from root. However, it's output # will go to A1
- * appender defined above. It's additivity is non-cumulative. log4j.logger.SECURITY=INHERIT, A1
- * log4j.additivity.SECURITY=false
- *
- * # Only warnings or above will be logged for the logger "SECURITY.access". # Output will go to A1.
- * log4j.logger.SECURITY.access=WARN
- *
- *
- * # The logger "class.of.the.day" inherits its level from the # logger hierarchy. Output will go to the appender's of
- * the root # logger, A2 in this case. log4j.logger.class.of.the.day=INHERIT
- *
- *
- * Refer to the setOption method in each Appender and Layout for class specific options.
- *
- *
- * Use the #
or !
characters at the beginning of a line for comments.
- *
- */
- private void doConfigure(final Properties properties) {
- String status = "error";
- String value = properties.getProperty(DEBUG_KEY);
- if (value == null) {
- value = properties.getProperty("log4j.configDebug");
- if (value != null) {
- LOGGER.warn("[log4j.configDebug] is deprecated. Use [log4j.debug] instead.");
- }
- }
-
- if (value != null) {
- status = OptionConverter.toBoolean(value, false) ? "debug" : "error";
- }
-
- final StatusConfiguration statusConfig = new StatusConfiguration().setStatus(status);
- statusConfig.initialize();
-
- // if log4j.reset=true then reset hierarchy
- final String reset = properties.getProperty(RESET_KEY);
- if (reset != null && OptionConverter.toBoolean(reset, false)) {
- LogManager.resetConfiguration();
- }
-
- final String threshold = OptionConverter.findAndSubst(THRESHOLD_KEY, properties);
- if (threshold != null) {
- final Level level = OptionConverter.convertLevel(threshold.trim(), Level.ALL);
- addFilter(ThresholdFilter.createFilter(level, Result.NEUTRAL, Result.DENY));
- }
-
- configureRoot(properties);
- parseLoggers(properties);
-
- LOGGER.debug("Finished configuring.");
- }
-
- // --------------------------------------------------------------------------
- // Internal stuff
- // --------------------------------------------------------------------------
-
- private void configureRoot(final Properties props) {
- String effectiveFrefix = ROOT_LOGGER_PREFIX;
- String value = OptionConverter.findAndSubst(ROOT_LOGGER_PREFIX, props);
-
- if (value == null) {
- value = OptionConverter.findAndSubst(ROOT_CATEGORY_PREFIX, props);
- effectiveFrefix = ROOT_CATEGORY_PREFIX;
- }
-
- if (value == null) {
- LOGGER.debug("Could not find root logger information. Is this OK?");
- } else {
- final LoggerConfig root = getRootLogger();
- parseLogger(props, root, effectiveFrefix, INTERNAL_ROOT_NAME, value);
- }
- }
-
- /**
- * Parses non-root elements, such non-root categories and renderers.
- */
- private void parseLoggers(final Properties props) {
- final Enumeration> enumeration = props.propertyNames();
- while (enumeration.hasMoreElements()) {
- final String key = Objects.toString(enumeration.nextElement(), null);
- if (key.startsWith(CATEGORY_PREFIX) || key.startsWith(LOGGER_PREFIX)) {
- String loggerName = null;
- if (key.startsWith(CATEGORY_PREFIX)) {
- loggerName = key.substring(CATEGORY_PREFIX.length());
- } else if (key.startsWith(LOGGER_PREFIX)) {
- loggerName = key.substring(LOGGER_PREFIX.length());
- }
- final String value = OptionConverter.findAndSubst(key, props);
- LoggerConfig loggerConfig = getLogger(loggerName);
- if (loggerConfig == null) {
- final boolean additivity = getAdditivityForLogger(props, loggerName);
- loggerConfig = new LoggerConfig(loggerName, Level.ERROR, additivity, this);
- addLogger(loggerName, loggerConfig);
- }
- parseLogger(props, loggerConfig, key, loggerName, value);
- }
- }
- }
-
- /**
- * Parses the additivity option for a non-root category.
- */
- private boolean getAdditivityForLogger(final Properties props, final String loggerName) {
- boolean additivity = true;
- final String key = ADDITIVITY_PREFIX + loggerName;
- final String value = OptionConverter.findAndSubst(key, props);
- LOGGER.debug("Handling {}=[{}]", key, value);
- // touch additivity only if necessary
- if (value != null && !value.isEmpty()) {
- additivity = OptionConverter.toBoolean(value, true);
- }
- return additivity;
- }
-
- /**
- * This method must work for the root category as well.
- */
- private void parseLogger(
- final Properties props,
- final LoggerConfig loggerConfig,
- final String optionKey,
- final String loggerName,
- final String value) {
-
- LOGGER.debug("Parsing for [{}] with value=[{}].", loggerName, value);
- // We must skip over ',' but not white space
- final StringTokenizer st = new StringTokenizer(value, ",");
-
- // If value is not in the form ", appender.." or "", then we should set the level of the logger.
-
- if (!(value.startsWith(",") || value.isEmpty())) {
-
- // just to be on the safe side...
- if (!st.hasMoreTokens()) {
- return;
- }
-
- final String levelStr = st.nextToken();
- LOGGER.debug("Level token is [{}].", levelStr);
-
- final org.apache.logging.log4j.Level level = levelStr == null
- ? org.apache.logging.log4j.Level.ERROR
- : OptionConverter.convertLevel(levelStr, org.apache.logging.log4j.Level.DEBUG);
- loggerConfig.setLevel(level);
- LOGGER.debug("Logger {} level set to {}", loggerName, level);
- }
-
- Appender appender;
- String appenderName;
- while (st.hasMoreTokens()) {
- appenderName = st.nextToken().trim();
- if (appenderName == null || appenderName.equals(",")) {
- continue;
- }
- LOGGER.debug("Parsing appender named \"{}\".", appenderName);
- appender = parseAppender(props, appenderName);
- if (appender != null) {
- LOGGER.debug("Adding appender named [{}] to loggerConfig [{}].", appenderName, loggerConfig.getName());
- loggerConfig.addAppender(getAppender(appenderName), null, null);
- } else {
- LOGGER.debug("Appender named [{}] not found.", appenderName);
- }
- }
- }
-
- public Appender parseAppender(final Properties props, final String appenderName) {
- Appender appender = registry.get(appenderName);
- if ((appender != null)) {
- LOGGER.debug("Appender \"" + appenderName + "\" was already parsed.");
- return appender;
- }
- // Appender was not previously initialized.
- final String prefix = APPENDER_PREFIX + appenderName;
- final String layoutPrefix = prefix + ".layout";
- final String filterPrefix = APPENDER_PREFIX + appenderName + ".filter.";
- final String className = OptionConverter.findAndSubst(prefix, props);
- if (className == null) {
- LOGGER.debug("Appender \"" + appenderName + "\" does not exist.");
- return null;
- }
- appender = manager.parseAppender(appenderName, className, prefix, layoutPrefix, filterPrefix, props, this);
- if (appender == null) {
- appender = buildAppender(appenderName, className, prefix, layoutPrefix, filterPrefix, props);
- } else {
- registry.put(appenderName, appender);
- addAppender(AppenderAdapter.adapt(appender));
- }
- return appender;
- }
-
- private Appender buildAppender(
- final String appenderName,
- final String className,
- final String prefix,
- final String layoutPrefix,
- final String filterPrefix,
- final Properties props) {
- final Appender appender = newInstanceOf(className, "Appender");
- if (appender == null) {
- return null;
- }
- appender.setName(appenderName);
- appender.setLayout(parseLayout(layoutPrefix, appenderName, props));
- final String errorHandlerPrefix = prefix + ".errorhandler";
- final String errorHandlerClass = OptionConverter.findAndSubst(errorHandlerPrefix, props);
- if (errorHandlerClass != null) {
- final ErrorHandler eh = parseErrorHandler(props, errorHandlerPrefix, errorHandlerClass, appender);
- if (eh != null) {
- appender.setErrorHandler(eh);
- }
- }
- appender.addFilter(parseAppenderFilters(props, filterPrefix, appenderName));
- final String[] keys = new String[] {layoutPrefix};
- addProperties(appender, keys, props, prefix);
- addAppender(AppenderAdapter.adapt(appender));
- registry.put(appenderName, appender);
- return appender;
- }
-
- public Layout parseLayout(final String layoutPrefix, final String appenderName, final Properties props) {
- final String layoutClass = OptionConverter.findAndSubst(layoutPrefix, props);
- if (layoutClass == null) {
- return null;
- }
- Layout layout = manager.parse(layoutClass, layoutPrefix, props, this, BuilderManager.INVALID_LAYOUT);
- if (layout == null) {
- layout = buildLayout(layoutPrefix, layoutClass, appenderName, props);
- }
- return layout;
- }
-
- private Layout buildLayout(
- final String layoutPrefix, final String className, final String appenderName, final Properties props) {
- final Layout layout = newInstanceOf(className, "Layout");
- if (layout == null) {
- return null;
- }
- LOGGER.debug("Parsing layout options for \"{}\".", appenderName);
- PropertySetter.setProperties(layout, props, layoutPrefix + ".");
- LOGGER.debug("End of parsing for \"{}\".", appenderName);
- return layout;
- }
-
- public ErrorHandler parseErrorHandler(
- final Properties props,
- final String errorHandlerPrefix,
- final String errorHandlerClass,
- final Appender appender) {
- final ErrorHandler eh = newInstanceOf(errorHandlerClass, "ErrorHandler");
- final String[] keys = new String[] {
- // @formatter:off
- errorHandlerPrefix + "." + ROOT_REF,
- errorHandlerPrefix + "." + LOGGER_REF,
- errorHandlerPrefix + "." + APPENDER_REF_TAG
- };
- // @formatter:on
- addProperties(eh, keys, props, errorHandlerPrefix);
- return eh;
- }
-
- public void addProperties(final Object obj, final String[] keys, final Properties props, final String prefix) {
- final Properties edited = new Properties();
- props.stringPropertyNames().stream()
- .filter(name -> {
- if (name.startsWith(prefix)) {
- for (final String key : keys) {
- if (name.equals(key)) {
- return false;
- }
- }
- return true;
- }
- return false;
- })
- .forEach(name -> edited.put(name, props.getProperty(name)));
- PropertySetter.setProperties(obj, edited, prefix + ".");
- }
-
- public Filter parseAppenderFilters(final Properties props, final String filterPrefix, final String appenderName) {
- // extract filters and filter options from props into a hashtable mapping
- // the property name defining the filter class to a list of pre-parsed
- // name-value pairs associated to that filter
- final int fIdx = filterPrefix.length();
- final SortedMap> filters = new TreeMap<>();
- final Enumeration> e = props.keys();
- String name = "";
- while (e.hasMoreElements()) {
- final String key = (String) e.nextElement();
- if (key.startsWith(filterPrefix)) {
- final int dotIdx = key.indexOf('.', fIdx);
- String filterKey = key;
- if (dotIdx != -1) {
- filterKey = key.substring(0, dotIdx);
- name = key.substring(dotIdx + 1);
- }
- final List filterOpts = filters.computeIfAbsent(filterKey, k -> new ArrayList<>());
- if (dotIdx != -1) {
- final String value = OptionConverter.findAndSubst(key, props);
- filterOpts.add(new NameValue(name, value));
- }
- }
- }
-
- Filter head = null;
- for (final Map.Entry> entry : filters.entrySet()) {
- final String clazz = props.getProperty(entry.getKey());
- Filter filter = null;
- if (clazz != null) {
- filter = manager.parse(clazz, entry.getKey(), props, this, BuilderManager.INVALID_FILTER);
- if (filter == null) {
- LOGGER.debug("Filter key: [{}] class: [{}] props: {}", entry.getKey(), clazz, entry.getValue());
- filter = buildFilter(clazz, appenderName, entry.getValue());
- }
- }
- head = FilterAdapter.addFilter(head, filter);
- }
- return head;
- }
-
- private Filter buildFilter(final String className, final String appenderName, final List props) {
- final Filter filter = newInstanceOf(className, "Filter");
- if (filter != null) {
- final PropertySetter propSetter = new PropertySetter(filter);
- for (final NameValue property : props) {
- propSetter.setProperty(property.key, property.value);
- }
- propSetter.activate();
- }
- return filter;
- }
-
- public TriggeringPolicy parseTriggeringPolicy(final Properties props, final String policyPrefix) {
- final String policyClass = OptionConverter.findAndSubst(policyPrefix, props);
- if (policyClass == null) {
- return null;
- }
- return manager.parse(policyClass, policyPrefix, props, this, null);
- }
-
- private static T newInstanceOf(final String className, final String type) {
- try {
- return LoaderUtil.newInstanceOf(className);
- } catch (ReflectiveOperationException | LinkageError | RuntimeException ex) {
- LOGGER.error(
- "Unable to create {} {} due to {}:{}",
- type,
- className,
- ex.getClass().getSimpleName(),
- ex.getMessage(),
- ex);
- return null;
- }
- }
-
- private static class NameValue {
- String key, value;
-
- NameValue(final String key, final String value) {
- this.key = key;
- this.value = value;
- }
-
- @Override
- public String toString() {
- return key + "=" + value;
- }
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/config/PropertiesConfigurationFactory.java b/log4j-1.2-api/src/main/java/org/apache/log4j/config/PropertiesConfigurationFactory.java
deleted file mode 100644
index fe23383d4d6..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/config/PropertiesConfigurationFactory.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.config;
-
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.config.ConfigurationSource;
-import org.apache.logging.log4j.core.config.Order;
-import org.apache.logging.log4j.core.impl.CoreProperties.Version1Properties;
-import org.apache.logging.log4j.kit.env.PropertyEnvironment;
-import org.apache.logging.log4j.plugins.Namespace;
-import org.apache.logging.log4j.plugins.Plugin;
-
-/**
- * Configures Log4j from a log4j 1 format properties file.
- */
-@Namespace(ConfigurationFactory.NAMESPACE)
-@Plugin("Log4j1PropertiesConfigurationFactory")
-@Order(2)
-public class PropertiesConfigurationFactory extends ConfigurationFactory {
-
- static final String FILE_EXTENSION = ".properties";
-
- /**
- * File name prefix for test configurations.
- */
- protected static final String TEST_PREFIX = "log4j-test";
-
- /**
- * File name prefix for standard configurations.
- */
- protected static final String DEFAULT_PREFIX = "log4j";
-
- private final boolean enabled;
-
- public PropertiesConfigurationFactory() {
- this(PropertyEnvironment.getGlobal().getProperty(Version1Properties.class));
- }
-
- private PropertiesConfigurationFactory(final Version1Properties properties) {
- this.enabled = properties.compatibility() || properties.configuration() != null;
- }
-
- @Override
- protected String[] getSupportedTypes() {
- return enabled ? new String[] {FILE_EXTENSION} : null;
- }
-
- @Override
- public Configuration getConfiguration(final LoggerContext loggerContext, final ConfigurationSource source) {
- final int interval = loggerContext
- .getEnvironment()
- .getProperty(Version1Properties.class)
- .monitorInterval();
- return new PropertiesConfiguration(loggerContext, source, interval);
- }
-
- @Override
- public String getTestPrefix() {
- return TEST_PREFIX;
- }
-
- @Override
- public String getDefaultPrefix() {
- return DEFAULT_PREFIX;
- }
-
- @Override
- public String getVersion() {
- return LOG4J1_VERSION;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/config/PropertySetter.java b/log4j-1.2-api/src/main/java/org/apache/log4j/config/PropertySetter.java
deleted file mode 100644
index 47dd263d814..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/config/PropertySetter.java
+++ /dev/null
@@ -1,279 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.config;
-
-import java.beans.BeanInfo;
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-import java.io.InterruptedIOException;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Properties;
-import org.apache.log4j.Appender;
-import org.apache.log4j.Priority;
-import org.apache.log4j.spi.ErrorHandler;
-import org.apache.log4j.spi.OptionHandler;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.util.OptionConverter;
-import org.apache.logging.log4j.status.StatusLogger;
-
-/**
- * General purpose Object property setter. Clients repeatedly invokes
- * {@link #setProperty setProperty(name,value)} in order to invoke setters
- * on the Object specified in the constructor. This class relies on the
- * JavaBeans {@link Introspector} to analyze the given Object Class using
- * reflection.
- *
- * Usage:
- *
- * PropertySetter ps = new PropertySetter(anObject);
- * ps.set("name", "Joe");
- * ps.set("age", "32");
- * ps.set("isMale", "true");
- *
- * will cause the invocations anObject.setName("Joe"), anObject.setAge(32),
- * and setMale(true) if such methods exist with those signatures.
- * Otherwise an {@link IntrospectionException} are thrown.
- */
-public class PropertySetter {
- private static final PropertyDescriptor[] EMPTY_PROPERTY_DESCRIPTOR_ARRAY = {};
- private static final Logger LOGGER = StatusLogger.getLogger();
- protected Object obj;
- protected PropertyDescriptor[] props;
-
- /**
- * Create a new PropertySetter for the specified Object. This is done
- * in preparation for invoking {@link #setProperty} one or more times.
- *
- * @param obj the object for which to set properties
- */
- public PropertySetter(final Object obj) {
- this.obj = obj;
- }
-
- /**
- * Set the properties of an object passed as a parameter in one
- * go. The properties
are parsed relative to a
- * prefix
.
- *
- * @param obj The object to configure.
- * @param properties A java.util.Properties containing keys and values.
- * @param prefix Only keys having the specified prefix will be set.
- */
- public static void setProperties(final Object obj, final Properties properties, final String prefix) {
- new PropertySetter(obj).setProperties(properties, prefix);
- }
-
- /**
- * Uses JavaBeans {@link Introspector} to computer setters of object to be
- * configured.
- */
- protected void introspect() {
- try {
- final BeanInfo bi = Introspector.getBeanInfo(obj.getClass());
- props = bi.getPropertyDescriptors();
- } catch (IntrospectionException ex) {
- LOGGER.error("Failed to introspect {}: {}", obj, ex.getMessage());
- props = EMPTY_PROPERTY_DESCRIPTOR_ARRAY;
- }
- }
-
- /**
- * Set the properties for the object that match the
- * prefix
passed as parameter.
- * @param properties The properties.
- * @param prefix The prefix of the properties to use.
- */
- public void setProperties(final Properties properties, final String prefix) {
- final int len = prefix.length();
-
- for (String key : properties.stringPropertyNames()) {
-
- // handle only properties that start with the desired prefix.
- if (key.startsWith(prefix)) {
-
- // ignore key if it contains dots after the prefix
- if (key.indexOf('.', len + 1) > 0) {
- continue;
- }
-
- final String value = OptionConverter.findAndSubst(key, properties);
- key = key.substring(len);
- if (("layout".equals(key) || "errorhandler".equals(key)) && obj instanceof Appender) {
- continue;
- }
- //
- // if the property type is an OptionHandler
- // (for example, triggeringPolicy of org.apache.log4j.rolling.RollingFileAppender)
- final PropertyDescriptor prop = getPropertyDescriptor(Introspector.decapitalize(key));
- if (prop != null
- && OptionHandler.class.isAssignableFrom(prop.getPropertyType())
- && prop.getWriteMethod() != null) {
- final OptionHandler opt = (OptionHandler)
- OptionConverter.instantiateByKey(properties, prefix + key, prop.getPropertyType(), null);
- final PropertySetter setter = new PropertySetter(opt);
- setter.setProperties(properties, prefix + key + ".");
- try {
- prop.getWriteMethod().invoke(this.obj, opt);
- } catch (InvocationTargetException ex) {
- if (ex.getTargetException() instanceof InterruptedException
- || ex.getTargetException() instanceof InterruptedIOException) {
- Thread.currentThread().interrupt();
- }
- LOGGER.warn("Failed to set property [{}] to value \"{}\".", key, value, ex);
- } catch (IllegalAccessException | RuntimeException ex) {
- LOGGER.warn("Failed to set property [{}] to value \"{}\".", key, value, ex);
- }
- continue;
- }
-
- setProperty(key, value);
- }
- }
- activate();
- }
-
- /**
- * Set a property on this PropertySetter's Object. If successful, this
- * method will invoke a setter method on the underlying Object. The
- * setter is the one for the specified property name and the value is
- * determined partly from the setter argument type and partly from the
- * value specified in the call to this method.
- *
- * If the setter expects a String no conversion is necessary.
- * If it expects an int, then an attempt is made to convert 'value'
- * to an int using new Integer(value). If the setter expects a boolean,
- * the conversion is by new Boolean(value).
- *
- * @param name name of the property
- * @param value String value of the property
- */
- public void setProperty(String name, String value) {
- if (value == null) {
- return;
- }
-
- name = Introspector.decapitalize(name);
- final PropertyDescriptor prop = getPropertyDescriptor(name);
-
- // LOGGER.debug("---------Key: "+name+", type="+prop.getPropertyType());
-
- if (prop == null) {
- LOGGER.warn("No such property [" + name + "] in " + obj.getClass().getName() + ".");
- } else {
- try {
- setProperty(prop, name, value);
- } catch (PropertySetterException ex) {
- LOGGER.warn("Failed to set property [{}] to value \"{}\".", name, value, ex.rootCause);
- }
- }
- }
-
- /**
- * Set the named property given a {@link PropertyDescriptor}.
- *
- * @param prop A PropertyDescriptor describing the characteristics
- * of the property to set.
- * @param name The named of the property to set.
- * @param value The value of the property.
- * @throws PropertySetterException if no setter is available.
- */
- public void setProperty(PropertyDescriptor prop, String name, String value) throws PropertySetterException {
- final Method setter = prop.getWriteMethod();
- if (setter == null) {
- throw new PropertySetterException("No setter for property [" + name + "].");
- }
- final Class>[] paramTypes = setter.getParameterTypes();
- if (paramTypes.length != 1) {
- throw new PropertySetterException("#params for setter != 1");
- }
-
- Object arg;
- try {
- arg = convertArg(value, paramTypes[0]);
- } catch (Throwable t) {
- throw new PropertySetterException("Conversion to type [" + paramTypes[0] + "] failed. Reason: " + t);
- }
- if (arg == null) {
- throw new PropertySetterException("Conversion to type [" + paramTypes[0] + "] failed.");
- }
- LOGGER.debug("Setting property [" + name + "] to [" + arg + "].");
- try {
- setter.invoke(obj, arg);
- } catch (InvocationTargetException ex) {
- if (ex.getTargetException() instanceof InterruptedException
- || ex.getTargetException() instanceof InterruptedIOException) {
- Thread.currentThread().interrupt();
- }
- throw new PropertySetterException(ex);
- } catch (IllegalAccessException | RuntimeException ex) {
- throw new PropertySetterException(ex);
- }
- }
-
- /**
- * Convert val
a String parameter to an object of a
- * given type.
- * @param val The value to convert.
- * @param type The type of the value to convert to.
- * @return The result of the conversion.
- */
- protected Object convertArg(final String val, final Class> type) {
- if (val == null) {
- return null;
- }
-
- final String v = val.trim();
- if (String.class.isAssignableFrom(type)) {
- return val;
- } else if (Integer.TYPE.isAssignableFrom(type)) {
- return Integer.parseInt(v);
- } else if (Long.TYPE.isAssignableFrom(type)) {
- return Long.parseLong(v);
- } else if (Boolean.TYPE.isAssignableFrom(type)) {
- if ("true".equalsIgnoreCase(v)) {
- return Boolean.TRUE;
- } else if ("false".equalsIgnoreCase(v)) {
- return Boolean.FALSE;
- }
- } else if (Priority.class.isAssignableFrom(type)) {
- return org.apache.log4j.helpers.OptionConverter.toLevel(v, Log4j1Configuration.DEFAULT_LEVEL);
- } else if (ErrorHandler.class.isAssignableFrom(type)) {
- return OptionConverter.instantiateByClassName(v, ErrorHandler.class, null);
- }
- return null;
- }
-
- protected PropertyDescriptor getPropertyDescriptor(String name) {
- if (props == null) {
- introspect();
- }
- for (PropertyDescriptor prop : props) {
- if (name.equals(prop.getName())) {
- return prop;
- }
- }
- return null;
- }
-
- public void activate() {
- if (obj instanceof OptionHandler) {
- ((OptionHandler) obj).activateOptions();
- }
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/config/PropertySetterException.java b/log4j-1.2-api/src/main/java/org/apache/log4j/config/PropertySetterException.java
deleted file mode 100644
index be1a3df0cd2..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/config/PropertySetterException.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.config;
-
-/**
- * Thrown when an error is encountered whilst attempting to set a property
- * using the {@link PropertySetter} utility class.
- *
- * @since 1.1
- */
-public class PropertySetterException extends Exception {
- private static final long serialVersionUID = -1352613734254235861L;
-
- /**
- * The root cause.
- */
- protected Throwable rootCause;
-
- /**
- * Construct the exception with the given message.
- *
- * @param msg The message
- */
- public PropertySetterException(final String msg) {
- super(msg);
- }
-
- /**
- * Construct the exception with the given root cause.
- *
- * @param rootCause The root cause
- */
- public PropertySetterException(final Throwable rootCause) {
- this.rootCause = rootCause;
- }
-
- /**
- * Returns descriptive text on the cause of this exception.
- *
- * @return the descriptive text.
- */
- @Override
- public String getMessage() {
- String msg = super.getMessage();
- if (msg == null && rootCause != null) {
- msg = rootCause.getMessage();
- }
- return msg;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/config/package-info.java b/log4j-1.2-api/src/main/java/org/apache/log4j/config/package-info.java
deleted file mode 100644
index 396cf9bbd32..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/config/package-info.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-/**
- * Log4j 1.x compatibility layer.
- */
-@Export
-@Version("2.20.1")
-@Open("org.apache.logging.log4j.core")
-package org.apache.log4j.config;
-
-import aQute.bnd.annotation.jpms.Open;
-import org.osgi.annotation.bundle.Export;
-import org.osgi.annotation.versioning.Version;
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/AbsoluteTimeDateFormat.java b/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/AbsoluteTimeDateFormat.java
deleted file mode 100644
index f8ffdb7053d..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/AbsoluteTimeDateFormat.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.helpers;
-
-import java.text.DateFormat;
-import java.text.FieldPosition;
-import java.text.ParsePosition;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.TimeZone;
-
-/**
- * Formats a {@link Date} in the format "HH:mm:ss,SSS" for example, "15:49:37,459".
- *
- * @since 0.7.5
- */
-public class AbsoluteTimeDateFormat extends DateFormat {
-
- private static final long serialVersionUID = -388856345976723342L;
-
- /**
- * String constant used to specify {@link org.apache.log4j.helpers.AbsoluteTimeDateFormat} in layouts. Current value is
- * ABSOLUTE .
- */
- public static final String ABS_TIME_DATE_FORMAT = "ABSOLUTE";
-
- /**
- * String constant used to specify {@link org.apache.log4j.helpers.DateTimeDateFormat} in layouts. Current value is
- * DATE .
- */
- public static final String DATE_AND_TIME_DATE_FORMAT = "DATE";
-
- /**
- * String constant used to specify {@link org.apache.log4j.helpers.ISO8601DateFormat} in layouts. Current value is
- * ISO8601 .
- */
- public static final String ISO8601_DATE_FORMAT = "ISO8601";
-
- private static long previousTime;
-
- private static char[] previousTimeWithoutMillis = new char[9]; // "HH:mm:ss."
-
- public AbsoluteTimeDateFormat() {
- setCalendar(Calendar.getInstance());
- }
-
- public AbsoluteTimeDateFormat(final TimeZone timeZone) {
- setCalendar(Calendar.getInstance(timeZone));
- }
-
- /**
- * Appends to sbuf
the time in the format "HH:mm:ss,SSS" for example, "15:49:37,459"
- *
- * @param date the date to format
- * @param sbuf the string buffer to write to
- * @param fieldPosition remains untouched
- */
- @Override
- public StringBuffer format(final Date date, final StringBuffer sbuf, final FieldPosition fieldPosition) {
-
- final long now = date.getTime();
- final int millis = (int) (now % 1000);
-
- if ((now - millis) != previousTime || previousTimeWithoutMillis[0] == 0) {
- // We reach this point at most once per second
- // across all threads instead of each time format()
- // is called. This saves considerable CPU time.
-
- calendar.setTime(date);
-
- final int start = sbuf.length();
-
- final int hour = calendar.get(Calendar.HOUR_OF_DAY);
- if (hour < 10) {
- sbuf.append('0');
- }
- sbuf.append(hour);
- sbuf.append(':');
-
- final int mins = calendar.get(Calendar.MINUTE);
- if (mins < 10) {
- sbuf.append('0');
- }
- sbuf.append(mins);
- sbuf.append(':');
-
- final int secs = calendar.get(Calendar.SECOND);
- if (secs < 10) {
- sbuf.append('0');
- }
- sbuf.append(secs);
- sbuf.append(',');
-
- // store the time string for next time to avoid recomputation
- sbuf.getChars(start, sbuf.length(), previousTimeWithoutMillis, 0);
-
- previousTime = now - millis;
- } else {
- sbuf.append(previousTimeWithoutMillis);
- }
-
- if (millis < 100) {
- sbuf.append('0');
- }
- if (millis < 10) {
- sbuf.append('0');
- }
-
- sbuf.append(millis);
- return sbuf;
- }
-
- /**
- * Always returns null.
- */
- @Override
- public Date parse(final String s, final ParsePosition pos) {
- return null;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/AppenderAttachableImpl.java b/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/AppenderAttachableImpl.java
deleted file mode 100644
index 6b3090559a2..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/AppenderAttachableImpl.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.helpers;
-
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.Objects;
-import java.util.Vector;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import org.apache.log4j.Appender;
-import org.apache.log4j.spi.AppenderAttachable;
-import org.apache.log4j.spi.LoggingEvent;
-
-/**
- * Allows Classes to attach Appenders.
- */
-public class AppenderAttachableImpl implements AppenderAttachable {
-
- private final ConcurrentMap appenders = new ConcurrentHashMap<>();
-
- /** Array of appenders. TODO */
- protected Vector appenderList;
-
- @Override
- public void addAppender(final Appender appender) {
- if (appender != null) {
- // NullAppender name is null.
- appenders.put(Objects.toString(appender.getName()), appender);
- }
- }
-
- /**
- * Calls the doAppend
method on all attached appenders.
- *
- * @param event The event to log.
- * @return The number of appenders.
- */
- public int appendLoopOnAppenders(final LoggingEvent event) {
- for (final Appender appender : appenders.values()) {
- appender.doAppend(event);
- }
- return appenders.size();
- }
-
- /**
- * Closes all appenders.
- */
- public void close() {
- for (final Appender appender : appenders.values()) {
- appender.close();
- }
- }
-
- @Override
- public Enumeration getAllAppenders() {
- return Collections.enumeration(appenders.values());
- }
-
- @Override
- public Appender getAppender(final String name) {
- // No null keys allowed in a CHM.
- return name == null ? null : appenders.get(name);
- }
-
- @Override
- public boolean isAttached(final Appender appender) {
- return appender != null ? appenders.containsValue(appender) : false;
- }
-
- @Override
- public void removeAllAppenders() {
- appenders.clear();
- }
-
- @Override
- public void removeAppender(final Appender appender) {
- if (appender != null) {
- final String name = appender.getName();
- if (name != null) {
- appenders.remove(name, appender);
- }
- }
- }
-
- @Override
- public void removeAppender(final String name) {
- if (name != null) {
- appenders.remove(name);
- }
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/BoundedFIFO.java b/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/BoundedFIFO.java
deleted file mode 100644
index 404a58a57ed..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/BoundedFIFO.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.helpers;
-
-import org.apache.log4j.spi.LoggingEvent;
-
-/**
- * Bounded first-in-first-out buffer.
- *
- * @since version 0.9.1
- */
-public class BoundedFIFO {
-
- LoggingEvent[] buf;
- int numElements = 0;
- int first = 0;
- int next = 0;
- int maxSize;
-
- /**
- * Constructs a new instance with a maximum size passed as argument.
- */
- public BoundedFIFO(final int maxSize) {
- if (maxSize < 1) {
- throw new IllegalArgumentException("The maxSize argument (" + maxSize + ") is not a positive integer.");
- }
- this.maxSize = maxSize;
- buf = new LoggingEvent[maxSize];
- }
-
- /**
- * Gets the first element in the buffer. Returns null
if there are no elements in the buffer.
- */
- public LoggingEvent get() {
- if (numElements == 0) {
- return null;
- }
-
- final LoggingEvent r = buf[first];
- buf[first] = null; // help garbage collection
-
- if (++first == maxSize) {
- first = 0;
- }
- numElements--;
- return r;
- }
-
- /**
- * Gets the maximum size of the buffer.
- */
- public int getMaxSize() {
- return maxSize;
- }
-
- /**
- * Returns true
if the buffer is full, that is, whether the number of elements in the buffer equals the
- * buffer size.
- */
- public boolean isFull() {
- return numElements == maxSize;
- }
-
- /**
- * Gets the number of elements in the buffer. This number is guaranteed to be in the range 0 to maxSize
- * (inclusive).
- */
- public int length() {
- return numElements;
- }
-
- int min(final int a, final int b) {
- return a < b ? a : b;
- }
-
- /**
- * Puts a {@link LoggingEvent} in the buffer. If the buffer is full then the event is silently dropped . It is the
- * caller's responsability to make sure that the buffer has free space.
- */
- public void put(final LoggingEvent o) {
- if (numElements != maxSize) {
- buf[next] = o;
- if (++next == maxSize) {
- next = 0;
- }
- numElements++;
- }
- }
-
- /**
- * Resizes the buffer to a new size. If the new size is smaller than the old size events might be lost.
- *
- * @since 1.1
- */
- public synchronized void resize(final int newSize) {
- if (newSize == maxSize) {
- return;
- }
-
- final LoggingEvent[] tmp = new LoggingEvent[newSize];
-
- // we should not copy beyond the buf array
- int len1 = maxSize - first;
-
- // we should not copy beyond the tmp array
- len1 = min(len1, newSize);
-
- // er.. how much do we actually need to copy?
- // We should not copy more than the actual number of elements.
- len1 = min(len1, numElements);
-
- // Copy from buf starting a first, to tmp, starting at position 0, len1 elements.
- System.arraycopy(buf, first, tmp, 0, len1);
-
- // Are there any uncopied elements and is there still space in the new array?
- int len2 = 0;
- if ((len1 < numElements) && (len1 < newSize)) {
- len2 = numElements - len1;
- len2 = min(len2, newSize - len1);
- System.arraycopy(buf, 0, tmp, len1, len2);
- }
-
- this.buf = tmp;
- this.maxSize = newSize;
- this.first = 0;
- this.numElements = len1 + len2;
- this.next = this.numElements;
- if (this.next == this.maxSize) {
- this.next = 0;
- }
- }
-
- /**
- * Returns true
if there is just one element in the buffer. In other words, if there were no elements
- * before the last {@link #put} operation completed.
- */
- public boolean wasEmpty() {
- return numElements == 1;
- }
-
- /**
- * Returns true
if the number of elements in the buffer plus 1 equals the maximum buffer size, returns
- * false
otherwise.
- */
- public boolean wasFull() {
- return numElements + 1 == maxSize;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/CountingQuietWriter.java b/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/CountingQuietWriter.java
deleted file mode 100644
index d806cc5628c..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/CountingQuietWriter.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.helpers;
-
-import java.io.IOException;
-import java.io.Writer;
-import org.apache.log4j.spi.ErrorCode;
-import org.apache.log4j.spi.ErrorHandler;
-
-/**
- * Counts the number of bytes written.
- *
- * @since 0.8.1
- */
-public class CountingQuietWriter extends QuietWriter {
-
- protected long count;
-
- public CountingQuietWriter(final Writer writer, final ErrorHandler eh) {
- super(writer, eh);
- }
-
- public long getCount() {
- return count;
- }
-
- public void setCount(final long count) {
- this.count = count;
- }
-
- @Override
- public void write(final String string) {
- try {
- out.write(string);
- count += string.length();
- } catch (final IOException e) {
- errorHandler.error("Write failure.", e, ErrorCode.WRITE_FAILURE);
- }
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/CyclicBuffer.java b/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/CyclicBuffer.java
deleted file mode 100644
index 882f495ef7b..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/CyclicBuffer.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.helpers;
-
-import org.apache.log4j.spi.LoggingEvent;
-
-/**
- * Holds {@link LoggingEvent LoggingEvents} for immediate or differed display.
- *
- *
- * This buffer gives read access to any element in the buffer not just the first or last element.
- *
- *
- * @since 0.9.0
- */
-public class CyclicBuffer {
-
- LoggingEvent[] ea;
- int first;
- int last;
- int numElems;
- int maxSize;
-
- /**
- * Constructs a new instance of at most maxSize
events.
- *
- * The maxSize
argument must a positive integer.
- *
- * @param maxSize The maximum number of elements in the buffer.
- */
- public CyclicBuffer(final int maxSize) throws IllegalArgumentException {
- if (maxSize < 1) {
- throw new IllegalArgumentException("The maxSize argument (" + maxSize + ") is not a positive integer.");
- }
- this.maxSize = maxSize;
- ea = new LoggingEvent[maxSize];
- first = 0;
- last = 0;
- numElems = 0;
- }
-
- /**
- * Adds an event
as the last event in the buffer.
- */
- public void add(final LoggingEvent event) {
- ea[last] = event;
- if (++last == maxSize) {
- last = 0;
- }
-
- if (numElems < maxSize) {
- numElems++;
- } else if (++first == maxSize) {
- first = 0;
- }
- }
-
- /**
- * Gets the oldest (first) element in the buffer. The oldest element is removed from the buffer.
- */
- public LoggingEvent get() {
- LoggingEvent r = null;
- if (numElems > 0) {
- numElems--;
- r = ea[first];
- ea[first] = null;
- if (++first == maxSize) {
- first = 0;
- }
- }
- return r;
- }
-
- /**
- * Gets the i th oldest event currently in the buffer. If i is outside the range 0 to the number of
- * elements currently in the buffer, then null
is returned.
- */
- public LoggingEvent get(final int i) {
- if (i < 0 || i >= numElems) {
- return null;
- }
-
- return ea[(first + i) % maxSize];
- }
-
- public int getMaxSize() {
- return maxSize;
- }
-
- /**
- * Gets the number of elements in the buffer. This number is guaranteed to be in the range 0 to maxSize
- * (inclusive).
- */
- public int length() {
- return numElems;
- }
-
- /**
- * Resizes the cyclic buffer to newSize
.
- *
- * @throws IllegalArgumentException if newSize
is negative.
- */
- public void resize(final int newSize) {
- if (newSize < 0) {
- throw new IllegalArgumentException("Negative array size [" + newSize + "] not allowed.");
- }
- if (newSize == numElems) {
- return; // nothing to do
- }
-
- final LoggingEvent[] temp = new LoggingEvent[newSize];
-
- final int loopLen = newSize < numElems ? newSize : numElems;
-
- for (int i = 0; i < loopLen; i++) {
- temp[i] = ea[first];
- ea[first] = null;
- if (++first == numElems) {
- first = 0;
- }
- }
- ea = temp;
- first = 0;
- numElems = loopLen;
- maxSize = newSize;
- if (loopLen == newSize) {
- last = 0;
- } else {
- last = loopLen;
- }
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/DateLayout.java b/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/DateLayout.java
deleted file mode 100644
index 5412b1b4f7e..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/DateLayout.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.helpers;
-
-import static org.apache.logging.log4j.util.Strings.toRootUpperCase;
-
-import java.text.DateFormat;
-import java.text.FieldPosition;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-import org.apache.log4j.Layout;
-import org.apache.log4j.spi.LoggingEvent;
-
-/**
- * This abstract layout takes care of all the date related options and formatting work.
- */
-public abstract class DateLayout extends Layout {
-
- /**
- * String constant designating no time information. Current value of this constant is NULL .
- *
- */
- public static final String NULL_DATE_FORMAT = "NULL";
-
- /**
- * String constant designating relative time. Current value of this constant is RELATIVE .
- */
- public static final String RELATIVE_TIME_DATE_FORMAT = "RELATIVE";
-
- /**
- * @deprecated Options are now handled using the JavaBeans paradigm. This constant is not longer needed and will be
- * removed in the near term.
- */
- @Deprecated
- public static final String DATE_FORMAT_OPTION = "DateFormat";
-
- /**
- * @deprecated Options are now handled using the JavaBeans paradigm. This constant is not longer needed and will be
- * removed in the near term.
- */
- @Deprecated
- public static final String TIMEZONE_OPTION = "TimeZone";
-
- protected FieldPosition pos = new FieldPosition(0);
-
- private String timeZoneID;
- private String dateFormatOption;
-
- protected DateFormat dateFormat;
- protected Date date = new Date();
-
- public void activateOptions() {
- setDateFormat(dateFormatOption);
- if (timeZoneID != null && dateFormat != null) {
- dateFormat.setTimeZone(TimeZone.getTimeZone(timeZoneID));
- }
- }
-
- public void dateFormat(final StringBuffer buf, final LoggingEvent event) {
- if (dateFormat != null) {
- date.setTime(event.timeStamp);
- dateFormat.format(date, buf, this.pos);
- buf.append(' ');
- }
- }
-
- /**
- * Returns value of the DateFormat option.
- */
- public String getDateFormat() {
- return dateFormatOption;
- }
-
- /**
- * @deprecated Use the setter method for the option directly instead of the generic setOption
method.
- */
- @Deprecated
- public String[] getOptionStrings() {
- return new String[] {DATE_FORMAT_OPTION, TIMEZONE_OPTION};
- }
-
- /**
- * Returns value of the TimeZone option.
- */
- public String getTimeZone() {
- return timeZoneID;
- }
-
- /**
- * Sets the {@link DateFormat} used to format time and date in the zone determined by timeZone
.
- */
- public void setDateFormat(final DateFormat dateFormat, final TimeZone timeZone) {
- this.dateFormat = dateFormat;
- this.dateFormat.setTimeZone(timeZone);
- }
-
- /**
- * The value of the DateFormat option should be either an argument to the constructor of {@link SimpleDateFormat}
- * or one of the srings "NULL", "RELATIVE", "ABSOLUTE", "DATE" or "ISO8601.
- */
- public void setDateFormat(final String dateFormat) {
- if (dateFormat != null) {
- dateFormatOption = dateFormat;
- }
- setDateFormat(dateFormatOption, TimeZone.getDefault());
- }
-
- /**
- * Sets the DateFormat used to format date and time in the time zone determined by timeZone
parameter. The
- * {@link DateFormat} used will depend on the dateFormatType
.
- *
- *
- * The recognized types are {@link #NULL_DATE_FORMAT}, {@link #RELATIVE_TIME_DATE_FORMAT}
- * {@link AbsoluteTimeDateFormat#ABS_TIME_DATE_FORMAT}, {@link AbsoluteTimeDateFormat#DATE_AND_TIME_DATE_FORMAT} and
- * {@link AbsoluteTimeDateFormat#ISO8601_DATE_FORMAT}. If the dateFormatType
is not one of the above, then
- * the argument is assumed to be a date pattern for {@link SimpleDateFormat}.
- */
- public void setDateFormat(final String dateFormatType, final TimeZone timeZone) {
- if (dateFormatType == null) {
- this.dateFormat = null;
- return;
- }
- if (dateFormatType.equalsIgnoreCase(NULL_DATE_FORMAT)) {
- this.dateFormat = null;
- } else if (dateFormatType.equalsIgnoreCase(RELATIVE_TIME_DATE_FORMAT)) {
- this.dateFormat = new RelativeTimeDateFormat();
- } else if (dateFormatType.equalsIgnoreCase(AbsoluteTimeDateFormat.ABS_TIME_DATE_FORMAT)) {
- this.dateFormat = new AbsoluteTimeDateFormat(timeZone);
- } else if (dateFormatType.equalsIgnoreCase(AbsoluteTimeDateFormat.DATE_AND_TIME_DATE_FORMAT)) {
- this.dateFormat = new DateTimeDateFormat(timeZone);
- } else if (dateFormatType.equalsIgnoreCase(AbsoluteTimeDateFormat.ISO8601_DATE_FORMAT)) {
- this.dateFormat = new ISO8601DateFormat(timeZone);
- } else {
- this.dateFormat = new SimpleDateFormat(dateFormatType);
- this.dateFormat.setTimeZone(timeZone);
- }
- }
-
- /**
- * @deprecated Use the setter method for the option directly instead of the generic setOption
method.
- */
- @Deprecated
- public void setOption(final String option, final String value) {
- if (option.equalsIgnoreCase(DATE_FORMAT_OPTION)) {
- dateFormatOption = toRootUpperCase(value);
- } else if (option.equalsIgnoreCase(TIMEZONE_OPTION)) {
- timeZoneID = value;
- }
- }
-
- /**
- * The TimeZoneID option is a time zone ID string in the format expected by the {@link TimeZone#getTimeZone}
- * method.
- */
- public void setTimeZone(final String timeZone) {
- this.timeZoneID = timeZone;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/DateTimeDateFormat.java b/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/DateTimeDateFormat.java
deleted file mode 100644
index aa117c8feea..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/DateTimeDateFormat.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.helpers;
-
-import java.text.DateFormatSymbols;
-import java.text.FieldPosition;
-import java.text.ParsePosition;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.TimeZone;
-
-/**
- * Formats a {@link Date} in the format "dd MMM yyyy HH:mm:ss,SSS" for example, "06 Nov 1994 15:49:37,459".
- *
- * @since 0.7.5
- */
-public class DateTimeDateFormat extends AbsoluteTimeDateFormat {
- private static final long serialVersionUID = 5547637772208514971L;
-
- String[] shortMonths;
-
- public DateTimeDateFormat() {
- super();
- shortMonths = new DateFormatSymbols().getShortMonths();
- }
-
- public DateTimeDateFormat(final TimeZone timeZone) {
- this();
- setCalendar(Calendar.getInstance(timeZone));
- }
-
- /**
- * Appends to sbuf
the date in the format "dd MMM yyyy HH:mm:ss,SSS" for example, "06 Nov 1994
- * 08:49:37,459".
- *
- * @param sbuf the string buffer to write to
- */
- @Override
- public StringBuffer format(final Date date, final StringBuffer sbuf, final FieldPosition fieldPosition) {
-
- calendar.setTime(date);
-
- final int day = calendar.get(Calendar.DAY_OF_MONTH);
- if (day < 10) {
- sbuf.append('0');
- }
- sbuf.append(day);
- sbuf.append(' ');
- sbuf.append(shortMonths[calendar.get(Calendar.MONTH)]);
- sbuf.append(' ');
-
- final int year = calendar.get(Calendar.YEAR);
- sbuf.append(year);
- sbuf.append(' ');
-
- return super.format(date, sbuf, fieldPosition);
- }
-
- /**
- * Always returns null.
- */
- @Override
- public Date parse(final String s, final ParsePosition pos) {
- return null;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/FileWatchdog.java b/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/FileWatchdog.java
deleted file mode 100644
index a43776bed76..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/FileWatchdog.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.helpers;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.io.File;
-
-/**
- * Checks every now and then that a certain file has not changed. If it has, then call the {@link #doOnChange} method.
- *
- * @since version 0.9.1
- */
-public abstract class FileWatchdog extends Thread {
-
- /**
- * The default delay between every file modification check, set to 60 seconds.
- */
- public static final long DEFAULT_DELAY = 60_000;
-
- /**
- * The name of the file to observe for changes.
- */
- protected String filename;
-
- /**
- * The delay to observe between every check. By default set {@link #DEFAULT_DELAY}.
- */
- protected long delay = DEFAULT_DELAY;
-
- File file;
- long lastModified;
- boolean warnedAlready;
- boolean interrupted;
-
- @SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "The filename comes from a system property.")
- protected FileWatchdog(final String fileName) {
- super("FileWatchdog");
- this.filename = fileName;
- this.file = new File(fileName);
- setDaemon(true);
- checkAndConfigure();
- }
-
- protected void checkAndConfigure() {
- boolean fileExists;
- try {
- fileExists = file.exists();
- } catch (final SecurityException e) {
- LogLog.warn("Was not allowed to read check file existance, file:[" + filename + "].");
- interrupted = true; // there is no point in continuing
- return;
- }
-
- if (fileExists) {
- final long fileLastMod = file.lastModified(); // this can also throw a SecurityException
- if (fileLastMod > lastModified) { // however, if we reached this point this
- lastModified = fileLastMod; // is very unlikely.
- doOnChange();
- warnedAlready = false;
- }
- } else {
- if (!warnedAlready) {
- LogLog.debug("[" + filename + "] does not exist.");
- warnedAlready = true;
- }
- }
- }
-
- protected abstract void doOnChange();
-
- @Override
- public void run() {
- while (!interrupted) {
- try {
- Thread.sleep(delay);
- } catch (final InterruptedException e) {
- // no interruption expected
- }
- checkAndConfigure();
- }
- }
-
- /**
- * Sets the delay in milliseconds to observe between each check of the file changes.
- *
- * @param delayMillis the delay in milliseconds
- */
- public void setDelay(final long delayMillis) {
- this.delay = delayMillis;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/FormattingInfo.java b/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/FormattingInfo.java
deleted file mode 100644
index 1d6a9082024..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/FormattingInfo.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.helpers;
-
-/**
- * FormattingInfo instances contain the information obtained when parsing formatting modifiers in conversion modifiers.
- *
- * @since 0.8.2
- */
-public class FormattingInfo {
- int min = -1;
- int max = 0x7FFFFFFF;
- boolean leftAlign = false;
-
- void dump() {
- LogLog.debug("min=" + min + ", max=" + max + ", leftAlign=" + leftAlign);
- }
-
- void reset() {
- min = -1;
- max = 0x7FFFFFFF;
- leftAlign = false;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/ISO8601DateFormat.java b/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/ISO8601DateFormat.java
deleted file mode 100644
index 847bbb4ec0a..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/ISO8601DateFormat.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.helpers;
-
-import java.text.FieldPosition;
-import java.text.ParsePosition;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.TimeZone;
-
-/**
- * Formats a {@link Date} in the format "yyyy-MM-dd HH:mm:ss,SSS" for example "1999-11-27 15:49:37,459".
- *
- *
- * Refer to the summary of the International Standard Date and Time
- * Notation for more information on this format.
- *
- *
- * @since 0.7.5
- */
-public class ISO8601DateFormat extends AbsoluteTimeDateFormat {
-
- private static final long serialVersionUID = -759840745298755296L;
-
- private static long lastTime;
-
- private static char[] lastTimeString = new char[20];
-
- public ISO8601DateFormat() {}
-
- public ISO8601DateFormat(final TimeZone timeZone) {
- super(timeZone);
- }
-
- /**
- * Appends a date in the format "YYYY-mm-dd HH:mm:ss,SSS" to sbuf
. For example: "1999-11-27 15:49:37,459".
- *
- * @param sbuf the StringBuffer
to write to
- */
- @Override
- public StringBuffer format(final Date date, final StringBuffer sbuf, final FieldPosition fieldPosition) {
-
- final long now = date.getTime();
- final int millis = (int) (now % 1000);
-
- if ((now - millis) != lastTime || lastTimeString[0] == 0) {
- // We reach this point at most once per second
- // across all threads instead of each time format()
- // is called. This saves considerable CPU time.
-
- calendar.setTime(date);
-
- final int start = sbuf.length();
-
- final int year = calendar.get(Calendar.YEAR);
- sbuf.append(year);
-
- String month;
- switch (calendar.get(Calendar.MONTH)) {
- case Calendar.JANUARY:
- month = "-01-";
- break;
- case Calendar.FEBRUARY:
- month = "-02-";
- break;
- case Calendar.MARCH:
- month = "-03-";
- break;
- case Calendar.APRIL:
- month = "-04-";
- break;
- case Calendar.MAY:
- month = "-05-";
- break;
- case Calendar.JUNE:
- month = "-06-";
- break;
- case Calendar.JULY:
- month = "-07-";
- break;
- case Calendar.AUGUST:
- month = "-08-";
- break;
- case Calendar.SEPTEMBER:
- month = "-09-";
- break;
- case Calendar.OCTOBER:
- month = "-10-";
- break;
- case Calendar.NOVEMBER:
- month = "-11-";
- break;
- case Calendar.DECEMBER:
- month = "-12-";
- break;
- default:
- month = "-NA-";
- break;
- }
- sbuf.append(month);
-
- final int day = calendar.get(Calendar.DAY_OF_MONTH);
- if (day < 10) {
- sbuf.append('0');
- }
- sbuf.append(day);
-
- sbuf.append(' ');
-
- final int hour = calendar.get(Calendar.HOUR_OF_DAY);
- if (hour < 10) {
- sbuf.append('0');
- }
- sbuf.append(hour);
- sbuf.append(':');
-
- final int mins = calendar.get(Calendar.MINUTE);
- if (mins < 10) {
- sbuf.append('0');
- }
- sbuf.append(mins);
- sbuf.append(':');
-
- final int secs = calendar.get(Calendar.SECOND);
- if (secs < 10) {
- sbuf.append('0');
- }
- sbuf.append(secs);
-
- sbuf.append(',');
-
- // store the time string for next time to avoid recomputation
- sbuf.getChars(start, sbuf.length(), lastTimeString, 0);
- lastTime = now - millis;
- } else {
- sbuf.append(lastTimeString);
- }
-
- if (millis < 100) {
- sbuf.append('0');
- }
- if (millis < 10) {
- sbuf.append('0');
- }
-
- sbuf.append(millis);
- return sbuf;
- }
-
- /**
- * Always returns null.
- */
- @Override
- public Date parse(final String s, final ParsePosition pos) {
- return null;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/Loader.java b/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/Loader.java
deleted file mode 100644
index bf5bb23ec38..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/Loader.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.helpers;
-
-import java.net.URL;
-
-/**
- * Loads resources (or images) from various sources.
- */
-public class Loader {
-
- static final String TSTR = "Caught Exception while in Loader.getResource. This may be innocuous.";
-
- private static boolean ignoreTCL;
-
- static {
- final String ignoreTCLProp = OptionConverter.getSystemProperty("log4j.ignoreTCL", null);
- if (ignoreTCLProp != null) {
- ignoreTCL = OptionConverter.toBoolean(ignoreTCLProp, true);
- }
- }
-
- /**
- * This method will search for resource
in different places. The search order is as follows:
- *
- *
- *
Search for resource
using the thread context class loader under Java2. If that fails, search for
- * resource
using the class loader that loaded this class (Loader
).
- *
- *
- *
Try one last time with ClassLoader.getSystemResource(resource)
.
- *
- *
- */
- public static URL getResource(final String resource) {
- ClassLoader classLoader = null;
- URL url = null;
-
- try {
- if (!ignoreTCL) {
- classLoader = getTCL();
- if (classLoader != null) {
- LogLog.debug("Trying to find [" + resource + "] using context classloader " + classLoader + ".");
- url = classLoader.getResource(resource);
- if (url != null) {
- return url;
- }
- }
- }
-
- // We could not find resource. Ler us now try with the
- // ClassLoader that loaded this class.
- classLoader = Loader.class.getClassLoader();
- if (classLoader != null) {
- LogLog.debug("Trying to find [" + resource + "] using " + classLoader + " class loader.");
- url = classLoader.getResource(resource);
- if (url != null) {
- return url;
- }
- }
- } catch (final Throwable t) {
- // can't be InterruptedException or InterruptedIOException
- // since not declared, must be error or RuntimeError.
- LogLog.warn(TSTR, t);
- }
-
- // Last ditch attempt: get the resource from the class path. It
- // may be the case that clazz was loaded by the Extentsion class
- // loader which the parent of the system class loader. Hence the
- // code below.
- LogLog.debug("Trying to find [" + resource + "] using ClassLoader.getSystemResource().");
- return ClassLoader.getSystemResource(resource);
- }
-
- /**
- * Gets a resource by delegating to getResource(String).
- *
- * @param resource resource name
- * @param clazz class, ignored.
- * @return URL to resource or null.
- * @deprecated as of 1.2.
- */
- @Deprecated
- public static URL getResource(final String resource, final Class clazz) {
- return getResource(resource);
- }
-
- /**
- * Shorthand for {@code Thread.currentThread().getContextClassLoader()}.
- */
- private static ClassLoader getTCL() {
- return Thread.currentThread().getContextClassLoader();
- }
-
- /**
- * Always returns false since Java 1.x support is long gone.
- *
- * @return Always false.
- */
- public static boolean isJava1() {
- return false;
- }
-
- /**
- * Loads the specified class using the Thread
contextClassLoader
, if that fails try
- * Class.forname.
- *
- * @param clazz The class to load.
- * @return The Class.
- * @throws ClassNotFoundException Never thrown, declared for compatibility.
- */
- public static Class loadClass(final String clazz) throws ClassNotFoundException {
- // Just call Class.forName(clazz) if we are instructed to ignore the TCL.
- if (ignoreTCL) {
- return Class.forName(clazz);
- }
- try {
- return getTCL().loadClass(clazz);
- } catch (final Throwable t) {
- // ignore
- }
- return Class.forName(clazz);
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/LogLog.java b/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/LogLog.java
deleted file mode 100644
index 6c33b924987..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/LogLog.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.helpers;
-
-import org.apache.logging.log4j.status.StatusLogger;
-
-/**
- * Logs statements from within Log4j.
- *
- *
- * Log4j components cannot make Log4j logging calls. However, it is sometimes useful for the user to learn about what
- * Log4j is doing. You can enable Log4j internal logging by defining the log4j.configDebug variable.
- *
- *
- * All Log4j internal debug calls go to System.out
where as internal error messages are sent to
- * System.err
. All internal messages are prepended with the string "log4j: ".
- *
- *
- * @since 0.8.2
- */
-public class LogLog {
-
- private static final StatusLogger LOGGER = StatusLogger.getLogger();
-
- /**
- * Makes Log4j print log4j-internal debug statements to System.out
.
- *
- *
- * The value of this string is {@value #DEBUG_KEY}
- *
- *
- * Note that the search for all option names is case sensitive.
- *
- */
- public static final String DEBUG_KEY = "log4j.debug";
-
- /**
- * Makes Log4j components print log4j-internal debug statements to System.out
.
- *
- *
- * The value of this string is {@value #CONFIG_DEBUG_KEY}.
- *
- *
- * Note that the search for all option names is case sensitive.
- *
- *
- * @deprecated Use {@link #DEBUG_KEY} instead.
- */
- @Deprecated
- public static final String CONFIG_DEBUG_KEY = "log4j.configDebug";
-
- /**
- * Debug enabled Enable or disable.
- */
- protected static boolean debugEnabled = false;
-
- /**
- * In quietMode not even errors generate any output.
- */
- private static boolean quietMode = false;
-
- static {
- String key = OptionConverter.getSystemProperty(DEBUG_KEY, null);
- if (key == null) {
- key = OptionConverter.getSystemProperty(CONFIG_DEBUG_KEY, null);
- }
- if (key != null) {
- debugEnabled = OptionConverter.toBoolean(key, true);
- }
- }
-
- /**
- * Logs Log4j internal debug statements.
- *
- * @param message the message object to log.
- */
- public static void debug(final String message) {
- if (debugEnabled && !quietMode) {
- LOGGER.debug(message);
- }
- }
-
- /**
- * Logs Log4j internal debug statements.
- *
- * @param message the message object to log.
- * @param throwable the {@code Throwable} to log, including its stack trace.
- */
- public static void debug(final String message, final Throwable throwable) {
- if (debugEnabled && !quietMode) {
- LOGGER.debug(message, throwable);
- }
- }
-
- /**
- * Logs Log4j internal error statements.
- *
- * @param message the message object to log.
- */
- public static void error(final String message) {
- if (!quietMode) {
- LOGGER.error(message);
- }
- }
-
- /**
- * Logs Log4j internal error statements.
- *
- * @param message the message object to log.
- * @param throwable the {@code Throwable} to log, including its stack trace.
- */
- public static void error(final String message, final Throwable throwable) {
- if (!quietMode) {
- LOGGER.error(message, throwable);
- }
- }
-
- /**
- * Enables and disables Log4j internal logging.
- *
- * @param enabled Enable or disable.
- */
- public static void setInternalDebugging(final boolean enabled) {
- debugEnabled = enabled;
- }
-
- /**
- * In quite mode no LogLog generates strictly no output, not even for errors.
- *
- * @param quietMode A true for not
- */
- public static void setQuietMode(final boolean quietMode) {
- LogLog.quietMode = quietMode;
- }
-
- /**
- * Logs Log4j internal warning statements.
- *
- * @param message the message object to log.
- */
- public static void warn(final String message) {
- if (!quietMode) {
- LOGGER.warn(message);
- }
- }
-
- /**
- * Logs Log4j internal warnings.
- *
- * @param message the message object to log.
- * @param throwable the {@code Throwable} to log, including its stack trace.
- */
- public static void warn(final String message, final Throwable throwable) {
- if (!quietMode) {
- LOGGER.warn(message, throwable);
- }
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/NullEnumeration.java b/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/NullEnumeration.java
deleted file mode 100644
index ff23eac8d92..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/NullEnumeration.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.helpers;
-
-import java.util.Enumeration;
-import java.util.NoSuchElementException;
-
-/**
- * An always-empty Enumerator.
- *
- * @since version 1.0
- */
-@SuppressWarnings("rawtypes")
-public final class NullEnumeration implements Enumeration {
- private static final NullEnumeration INSTANCE = new NullEnumeration();
-
- private NullEnumeration() {}
-
- public static NullEnumeration getInstance() {
- return INSTANCE;
- }
-
- @Override
- public boolean hasMoreElements() {
- return false;
- }
-
- @Override
- public Object nextElement() {
- throw new NoSuchElementException();
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/OptionConverter.java b/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/OptionConverter.java
deleted file mode 100644
index 9d05bc2ebda..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/OptionConverter.java
+++ /dev/null
@@ -1,693 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.helpers;
-
-import static org.apache.logging.log4j.util.Strings.toRootUpperCase;
-
-import java.io.InputStream;
-import java.io.InterruptedIOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import org.apache.log4j.Level;
-import org.apache.log4j.Priority;
-import org.apache.log4j.PropertyConfigurator;
-import org.apache.log4j.spi.Configurator;
-import org.apache.log4j.spi.LoggerRepository;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.spi.StandardLevel;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.util.LoaderUtil;
-import org.apache.logging.log4j.util.PropertiesUtil;
-import org.apache.logging.log4j.util.Strings;
-
-/**
- * A convenience class to convert property values to specific types.
- */
-public final class OptionConverter {
-
- private static class CharMap {
- final char key;
- final char replacement;
-
- public CharMap(final char key, final char replacement) {
- this.key = key;
- this.replacement = replacement;
- }
- }
-
- static String DELIM_START = "${";
- static char DELIM_STOP = '}';
- static int DELIM_START_LEN = 2;
- static int DELIM_STOP_LEN = 1;
- private static final Logger LOGGER = StatusLogger.getLogger();
- /**
- * A Log4j 1.x level above or equal to this value is considered as OFF.
- */
- static final int MAX_CUTOFF_LEVEL =
- Priority.FATAL_INT + 100 * (StandardLevel.FATAL.intLevel() - StandardLevel.OFF.intLevel() - 1) + 1;
- /**
- * A Log4j 1.x level below or equal to this value is considered as ALL.
- *
- * Log4j 2.x ALL to TRACE interval is shorter. This is {@link Priority#ALL_INT}
- * plus the difference.
- */
- static final int MIN_CUTOFF_LEVEL = Priority.ALL_INT
- + Level.TRACE_INT
- - (Priority.ALL_INT + StandardLevel.ALL.intLevel())
- + StandardLevel.TRACE.intLevel();
- /**
- * Cache of currently known levels.
- */
- static final ConcurrentMap LEVELS = new ConcurrentHashMap<>();
- /**
- * Postfix for all Log4j 2.x level names.
- */
- private static final String LOG4J2_LEVEL_CLASS = org.apache.logging.log4j.Level.class.getName();
-
- private static final CharMap[] charMap = new CharMap[] {
- new CharMap('n', '\n'),
- new CharMap('r', '\r'),
- new CharMap('t', '\t'),
- new CharMap('f', '\f'),
- new CharMap('\b', '\b'),
- new CharMap('\"', '\"'),
- new CharMap('\'', '\''),
- new CharMap('\\', '\\')
- };
-
- public static String[] concatanateArrays(final String[] l, final String[] r) {
- final int len = l.length + r.length;
- final String[] a = new String[len];
-
- System.arraycopy(l, 0, a, 0, l.length);
- System.arraycopy(r, 0, a, l.length, r.length);
-
- return a;
- }
-
- static int toLog4j2Level(final int v1Level) {
- // I don't believe anyone uses values much bigger than FATAL
- if (v1Level >= MAX_CUTOFF_LEVEL) {
- return StandardLevel.OFF.intLevel();
- }
- // Linear transformation up to debug: CUTOFF_LEVEL -> OFF, DEBUG -> DEBUG
- if (v1Level > Priority.DEBUG_INT) {
- final int offset = Math.round((v1Level - Priority.DEBUG_INT) / 100.0f);
- return StandardLevel.DEBUG.intLevel() - offset;
- }
- // Steeper linear transformation
- if (v1Level > Level.TRACE_INT) {
- final int offset = Math.round((v1Level - Level.TRACE_INT) / 50.0f);
- return StandardLevel.TRACE.intLevel() - offset;
- }
- if (v1Level > MIN_CUTOFF_LEVEL) {
- final int offset = Level.TRACE_INT - v1Level;
- return StandardLevel.TRACE.intLevel() + offset;
- }
- return StandardLevel.ALL.intLevel();
- }
-
- static int toLog4j1Level(final int v2Level) {
- if (v2Level == StandardLevel.ALL.intLevel()) {
- return Priority.ALL_INT;
- }
- if (v2Level > StandardLevel.TRACE.intLevel()) {
- return MIN_CUTOFF_LEVEL + (StandardLevel.ALL.intLevel() - v2Level);
- }
- // Inflating by 50
- if (v2Level > StandardLevel.DEBUG.intLevel()) {
- return Level.TRACE_INT + 50 * (StandardLevel.TRACE.intLevel() - v2Level);
- }
- // Inflating by 100
- if (v2Level > StandardLevel.OFF.intLevel()) {
- return Priority.DEBUG_INT + 100 * (StandardLevel.DEBUG.intLevel() - v2Level);
- }
- return Priority.OFF_INT;
- }
-
- static int toSyslogLevel(final int v2Level) {
- if (v2Level <= StandardLevel.FATAL.intLevel()) {
- return 0;
- }
- if (v2Level <= StandardLevel.ERROR.intLevel()) {
- return 3
- - (3 * (StandardLevel.ERROR.intLevel() - v2Level))
- / (StandardLevel.ERROR.intLevel() - StandardLevel.FATAL.intLevel());
- }
- if (v2Level <= StandardLevel.WARN.intLevel()) {
- return 4;
- }
- if (v2Level <= StandardLevel.INFO.intLevel()) {
- return 6
- - (2 * (StandardLevel.INFO.intLevel() - v2Level))
- / (StandardLevel.INFO.intLevel() - StandardLevel.WARN.intLevel());
- }
- return 7;
- }
-
- public static org.apache.logging.log4j.Level createLevel(final Priority level) {
- final String name =
- toRootUpperCase(level.toString()) + "#" + level.getClass().getName();
- return org.apache.logging.log4j.Level.forName(name, toLog4j2Level(level.toInt()));
- }
-
- public static org.apache.logging.log4j.Level convertLevel(final Priority level) {
- return level != null ? level.getVersion2Level() : org.apache.logging.log4j.Level.ERROR;
- }
-
- /**
- * @param level
- * @return
- */
- public static Level convertLevel(final org.apache.logging.log4j.Level level) {
- // level is standard or was created by Log4j 1.x custom level
- Level actualLevel = toLevel(level.name(), null);
- // level was created by Log4j 2.x
- if (actualLevel == null) {
- actualLevel = toLevel(LOG4J2_LEVEL_CLASS, level.name(), null);
- }
- return actualLevel != null ? actualLevel : Level.ERROR;
- }
-
- public static org.apache.logging.log4j.Level convertLevel(
- final String level, final org.apache.logging.log4j.Level defaultLevel) {
- final Level actualLevel = toLevel(level, null);
- return actualLevel != null ? actualLevel.getVersion2Level() : defaultLevel;
- }
-
- public static String convertSpecialChars(final String s) {
- char c;
- final int len = s.length();
- final StringBuilder sbuf = new StringBuilder(len);
-
- int i = 0;
- while (i < len) {
- c = s.charAt(i++);
- if (c == '\\') {
- c = s.charAt(i++);
- for (final CharMap entry : charMap) {
- if (entry.key == c) {
- c = entry.replacement;
- }
- }
- }
- sbuf.append(c);
- }
- return sbuf.toString();
- }
-
- /**
- * Find the value corresponding to key
in
- * props
. Then perform variable substitution on the
- * found value.
- * @param key The key used to locate the substitution string.
- * @param props The properties to use in the substitution.
- * @return The substituted string.
- */
- public static String findAndSubst(final String key, final Properties props) {
- final String value = props.getProperty(key);
- if (value == null) {
- return null;
- }
-
- try {
- return substVars(value, props);
- } catch (final IllegalArgumentException e) {
- LOGGER.error("Bad option value [{}].", value, e);
- return value;
- }
- }
-
- /**
- * Very similar to System.getProperty
except
- * that the {@link SecurityException} is hidden.
- *
- * @param key The key to search for.
- * @param def The default value to return.
- * @return the string value of the system property, or the default
- * value if there is no property with that key.
- * @since 1.1
- */
- public static String getSystemProperty(final String key, final String def) {
- try {
- return System.getProperty(key, def);
- } catch (final Throwable e) { // MS-Java throws com.ms.security.SecurityExceptionEx
- LOGGER.debug("Was not allowed to read system property \"{}\".", key);
- return def;
- }
- }
-
- /**
- * Instantiate an object given a class name. Check that the
- * className
is a subclass of
- * superClass
. If that test fails or the object could
- * not be instantiated, then defaultValue
is returned.
- *
- * @param className The fully qualified class name of the object to instantiate.
- * @param superClass The class to which the new object should belong.
- * @param defaultValue The object to return in case of non-fulfillment
- * @return The created object.
- */
- public static Object instantiateByClassName(
- final String className, final Class> superClass, final Object defaultValue) {
- if (className != null) {
- try {
- final Object obj = LoaderUtil.newInstanceOf(className);
- if (!superClass.isAssignableFrom(obj.getClass())) {
- LOGGER.error(
- "A \"{}\" object is not assignable to a \"{}\" variable", className, superClass.getName());
- return defaultValue;
- }
- return obj;
- } catch (final ReflectiveOperationException e) {
- LOGGER.error("Could not instantiate class [" + className + "].", e);
- }
- }
- return defaultValue;
- }
-
- public static Object instantiateByKey(
- final Properties props, final String key, final Class superClass, final Object defaultValue) {
-
- // Get the value of the property in string form
- final String className = findAndSubst(key, props);
- if (className == null) {
- LogLog.error("Could not find value for key " + key);
- return defaultValue;
- }
- // Trim className to avoid trailing spaces that cause problems.
- return OptionConverter.instantiateByClassName(className.trim(), superClass, defaultValue);
- }
-
- /**
- * Configure log4j given an {@link InputStream}.
- *
- * The InputStream will be interpreted by a new instance of a log4j configurator.
- *
- *
- * All configurations steps are taken on the hierarchy
passed as a parameter.
- *
- *
- * @param inputStream The configuration input stream.
- * @param clazz The class name, of the log4j configurator which will parse the inputStream
. This must be a
- * subclass of {@link Configurator}, or null. If this value is null then a default configurator of
- * {@link PropertyConfigurator} is used.
- * @param hierarchy The {@link LoggerRepository} to act on.
- * @since 1.2.17
- */
- public static void selectAndConfigure(
- final InputStream inputStream, final String clazz, final LoggerRepository hierarchy) {
- Configurator configurator = null;
-
- if (clazz != null) {
- LOGGER.debug("Preferred configurator class: " + clazz);
- configurator = (Configurator) instantiateByClassName(clazz, Configurator.class, null);
- if (configurator == null) {
- LOGGER.error("Could not instantiate configurator [" + clazz + "].");
- return;
- }
- } else {
- configurator = new PropertyConfigurator();
- }
-
- configurator.doConfigure(inputStream, hierarchy);
- }
-
- /**
- * Configure log4j given a URL.
- *
- * The url must point to a file or resource which will be interpreted by a new instance of a log4j configurator.
- *
- *
- * All configurations steps are taken on the hierarchy
passed as a parameter.
- *
- *
- * @param url The location of the configuration file or resource.
- * @param clazz The classname, of the log4j configurator which will parse the file or resource at url
. This
- * must be a subclass of {@link Configurator}, or null. If this value is null then a default configurator of
- * {@link PropertyConfigurator} is used, unless the filename pointed to by url
ends in '.xml', in
- * which case {@link org.apache.log4j.xml.DOMConfigurator} is used.
- * @param hierarchy The {@link LoggerRepository} to act on.
- *
- * @since 1.1.4
- */
- public static void selectAndConfigure(final URL url, String clazz, final LoggerRepository hierarchy) {
- Configurator configurator = null;
- final String filename = url.getFile();
-
- if (clazz == null && filename != null && filename.endsWith(".xml")) {
- clazz = "org.apache.log4j.xml.DOMConfigurator";
- }
-
- if (clazz != null) {
- LOGGER.debug("Preferred configurator class: " + clazz);
- configurator = (Configurator) instantiateByClassName(clazz, Configurator.class, null);
- if (configurator == null) {
- LOGGER.error("Could not instantiate configurator [" + clazz + "].");
- return;
- }
- } else {
- configurator = new PropertyConfigurator();
- }
-
- configurator.doConfigure(url, hierarchy);
- }
-
- /**
- * Perform variable substitution in string val
from the
- * values of keys found in the system propeties.
- *
- * The variable substitution delimeters are ${ and } .
- *
- *
For example, if the System properties contains "key=value", then
- * the call
- *
- * String s = OptionConverter.substituteVars("Value of key is ${key}.");
- *
- *
- * will set the variable s
to "Value of key is value.".
- *
- *
If no value could be found for the specified key, then the
- * props
parameter is searched, if the value could not
- * be found there, then substitution defaults to the empty string.
- *
- *
For example, if system propeties contains no value for the key
- * "inexistentKey", then the call
- *
- *
- * String s = OptionConverter.subsVars("Value of inexistentKey is [${inexistentKey}]");
- *
- * will set s
to "Value of inexistentKey is []"
- *
- * An {@link IllegalArgumentException} is thrown if
- * val
contains a start delimeter "${" which is not
- * balanced by a stop delimeter "}".
- *
- * Author Avy Sharell
- *
- * @param val The string on which variable substitution is performed.
- * @param props The properties to use for the substitution.
- * @return The substituted string.
- * @throws IllegalArgumentException if val
is malformed.
- */
- public static String substVars(final String val, final Properties props) throws IllegalArgumentException {
- return substVars(val, props, new ArrayList<>());
- }
-
- private static String substVars(final String val, final Properties props, final List keys)
- throws IllegalArgumentException {
- if (val == null) {
- return null;
- }
- final StringBuilder sbuf = new StringBuilder();
-
- int i = 0;
- int j;
- int k;
-
- while (true) {
- j = val.indexOf(DELIM_START, i);
- if (j == -1) {
- // no more variables
- if (i == 0) { // this is a simple string
- return val;
- }
- // add the tail string which contails no variables and return the result.
- sbuf.append(val.substring(i));
- return sbuf.toString();
- }
- sbuf.append(val.substring(i, j));
- k = val.indexOf(DELIM_STOP, j);
- if (k == -1) {
- throw new IllegalArgumentException(
- Strings.dquote(val) + " has no closing brace. Opening brace at position " + j + '.');
- }
- j += DELIM_START_LEN;
- final String key = val.substring(j, k);
- // first try in System properties
- // We intentionally use PropertiesUtil here to retrieve properties not
- // prefixed by "log4j."
- String replacement = PropertiesUtil.getProperties().getStringProperty(key, null);
- // then try props parameter
- if (replacement == null && props != null) {
- replacement = props.getProperty(key);
- }
-
- if (replacement != null) {
-
- // Do variable substitution on the replacement string
- // such that we can solve "Hello ${x2}" as "Hello p1"
- // the where the properties are
- // x1=p1
- // x2=${x1}
- if (!keys.contains(key)) {
- final List usedKeys = new ArrayList<>(keys);
- usedKeys.add(key);
- final String recursiveReplacement = substVars(replacement, props, usedKeys);
- sbuf.append(recursiveReplacement);
- } else {
- sbuf.append(replacement);
- }
- }
- i = k + DELIM_STOP_LEN;
- }
- }
-
- /**
- * If value
is "true", then true
is
- * returned. If value
is "false", then
- * true
is returned. Otherwise, default
is
- * returned.
- *
- * Case of value is unimportant.
- * @param value The value to convert.
- * @param dEfault The default value.
- * @return the value of the result.
- */
- public static boolean toBoolean(final String value, final boolean dEfault) {
- if (value == null) {
- return dEfault;
- }
- final String trimmedVal = value.trim();
- if ("true".equalsIgnoreCase(trimmedVal)) {
- return true;
- }
- if ("false".equalsIgnoreCase(trimmedVal)) {
- return false;
- }
- return dEfault;
- }
-
- public static long toFileSize(final String value, final long defaultValue) {
- if (value == null) {
- return defaultValue;
- }
-
- String s = toRootUpperCase(value.trim());
- long multiplier = 1;
- int index;
-
- if ((index = s.indexOf("KB")) != -1) {
- multiplier = 1024;
- s = s.substring(0, index);
- } else if ((index = s.indexOf("MB")) != -1) {
- multiplier = 1024 * 1024;
- s = s.substring(0, index);
- } else if ((index = s.indexOf("GB")) != -1) {
- multiplier = 1024 * 1024 * 1024;
- s = s.substring(0, index);
- }
- if (s != null) {
- try {
- return Long.valueOf(s).longValue() * multiplier;
- } catch (final NumberFormatException e) {
- LogLog.error("[" + s + "] is not in proper int form.");
- LogLog.error("[" + value + "] not in expected format.", e);
- }
- }
- return defaultValue;
- }
-
- public static int toInt(final String value, final int dEfault) {
- if (value != null) {
- final String s = value.trim();
- try {
- return Integer.valueOf(s).intValue();
- } catch (final NumberFormatException e) {
- LogLog.error("[" + s + "] is not in proper int form.");
- e.printStackTrace();
- }
- }
- return dEfault;
- }
-
- /**
- * Converts a standard or custom priority level to a Level object.
- *
- * If value
is of form "level#classname", then the specified class'
- * toLevel method is called to process the specified level string; if no '#'
- * character is present, then the default {@link org.apache.log4j.Level} class
- * is used to process the level value.
- *
- *
- *
- * As a special case, if the value
parameter is equal to the string
- * "NULL", then the value null
will be returned.
- *
- *
- *
- * As a Log4j 2.x extension, a {@code value}
- * "level#org.apache.logging.log4j.Level" retrieves the corresponding custom
- * Log4j 2.x level.
- *
- *
- *
- * If any error occurs while converting the value to a level, the
- * defaultValue
parameter, which may be null
, is
- * returned.
- *
- *
- *
- * Case of value
is insignificant for the level, but is
- * significant for the class name part, if present.
- *
- *
- * @param value The value to convert.
- * @param defaultValue The default value.
- * @return the value of the result.
- *
- * @since 1.1
- */
- public static Level toLevel(String value, final Level defaultValue) {
- if (value == null) {
- return defaultValue;
- }
-
- value = value.trim();
- final Level cached = LEVELS.get(value);
- if (cached != null) {
- return cached;
- }
-
- final int hashIndex = value.indexOf('#');
- if (hashIndex == -1) {
- if ("NULL".equalsIgnoreCase(value)) {
- return null;
- }
- // no class name specified : use standard Level class
- final Level standardLevel = Level.toLevel(value, defaultValue);
- if (standardLevel != null && value.equals(standardLevel.toString())) {
- LEVELS.putIfAbsent(value, standardLevel);
- }
- return standardLevel;
- }
-
- final String clazz = value.substring(hashIndex + 1);
- final String levelName = value.substring(0, hashIndex);
-
- final Level customLevel = toLevel(clazz, levelName, defaultValue);
- if (customLevel != null
- && levelName.equals(customLevel.toString())
- && clazz.equals(customLevel.getClass().getName())) {
- LEVELS.putIfAbsent(value, customLevel);
- }
- return customLevel;
- }
-
- /**
- * Converts a custom priority level to a Level object.
- *
- *
- * If {@code clazz} has the special value "org.apache.logging.log4j.Level" a
- * wrapper of the corresponding Log4j 2.x custom level object is returned.
- *
- *
- * @param clazz a custom level class,
- * @param levelName the name of the level,
- * @param defaultValue the value to return in case an error occurs,
- * @return the value of the result.
- */
- public static Level toLevel(final String clazz, final String levelName, final Level defaultValue) {
-
- // This is degenerate case but you never know.
- if ("NULL".equalsIgnoreCase(levelName)) {
- return null;
- }
-
- LOGGER.debug("toLevel" + ":class=[" + clazz + "]" + ":pri=[" + levelName + "]");
-
- // Support for levels defined in Log4j2.
- if (LOG4J2_LEVEL_CLASS.equals(clazz)) {
- final org.apache.logging.log4j.Level v2Level =
- org.apache.logging.log4j.Level.getLevel(toRootUpperCase(levelName));
- if (v2Level != null) {
- return new LevelWrapper(v2Level);
- }
- return defaultValue;
- }
- try {
- final Class> customLevel = LoaderUtil.loadClass(clazz);
-
- // get a ref to the specified class' static method
- // toLevel(String, org.apache.log4j.Level)
- final Class>[] paramTypes = new Class[] {String.class, org.apache.log4j.Level.class};
- final java.lang.reflect.Method toLevelMethod = customLevel.getMethod("toLevel", paramTypes);
-
- // now call the toLevel method, passing level string + default
- final Object[] params = new Object[] {levelName, defaultValue};
- final Object o = toLevelMethod.invoke(null, params);
-
- return (Level) o;
- } catch (final ClassNotFoundException e) {
- LOGGER.warn("custom level class [" + clazz + "] not found.");
- } catch (final NoSuchMethodException e) {
- LOGGER.warn(
- "custom level class [" + clazz + "]" + " does not have a class function toLevel(String, Level)", e);
- } catch (final java.lang.reflect.InvocationTargetException e) {
- if (e.getTargetException() instanceof InterruptedException
- || e.getTargetException() instanceof InterruptedIOException) {
- Thread.currentThread().interrupt();
- }
- LOGGER.warn("custom level class [" + clazz + "]" + " could not be instantiated", e);
- } catch (final ClassCastException e) {
- LOGGER.warn("class [" + clazz + "] is not a subclass of org.apache.log4j.Level", e);
- } catch (final IllegalAccessException e) {
- LOGGER.warn("class [" + clazz + "] cannot be instantiated due to access restrictions", e);
- } catch (final RuntimeException e) {
- LOGGER.warn("class [" + clazz + "], level [" + levelName + "] conversion failed.", e);
- }
- return defaultValue;
- }
-
- /**
- * OptionConverter is a static class.
- */
- private OptionConverter() {}
-
- private static class LevelWrapper extends Level {
-
- private static final long serialVersionUID = -7693936267612508528L;
-
- protected LevelWrapper(final org.apache.logging.log4j.Level v2Level) {
- super(toLog4j1Level(v2Level.intLevel()), v2Level.name(), toSyslogLevel(v2Level.intLevel()), v2Level);
- }
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/PatternConverter.java b/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/PatternConverter.java
deleted file mode 100644
index be5be195d12..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/PatternConverter.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.helpers;
-
-import org.apache.log4j.spi.LoggingEvent;
-
-/**
- *
- * PatternConverter is an abtract class that provides the
- * formatting functionality that derived classes need.
- *
- *
Conversion specifiers in a conversion patterns are parsed to
- * individual PatternConverters. Each of which is responsible for
- * converting a logging event in a converter specific manner.
- *
- * @author James P. Cakalic
- * @author Ceki Gülcü
- *
- * @since 0.8.2
- */
-public abstract class PatternConverter {
- public PatternConverter next;
- int min = -1;
- int max = 0x7FFFFFFF;
- boolean leftAlign = false;
-
- protected PatternConverter() {}
-
- protected PatternConverter(final FormattingInfo fi) {
- min = fi.min;
- max = fi.max;
- leftAlign = fi.leftAlign;
- }
-
- /**
- * Derived pattern converters must override this method in order to
- * convert conversion specifiers in the correct way.
- */
- protected abstract String convert(LoggingEvent event);
-
- /**
- * A template method for formatting in a converter specific way.
- */
- public void format(final StringBuffer sbuf, final LoggingEvent e) {
- final String s = convert(e);
-
- if (s == null) {
- if (0 < min) spacePad(sbuf, min);
- return;
- }
-
- final int len = s.length();
-
- if (len > max) sbuf.append(s.substring(len - max));
- else if (len < min) {
- if (leftAlign) {
- sbuf.append(s);
- spacePad(sbuf, min - len);
- } else {
- spacePad(sbuf, min - len);
- sbuf.append(s);
- }
- } else sbuf.append(s);
- }
-
- static String[] SPACES = {
- " ",
- " ",
- " ",
- " ", // 1,2,4,8 spaces
- " ", // 16 spaces
- " "
- }; // 32 spaces
-
- /**
- * Fast space padding method.
- */
- public void spacePad(final StringBuffer sbuf, final int length) {
- int l = length;
- while (l >= 32) {
- sbuf.append(SPACES[5]);
- l -= 32;
- }
-
- for (int i = 4; i >= 0; i--) {
- if ((l & (1 << i)) != 0) {
- sbuf.append(SPACES[i]);
- }
- }
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/PatternParser.java b/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/PatternParser.java
deleted file mode 100644
index 8e01c07e78e..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/PatternParser.java
+++ /dev/null
@@ -1,517 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.helpers;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.Map;
-import org.apache.log4j.Layout;
-import org.apache.log4j.spi.LocationInfo;
-import org.apache.log4j.spi.LoggingEvent;
-
-// Contributors: Nelson Minar <(nelson@monkey.org>
-// Igor E. Poteryaev
-// Reinhard Deschler
-
-/**
- * Most of the work of the {@link org.apache.log4j.PatternLayout} class is delegated to the PatternParser class.
- *
- *
- * It is this class that parses conversion patterns and creates a chained list of {@link OptionConverter
- * OptionConverters}.
- *
- * @author James P. Cakalic
- * @author Ceki Gülcü
- * @author Anders Kristensen
- *
- * @since 0.8.2
- */
-public class PatternParser {
-
- private static final char ESCAPE_CHAR = '%';
-
- private static final int LITERAL_STATE = 0;
- private static final int CONVERTER_STATE = 1;
- private static final int DOT_STATE = 3;
- private static final int MIN_STATE = 4;
- private static final int MAX_STATE = 5;
-
- static final int FULL_LOCATION_CONVERTER = 1000;
- static final int METHOD_LOCATION_CONVERTER = 1001;
- static final int CLASS_LOCATION_CONVERTER = 1002;
- static final int LINE_LOCATION_CONVERTER = 1003;
- static final int FILE_LOCATION_CONVERTER = 1004;
-
- static final int RELATIVE_TIME_CONVERTER = 2000;
- static final int THREAD_CONVERTER = 2001;
- static final int LEVEL_CONVERTER = 2002;
- static final int NDC_CONVERTER = 2003;
- static final int MESSAGE_CONVERTER = 2004;
-
- int state;
- protected StringBuffer currentLiteral = new StringBuffer(32);
- protected int patternLength;
- protected int i;
- PatternConverter head;
- PatternConverter tail;
- protected FormattingInfo formattingInfo = new FormattingInfo();
- protected String pattern;
-
- public PatternParser(final String pattern) {
- this.pattern = pattern;
- patternLength = pattern.length();
- state = LITERAL_STATE;
- }
-
- private void addToList(PatternConverter pc) {
- if (head == null) {
- head = tail = pc;
- } else {
- tail.next = pc;
- tail = pc;
- }
- }
-
- protected String extractOption() {
- if ((i < patternLength) && (pattern.charAt(i) == '{')) {
- final int end = pattern.indexOf('}', i);
- if (end > i) {
- final String r = pattern.substring(i + 1, end);
- i = end + 1;
- return r;
- }
- }
- return null;
- }
-
- /**
- * The option is expected to be in decimal and positive. In case of error, zero is returned.
- */
- protected int extractPrecisionOption() {
- final String opt = extractOption();
- int r = 0;
- if (opt != null) {
- try {
- r = Integer.parseInt(opt);
- if (r <= 0) {
- LogLog.error("Precision option (" + opt + ") isn't a positive integer.");
- r = 0;
- }
- } catch (NumberFormatException e) {
- LogLog.error("Category option \"" + opt + "\" not a decimal integer.", e);
- }
- }
- return r;
- }
-
- public PatternConverter parse() {
- char c;
- i = 0;
- while (i < patternLength) {
- c = pattern.charAt(i++);
- switch (state) {
- case LITERAL_STATE:
- // In literal state, the last char is always a literal.
- if (i == patternLength) {
- currentLiteral.append(c);
- continue;
- }
- if (c == ESCAPE_CHAR) {
- // peek at the next char.
- switch (pattern.charAt(i)) {
- case ESCAPE_CHAR:
- currentLiteral.append(c);
- i++; // move pointer
- break;
- case 'n':
- currentLiteral.append(Layout.LINE_SEP);
- i++; // move pointer
- break;
- default:
- if (currentLiteral.length() != 0) {
- addToList(new LiteralPatternConverter(currentLiteral.toString()));
- // LogLog.debug("Parsed LITERAL converter: \""
- // +currentLiteral+"\".");
- }
- currentLiteral.setLength(0);
- currentLiteral.append(c); // append %
- state = CONVERTER_STATE;
- formattingInfo.reset();
- }
- } else {
- currentLiteral.append(c);
- }
- break;
- case CONVERTER_STATE:
- currentLiteral.append(c);
- switch (c) {
- case '-':
- formattingInfo.leftAlign = true;
- break;
- case '.':
- state = DOT_STATE;
- break;
- default:
- if (c >= '0' && c <= '9') {
- formattingInfo.min = c - '0';
- state = MIN_STATE;
- } else finalizeConverter(c);
- } // switch
- break;
- case MIN_STATE:
- currentLiteral.append(c);
- if (c >= '0' && c <= '9') formattingInfo.min = formattingInfo.min * 10 + (c - '0');
- else if (c == '.') state = DOT_STATE;
- else {
- finalizeConverter(c);
- }
- break;
- case DOT_STATE:
- currentLiteral.append(c);
- if (c >= '0' && c <= '9') {
- formattingInfo.max = c - '0';
- state = MAX_STATE;
- } else {
- LogLog.error("Error occured in position " + i + ".\n Was expecting digit, instead got char \""
- + c + "\".");
- state = LITERAL_STATE;
- }
- break;
- case MAX_STATE:
- currentLiteral.append(c);
- if (c >= '0' && c <= '9') formattingInfo.max = formattingInfo.max * 10 + (c - '0');
- else {
- finalizeConverter(c);
- state = LITERAL_STATE;
- }
- break;
- } // switch
- } // while
- if (currentLiteral.length() != 0) {
- addToList(new LiteralPatternConverter(currentLiteral.toString()));
- // LogLog.debug("Parsed LITERAL converter: \""+currentLiteral+"\".");
- }
- return head;
- }
-
- protected void finalizeConverter(char c) {
- PatternConverter pc = null;
- switch (c) {
- case 'c':
- pc = new CategoryPatternConverter(formattingInfo, extractPrecisionOption());
- // LogLog.debug("CATEGORY converter.");
- // formattingInfo.dump();
- currentLiteral.setLength(0);
- break;
- case 'C':
- pc = new ClassNamePatternConverter(formattingInfo, extractPrecisionOption());
- // LogLog.debug("CLASS_NAME converter.");
- // formattingInfo.dump();
- currentLiteral.setLength(0);
- break;
- case 'd':
- String dateFormatStr = AbsoluteTimeDateFormat.ISO8601_DATE_FORMAT;
- DateFormat df;
- final String dOpt = extractOption();
- if (dOpt != null) dateFormatStr = dOpt;
-
- if (dateFormatStr.equalsIgnoreCase(AbsoluteTimeDateFormat.ISO8601_DATE_FORMAT))
- df = new ISO8601DateFormat();
- else if (dateFormatStr.equalsIgnoreCase(AbsoluteTimeDateFormat.ABS_TIME_DATE_FORMAT))
- df = new AbsoluteTimeDateFormat();
- else if (dateFormatStr.equalsIgnoreCase(AbsoluteTimeDateFormat.DATE_AND_TIME_DATE_FORMAT))
- df = new DateTimeDateFormat();
- else {
- try {
- df = new SimpleDateFormat(dateFormatStr);
- } catch (IllegalArgumentException e) {
- LogLog.error("Could not instantiate SimpleDateFormat with " + dateFormatStr, e);
- df = (DateFormat) OptionConverter.instantiateByClassName(
- "org.apache.log4j.helpers.ISO8601DateFormat", DateFormat.class, null);
- }
- }
- pc = new DatePatternConverter(formattingInfo, df);
- // LogLog.debug("DATE converter {"+dateFormatStr+"}.");
- // formattingInfo.dump();
- currentLiteral.setLength(0);
- break;
- case 'F':
- pc = new LocationPatternConverter(formattingInfo, FILE_LOCATION_CONVERTER);
- // LogLog.debug("File name converter.");
- // formattingInfo.dump();
- currentLiteral.setLength(0);
- break;
- case 'l':
- pc = new LocationPatternConverter(formattingInfo, FULL_LOCATION_CONVERTER);
- // LogLog.debug("Location converter.");
- // formattingInfo.dump();
- currentLiteral.setLength(0);
- break;
- case 'L':
- pc = new LocationPatternConverter(formattingInfo, LINE_LOCATION_CONVERTER);
- // LogLog.debug("LINE NUMBER converter.");
- // formattingInfo.dump();
- currentLiteral.setLength(0);
- break;
- case 'm':
- pc = new BasicPatternConverter(formattingInfo, MESSAGE_CONVERTER);
- // LogLog.debug("MESSAGE converter.");
- // formattingInfo.dump();
- currentLiteral.setLength(0);
- break;
- case 'M':
- pc = new LocationPatternConverter(formattingInfo, METHOD_LOCATION_CONVERTER);
- // LogLog.debug("METHOD converter.");
- // formattingInfo.dump();
- currentLiteral.setLength(0);
- break;
- case 'p':
- pc = new BasicPatternConverter(formattingInfo, LEVEL_CONVERTER);
- // LogLog.debug("LEVEL converter.");
- // formattingInfo.dump();
- currentLiteral.setLength(0);
- break;
- case 'r':
- pc = new BasicPatternConverter(formattingInfo, RELATIVE_TIME_CONVERTER);
- // LogLog.debug("RELATIVE time converter.");
- // formattingInfo.dump();
- currentLiteral.setLength(0);
- break;
- case 't':
- pc = new BasicPatternConverter(formattingInfo, THREAD_CONVERTER);
- // LogLog.debug("THREAD converter.");
- // formattingInfo.dump();
- currentLiteral.setLength(0);
- break;
- /*
- * case 'u': if(i < patternLength) { char cNext = pattern.charAt(i); if(cNext >= '0' && cNext <= '9') { pc = new
- * UserFieldPatternConverter(formattingInfo, cNext - '0'); LogLog.debug("USER converter ["+cNext+"].");
- * formattingInfo.dump(); currentLiteral.setLength(0); i++; } else LogLog.error("Unexpected char"
- * +cNext+" at position "+i); } break;
- */
- case 'x':
- pc = new BasicPatternConverter(formattingInfo, NDC_CONVERTER);
- // LogLog.debug("NDC converter.");
- currentLiteral.setLength(0);
- break;
- case 'X':
- final String xOpt = extractOption();
- pc = new MDCPatternConverter(formattingInfo, xOpt);
- currentLiteral.setLength(0);
- break;
- default:
- LogLog.error("Unexpected char [" + c + "] at position " + i + " in conversion patterrn.");
- pc = new LiteralPatternConverter(currentLiteral.toString());
- currentLiteral.setLength(0);
- }
-
- addConverter(pc);
- }
-
- protected void addConverter(PatternConverter pc) {
- currentLiteral.setLength(0);
- // Add the pattern converter to the list.
- addToList(pc);
- // Next pattern is assumed to be a literal.
- state = LITERAL_STATE;
- // Reset formatting info
- formattingInfo.reset();
- }
-
- // ---------------------------------------------------------------------
- // PatternConverters
- // ---------------------------------------------------------------------
-
- private static class BasicPatternConverter extends PatternConverter {
- int type;
-
- BasicPatternConverter(final FormattingInfo formattingInfo, final int type) {
- super(formattingInfo);
- this.type = type;
- }
-
- public String convert(final LoggingEvent event) {
- switch (type) {
- case RELATIVE_TIME_CONVERTER:
- return (Long.toString(event.timeStamp - LoggingEvent.getStartTime()));
- case THREAD_CONVERTER:
- return event.getThreadName();
- case LEVEL_CONVERTER:
- return event.getLevel().toString();
- case NDC_CONVERTER:
- return event.getNDC();
- case MESSAGE_CONVERTER: {
- return event.getRenderedMessage();
- }
- default:
- return null;
- }
- }
- }
-
- private static class LiteralPatternConverter extends PatternConverter {
- private String literal;
-
- LiteralPatternConverter(final String value) {
- literal = value;
- }
-
- public final void format(final StringBuffer sbuf, final LoggingEvent event) {
- sbuf.append(literal);
- }
-
- public String convert(final LoggingEvent event) {
- return literal;
- }
- }
-
- private static class DatePatternConverter extends PatternConverter {
- private DateFormat df;
- private Date date;
-
- DatePatternConverter(final FormattingInfo formattingInfo, final DateFormat df) {
- super(formattingInfo);
- date = new Date();
- this.df = df;
- }
-
- public String convert(final LoggingEvent event) {
- date.setTime(event.timeStamp);
- String converted = null;
- try {
- converted = df.format(date);
- } catch (Exception ex) {
- LogLog.error("Error occured while converting date.", ex);
- }
- return converted;
- }
- }
-
- private static class MDCPatternConverter extends PatternConverter {
- private String key;
-
- MDCPatternConverter(final FormattingInfo formattingInfo, final String key) {
- super(formattingInfo);
- this.key = key;
- }
-
- public String convert(final LoggingEvent event) {
- if (key == null) {
- final StringBuffer buf = new StringBuffer("{");
- final Map properties = event.getProperties();
- if (properties.size() > 0) {
- final Object[] keys = properties.keySet().toArray();
- Arrays.sort(keys);
- for (int i = 0; i < keys.length; i++) {
- buf.append('{');
- buf.append(keys[i]);
- buf.append(',');
- buf.append(properties.get(keys[i]));
- buf.append('}');
- }
- }
- buf.append('}');
- return buf.toString();
- } else {
- final Object val = event.getMDC(key);
- if (val == null) {
- return null;
- } else {
- return val.toString();
- }
- }
- }
- }
-
- private class LocationPatternConverter extends PatternConverter {
- int type;
-
- LocationPatternConverter(final FormattingInfo formattingInfo, final int type) {
- super(formattingInfo);
- this.type = type;
- }
-
- public String convert(final LoggingEvent event) {
- final LocationInfo locationInfo = event.getLocationInformation();
- switch (type) {
- case FULL_LOCATION_CONVERTER:
- return locationInfo.fullInfo;
- case METHOD_LOCATION_CONVERTER:
- return locationInfo.getMethodName();
- case LINE_LOCATION_CONVERTER:
- return locationInfo.getLineNumber();
- case FILE_LOCATION_CONVERTER:
- return locationInfo.getFileName();
- default:
- return null;
- }
- }
- }
-
- private abstract static class NamedPatternConverter extends PatternConverter {
- int precision;
-
- NamedPatternConverter(final FormattingInfo formattingInfo, final int precision) {
- super(formattingInfo);
- this.precision = precision;
- }
-
- abstract String getFullyQualifiedName(LoggingEvent event);
-
- public String convert(final LoggingEvent event) {
- final String n = getFullyQualifiedName(event);
- if (precision <= 0) return n;
- else {
- final int len = n.length();
-
- // We substract 1 from 'len' when assigning to 'end' to avoid out of
- // bounds exception in return r.substring(end+1, len). This can happen if
- // precision is 1 and the category name ends with a dot.
- int end = len - 1;
- for (int i = precision; i > 0; i--) {
- end = n.lastIndexOf('.', end - 1);
- if (end == -1) return n;
- }
- return n.substring(end + 1, len);
- }
- }
- }
-
- private class ClassNamePatternConverter extends NamedPatternConverter {
-
- ClassNamePatternConverter(final FormattingInfo formattingInfo, final int precision) {
- super(formattingInfo, precision);
- }
-
- String getFullyQualifiedName(final LoggingEvent event) {
- return event.getLocationInformation().getClassName();
- }
- }
-
- private class CategoryPatternConverter extends NamedPatternConverter {
-
- CategoryPatternConverter(final FormattingInfo formattingInfo, final int precision) {
- super(formattingInfo, precision);
- }
-
- String getFullyQualifiedName(final LoggingEvent event) {
- return event.getLoggerName();
- }
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/QuietWriter.java b/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/QuietWriter.java
deleted file mode 100644
index f9dc6fb7871..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/QuietWriter.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.helpers;
-
-import java.io.FilterWriter;
-import java.io.Writer;
-import org.apache.log4j.spi.ErrorCode;
-import org.apache.log4j.spi.ErrorHandler;
-
-/**
- * QuietWriter does not throw exceptions when things go
- * wrong. Instead, it delegates error handling to its {@link ErrorHandler}.
- */
-public class QuietWriter extends FilterWriter {
-
- protected ErrorHandler errorHandler;
-
- public QuietWriter(final Writer writer, final ErrorHandler errorHandler) {
- super(writer);
- setErrorHandler(errorHandler);
- }
-
- @Override
- public void write(final String string) {
- if (string != null) {
- try {
- out.write(string);
- } catch (Exception e) {
- errorHandler.error("Failed to write [" + string + "].", e, ErrorCode.WRITE_FAILURE);
- }
- }
- }
-
- @Override
- public void flush() {
- try {
- out.flush();
- } catch (Exception e) {
- errorHandler.error("Failed to flush writer,", e, ErrorCode.FLUSH_FAILURE);
- }
- }
-
- public void setErrorHandler(final ErrorHandler eh) {
- if (eh == null) {
- // This is a programming error on the part of the enclosing appender.
- throw new IllegalArgumentException("Attempted to set null ErrorHandler.");
- }
- this.errorHandler = eh;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/RelativeTimeDateFormat.java b/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/RelativeTimeDateFormat.java
deleted file mode 100644
index 498e014a2a4..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/RelativeTimeDateFormat.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.helpers;
-
-import java.text.DateFormat;
-import java.text.FieldPosition;
-import java.text.ParsePosition;
-import java.util.Date;
-
-/**
- * Formats a {@link Date} by printing the number of milliseconds elapsed since construction of the format. This is the
- * fastest printing DateFormat in the package.
- *
- * @since 0.7.5
- */
-public class RelativeTimeDateFormat extends DateFormat {
-
- private static final long serialVersionUID = 7055751607085611984L;
-
- protected final long startTime;
-
- public RelativeTimeDateFormat() {
- this.startTime = System.currentTimeMillis();
- }
-
- /**
- * Appends to sbuf
the number of milliseconds elapsed since the start of the application.
- *
- * @since 0.7.5
- */
- @Override
- public StringBuffer format(final Date date, final StringBuffer sbuf, final FieldPosition fieldPosition) {
- // System.err.println(":"+ date.getTime() + " - " + startTime);
- return sbuf.append((date.getTime() - startTime));
- }
-
- /**
- * Always returns null.
- */
- @Override
- public Date parse(final String s, final ParsePosition pos) {
- return null;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/UtilLoggingLevel.java b/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/UtilLoggingLevel.java
deleted file mode 100644
index 2eab2e81a43..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/UtilLoggingLevel.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.helpers;
-
-import static org.apache.logging.log4j.util.Strings.toRootUpperCase;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.log4j.Level;
-
-/**
- * An extension of the Level class that provides support for java.util.logging Levels.
- */
-public class UtilLoggingLevel extends Level {
-
- /**
- * Serialization version id.
- */
- private static final long serialVersionUID = 909301162611820211L;
-
- /**
- * Numerical value for SEVERE.
- */
- public static final int SEVERE_INT = 22000;
- /**
- * Numerical value for WARNING.
- */
- public static final int WARNING_INT = 21000;
-
- // INFO level defined in parent as 20000..no need to redefine here
-
- /**
- * Numerical value for CONFIG.
- */
- public static final int CONFIG_INT = 14000;
-
- /**
- * Numerical value for FINE.
- */
- public static final int FINE_INT = 13000;
-
- /**
- * Numerical value for FINER.
- */
- public static final int FINER_INT = 12000;
-
- /**
- * Numerical value for FINEST.
- */
- public static final int FINEST_INT = 11000;
-
- /**
- * Numerical value for UNKNOWN.
- */
- public static final int UNKNOWN_INT = 10000;
-
- /**
- * SEVERE.
- */
- public static final UtilLoggingLevel SEVERE = new UtilLoggingLevel(SEVERE_INT, "SEVERE", 0);
-
- /**
- * WARNING.
- */
- public static final UtilLoggingLevel WARNING = new UtilLoggingLevel(WARNING_INT, "WARNING", 4);
-
- /**
- * INFO.
- */
- // note: we've aligned the int values of the java.util.logging INFO level with log4j's level
- public static final UtilLoggingLevel INFO = new UtilLoggingLevel(INFO_INT, "INFO", 5);
-
- /**
- * CONFIG.
- */
- public static final UtilLoggingLevel CONFIG = new UtilLoggingLevel(CONFIG_INT, "CONFIG", 6);
-
- /**
- * FINE.
- */
- public static final UtilLoggingLevel FINE = new UtilLoggingLevel(FINE_INT, "FINE", 7);
-
- /**
- * FINER.
- */
- public static final UtilLoggingLevel FINER = new UtilLoggingLevel(FINER_INT, "FINER", 8);
-
- /**
- * FINEST.
- */
- public static final UtilLoggingLevel FINEST = new UtilLoggingLevel(FINEST_INT, "FINEST", 9);
-
- /**
- * Create new instance.
- *
- * @param level numeric value for level.
- * @param levelStr symbolic name for level.
- * @param syslogEquivalent Equivalent syslog severity.
- */
- protected UtilLoggingLevel(final int level, final String levelStr, final int syslogEquivalent) {
- super(level, levelStr, syslogEquivalent);
- }
-
- /**
- * Convert an integer passed as argument to a level. If the conversion fails, then this method returns the specified
- * default.
- *
- * @param val numeric value.
- * @param defaultLevel level to be returned if no level matches numeric value.
- * @return matching level or default level.
- */
- public static UtilLoggingLevel toLevel(final int val, final UtilLoggingLevel defaultLevel) {
- switch (val) {
- case SEVERE_INT:
- return SEVERE;
-
- case WARNING_INT:
- return WARNING;
-
- case INFO_INT:
- return INFO;
-
- case CONFIG_INT:
- return CONFIG;
-
- case FINE_INT:
- return FINE;
-
- case FINER_INT:
- return FINER;
-
- case FINEST_INT:
- return FINEST;
-
- default:
- return defaultLevel;
- }
- }
-
- /**
- * Gets level matching numeric value.
- *
- * @param val numeric value.
- * @return matching level or UtilLoggerLevel.FINEST if no match.
- */
- public static Level toLevel(final int val) {
- return toLevel(val, FINEST);
- }
-
- /**
- * Gets list of supported levels.
- *
- * @return list of supported levels.
- */
- public static List getAllPossibleLevels() {
- final ArrayList list = new ArrayList<>();
- list.add(FINE);
- list.add(FINER);
- list.add(FINEST);
- list.add(INFO);
- list.add(CONFIG);
- list.add(WARNING);
- list.add(SEVERE);
- return list;
- }
-
- /**
- * Get level with specified symbolic name.
- *
- * @param s symbolic name.
- * @return matching level or Level.DEBUG if no match.
- */
- public static Level toLevel(final String s) {
- return toLevel(s, Level.DEBUG);
- }
-
- /**
- * Get level with specified symbolic name.
- *
- * @param sArg symbolic name.
- * @param defaultLevel level to return if no match.
- * @return matching level or defaultLevel if no match.
- */
- public static Level toLevel(final String sArg, final Level defaultLevel) {
- if (sArg == null) {
- return defaultLevel;
- }
-
- final String s = toRootUpperCase(sArg);
-
- if (s.equals("SEVERE")) {
- return SEVERE;
- }
-
- // if(s.equals("FINE")) return Level.FINE;
- if (s.equals("WARNING")) {
- return WARNING;
- }
-
- if (s.equals("INFO")) {
- return INFO;
- }
-
- if (s.equals("CONFIG")) {
- return CONFIG;
- }
-
- if (s.equals("FINE")) {
- return FINE;
- }
-
- if (s.equals("FINER")) {
- return FINER;
- }
-
- if (s.equals("FINEST")) {
- return FINEST;
- }
- return defaultLevel;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/package-info.java b/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/package-info.java
deleted file mode 100644
index c8459cb5362..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/helpers/package-info.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-/**
- * Log4j 1.x compatibility layer.
- */
-@Export
-@Version("2.20.2")
-package org.apache.log4j.helpers;
-
-import org.osgi.annotation.bundle.Export;
-import org.osgi.annotation.versioning.Version;
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/jmx/AbstractDynamicMBean.java b/log4j-1.2-api/src/main/java/org/apache/log4j/jmx/AbstractDynamicMBean.java
deleted file mode 100644
index ee9c1805a3f..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/jmx/AbstractDynamicMBean.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.jmx;
-
-import java.util.Enumeration;
-import java.util.Vector;
-import javax.management.Attribute;
-import javax.management.AttributeList;
-import javax.management.DynamicMBean;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.JMException;
-import javax.management.MBeanRegistration;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServer;
-import javax.management.NotCompliantMBeanException;
-import javax.management.ObjectName;
-import javax.management.RuntimeOperationsException;
-import org.apache.log4j.Appender;
-import org.apache.log4j.Logger;
-
-public abstract class AbstractDynamicMBean implements DynamicMBean, MBeanRegistration {
-
- /**
- * Get MBean name.
- *
- * @param appender appender, may not be null.
- * @return name.
- * @since 1.2.16
- */
- protected static String getAppenderName(final Appender appender) {
- String name = appender.getName();
- if (name == null || name.trim().length() == 0) {
- // try to get some form of a name, because null is not allowed (exception), and empty string certainly isn't
- // useful in
- // JMX..
- name = appender.toString();
- }
- return name;
- }
-
- String dClassName;
- MBeanServer server;
-
- private final Vector mbeanList = new Vector();
-
- /**
- * Enables the to get the values of several attributes of the Dynamic MBean.
- */
- @Override
- public AttributeList getAttributes(final String[] attributeNames) {
-
- // Check attributeNames is not null to avoid NullPointerException later on
- if (attributeNames == null) {
- throw new RuntimeOperationsException(
- new IllegalArgumentException("attributeNames[] cannot be null"),
- "Cannot invoke a getter of " + dClassName);
- }
-
- final AttributeList resultList = new AttributeList();
-
- // if attributeNames is empty, return an empty result list
- if (attributeNames.length == 0) {
- return resultList;
- }
-
- // build the result attribute list
- for (final String attributeName : attributeNames) {
- try {
- final Object value = getAttribute((String) attributeName);
- resultList.add(new Attribute(attributeName, value));
- } catch (final JMException e) {
- e.printStackTrace();
- } catch (final RuntimeException e) {
- e.printStackTrace();
- }
- }
- return (resultList);
- }
-
- protected abstract Logger getLogger();
-
- @Override
- public void postDeregister() {
- getLogger().debug("postDeregister is called.");
- }
-
- @Override
- public void postRegister(final java.lang.Boolean registrationDone) {}
-
- /**
- * Performs cleanup for deregistering this MBean. Default implementation unregisters MBean instances which are
- * registered using {@link #registerMBean(Object mbean, ObjectName objectName)}.
- */
- @Override
- public void preDeregister() {
- getLogger().debug("preDeregister called.");
-
- final Enumeration iterator = mbeanList.elements();
- while (iterator.hasMoreElements()) {
- final ObjectName name = (ObjectName) iterator.nextElement();
- try {
- server.unregisterMBean(name);
- } catch (final InstanceNotFoundException e) {
- getLogger().warn("Missing MBean " + name.getCanonicalName());
- } catch (final MBeanRegistrationException e) {
- getLogger().warn("Failed unregistering " + name.getCanonicalName());
- }
- }
- }
-
- @Override
- public ObjectName preRegister(final MBeanServer server, final ObjectName name) {
- getLogger().debug("preRegister called. Server=" + server + ", name=" + name);
- this.server = server;
- return name;
- }
-
- /**
- * Registers MBean instance in the attached server. Must NOT be called before registration of this instance.
- */
- protected void registerMBean(final Object mbean, final ObjectName objectName)
- throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException {
- server.registerMBean(mbean, objectName);
- mbeanList.add(objectName);
- }
-
- /**
- * Sets the values of several attributes of the Dynamic MBean, and returns the list of attributes that have been set.
- */
- @Override
- public AttributeList setAttributes(final AttributeList attributes) {
-
- // Check attributes is not null to avoid NullPointerException later on
- if (attributes == null) {
- throw new RuntimeOperationsException(
- new IllegalArgumentException("AttributeList attributes cannot be null"),
- "Cannot invoke a setter of " + dClassName);
- }
- final AttributeList resultList = new AttributeList();
-
- // if attributeNames is empty, nothing more to do
- if (attributes.isEmpty()) {
- return resultList;
- }
-
- // for each attribute, try to set it and add to the result list if successfull
- for (final Object attribute : attributes) {
- final Attribute attr = (Attribute) attribute;
- try {
- setAttribute(attr);
- final String name = attr.getName();
- final Object value = getAttribute(name);
- resultList.add(new Attribute(name, value));
- } catch (final JMException e) {
- e.printStackTrace();
- } catch (final RuntimeException e) {
- e.printStackTrace();
- }
- }
- return (resultList);
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/jmx/Agent.java b/log4j-1.2-api/src/main/java/org/apache/log4j/jmx/Agent.java
deleted file mode 100644
index daf7add2b54..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/jmx/Agent.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.jmx;
-
-import java.io.InterruptedIOException;
-import java.lang.reflect.InvocationTargetException;
-import javax.management.JMException;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.ObjectName;
-import org.apache.log4j.Logger;
-import org.apache.logging.log4j.util.LoaderUtil;
-
-/**
- * Manages an instance of com.sun.jdmk.comm.HtmlAdapterServer which was provided for demonstration purposes in the Java
- * Management Extensions Reference Implementation 1.2.1. This class is provided to maintain compatibility with earlier
- * versions of log4j and use in new code is discouraged.
- *
- * @deprecated
- */
-@Deprecated
-public class Agent {
-
- /**
- * Diagnostic logger.
- *
- * @deprecated
- */
- @Deprecated
- static Logger log = Logger.getLogger(Agent.class);
-
- /**
- * Creates a new instance of com.sun.jdmk.comm.HtmlAdapterServer using reflection.
- *
- * @since 1.2.16
- * @return new instance.
- */
- private static Object createServer() {
- Object newInstance = null;
- try {
- newInstance = LoaderUtil.newInstanceOf("com.sun.jdmk.comm.HtmlAdapterServer");
- } catch (final ReflectiveOperationException ex) {
- throw new RuntimeException(ex);
- }
- return newInstance;
- }
-
- /**
- * Invokes HtmlAdapterServer.start() using reflection.
- *
- * @since 1.2.16
- * @param server instance of com.sun.jdmk.comm.HtmlAdapterServer.
- */
- private static void startServer(final Object server) {
- try {
- server.getClass().getMethod("start", new Class[0]).invoke(server, new Object[0]);
- } catch (final InvocationTargetException ex) {
- final Throwable cause = ex.getTargetException();
- if (cause instanceof RuntimeException) {
- throw (RuntimeException) cause;
- } else if (cause != null) {
- if (cause instanceof InterruptedException || cause instanceof InterruptedIOException) {
- Thread.currentThread().interrupt();
- }
- throw new RuntimeException(cause.toString());
- } else {
- throw new RuntimeException();
- }
- } catch (final NoSuchMethodException ex) {
- throw new RuntimeException(ex.toString());
- } catch (final IllegalAccessException ex) {
- throw new RuntimeException(ex.toString());
- }
- }
-
- /**
- * Create new instance.
- *
- * @deprecated
- */
- @Deprecated
- public Agent() {}
-
- /**
- * Starts instance of HtmlAdapterServer.
- *
- * @deprecated
- */
- @Deprecated
- public void start() {
-
- final MBeanServer server = MBeanServerFactory.createMBeanServer();
- final Object html = createServer();
-
- try {
- log.info("Registering HtmlAdaptorServer instance.");
- server.registerMBean(html, new ObjectName("Adaptor:name=html,port=8082"));
- log.info("Registering HierarchyDynamicMBean instance.");
- final HierarchyDynamicMBean hdm = new HierarchyDynamicMBean();
- server.registerMBean(hdm, new ObjectName("log4j:hiearchy=default"));
- } catch (final JMException e) {
- log.error("Problem while registering MBeans instances.", e);
- return;
- } catch (final RuntimeException e) {
- log.error("Problem while registering MBeans instances.", e);
- return;
- }
- startServer(html);
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/jmx/AppenderDynamicMBean.java b/log4j-1.2-api/src/main/java/org/apache/log4j/jmx/AppenderDynamicMBean.java
deleted file mode 100644
index 2ee683240ad..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/jmx/AppenderDynamicMBean.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.jmx;
-
-import java.beans.BeanInfo;
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-import java.io.InterruptedIOException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Hashtable;
-import java.util.Vector;
-import javax.management.Attribute;
-import javax.management.AttributeNotFoundException;
-import javax.management.InvalidAttributeValueException;
-import javax.management.JMException;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanConstructorInfo;
-import javax.management.MBeanException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanNotificationInfo;
-import javax.management.MBeanOperationInfo;
-import javax.management.MBeanParameterInfo;
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
-import javax.management.RuntimeOperationsException;
-import org.apache.log4j.Appender;
-import org.apache.log4j.Layout;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.Priority;
-import org.apache.log4j.helpers.OptionConverter;
-import org.apache.log4j.spi.OptionHandler;
-
-public class AppenderDynamicMBean extends AbstractDynamicMBean {
-
- // This category instance is for logging.
- private static final Logger cat = Logger.getLogger(AppenderDynamicMBean.class);
- private final MBeanConstructorInfo[] dConstructors = new MBeanConstructorInfo[1];
- private final Vector dAttributes = new Vector();
-
- private final String dClassName = this.getClass().getName();
- private final Hashtable dynamicProps = new Hashtable(5);
- private final MBeanOperationInfo[] dOperations = new MBeanOperationInfo[2];
-
- private final String dDescription = "This MBean acts as a management facade for log4j appenders.";
-
- // We wrap this appender instance.
- private final Appender appender;
-
- public AppenderDynamicMBean(final Appender appender) throws IntrospectionException {
- this.appender = appender;
- buildDynamicMBeanInfo();
- }
-
- private void buildDynamicMBeanInfo() throws IntrospectionException {
- final Constructor[] constructors = this.getClass().getConstructors();
- dConstructors[0] = new MBeanConstructorInfo(
- "AppenderDynamicMBean(): Constructs a AppenderDynamicMBean instance", constructors[0]);
-
- final BeanInfo bi = Introspector.getBeanInfo(appender.getClass());
- final PropertyDescriptor[] pd = bi.getPropertyDescriptors();
-
- final int size = pd.length;
-
- for (int i = 0; i < size; i++) {
- final String name = pd[i].getName();
- final Method readMethod = pd[i].getReadMethod();
- final Method writeMethod = pd[i].getWriteMethod();
- if (readMethod != null) {
- final Class returnClass = readMethod.getReturnType();
- if (isSupportedType(returnClass)) {
- String returnClassName;
- if (returnClass.isAssignableFrom(Priority.class)) {
- returnClassName = "java.lang.String";
- } else {
- returnClassName = returnClass.getName();
- }
-
- dAttributes.add(
- new MBeanAttributeInfo(name, returnClassName, "Dynamic", true, writeMethod != null, false));
- dynamicProps.put(name, new MethodUnion(readMethod, writeMethod));
- }
- }
- }
-
- MBeanParameterInfo[] params = new MBeanParameterInfo[0];
-
- dOperations[0] = new MBeanOperationInfo(
- "activateOptions", "activateOptions(): add an appender", params, "void", MBeanOperationInfo.ACTION);
-
- params = new MBeanParameterInfo[1];
- params[0] = new MBeanParameterInfo("layout class", "java.lang.String", "layout class");
-
- dOperations[1] = new MBeanOperationInfo(
- "setLayout", "setLayout(): add a layout", params, "void", MBeanOperationInfo.ACTION);
- }
-
- @Override
- public Object getAttribute(final String attributeName)
- throws AttributeNotFoundException, MBeanException, ReflectionException {
-
- // Check attributeName is not null to avoid NullPointerException later on
- if (attributeName == null) {
- throw new RuntimeOperationsException(
- new IllegalArgumentException("Attribute name cannot be null"),
- "Cannot invoke a getter of " + dClassName + " with null attribute name");
- }
-
- cat.debug("getAttribute called with [" + attributeName + "].");
- if (attributeName.startsWith("appender=" + appender.getName() + ",layout")) {
- try {
- return new ObjectName("log4j:" + attributeName);
- } catch (final MalformedObjectNameException e) {
- cat.error("attributeName", e);
- } catch (final RuntimeException e) {
- cat.error("attributeName", e);
- }
- }
-
- final MethodUnion mu = (MethodUnion) dynamicProps.get(attributeName);
-
- // cat.debug("----name="+attributeName+", b="+b);
-
- if (mu != null && mu.readMethod != null) {
- try {
- return mu.readMethod.invoke(appender, null);
- } catch (final IllegalAccessException e) {
- return null;
- } catch (final InvocationTargetException e) {
- if (e.getTargetException() instanceof InterruptedException
- || e.getTargetException() instanceof InterruptedIOException) {
- Thread.currentThread().interrupt();
- }
- return null;
- } catch (final RuntimeException e) {
- return null;
- }
- }
-
- // If attributeName has not been recognized throw an AttributeNotFoundException
- throw (new AttributeNotFoundException("Cannot find " + attributeName + " attribute in " + dClassName));
- }
-
- @Override
- protected Logger getLogger() {
- return cat;
- }
-
- @Override
- public MBeanInfo getMBeanInfo() {
- cat.debug("getMBeanInfo called.");
-
- final MBeanAttributeInfo[] attribs = new MBeanAttributeInfo[dAttributes.size()];
- dAttributes.toArray(attribs);
-
- return new MBeanInfo(
- dClassName, dDescription, attribs, dConstructors, dOperations, new MBeanNotificationInfo[0]);
- }
-
- @Override
- public Object invoke(final String operationName, final Object params[], final String signature[])
- throws MBeanException, ReflectionException {
-
- if (operationName.equals("activateOptions") && appender instanceof OptionHandler) {
- final OptionHandler oh = (OptionHandler) appender;
- oh.activateOptions();
- return "Options activated.";
- } else if (operationName.equals("setLayout")) {
- final Layout layout =
- (Layout) OptionConverter.instantiateByClassName((String) params[0], Layout.class, null);
- appender.setLayout(layout);
- registerLayoutMBean(layout);
- }
- return null;
- }
-
- private boolean isSupportedType(final Class clazz) {
- if (clazz.isPrimitive() || (clazz == String.class) || clazz.isAssignableFrom(Priority.class)) {
- return true;
- }
-
- return false;
- }
-
- @Override
- public ObjectName preRegister(final MBeanServer server, final ObjectName name) {
- cat.debug("preRegister called. Server=" + server + ", name=" + name);
- this.server = server;
- registerLayoutMBean(appender.getLayout());
-
- return name;
- }
-
- void registerLayoutMBean(final Layout layout) {
- if (layout == null) {
- return;
- }
-
- final String name =
- getAppenderName(appender) + ",layout=" + layout.getClass().getName();
- cat.debug("Adding LayoutMBean:" + name);
- ObjectName objectName = null;
- try {
- final LayoutDynamicMBean appenderMBean = new LayoutDynamicMBean(layout);
- objectName = new ObjectName("log4j:appender=" + name);
- if (!server.isRegistered(objectName)) {
- registerMBean(appenderMBean, objectName);
- dAttributes.add(new MBeanAttributeInfo(
- "appender=" + name,
- "javax.management.ObjectName",
- "The " + name + " layout.",
- true,
- true,
- false));
- }
-
- } catch (final JMException e) {
- cat.error("Could not add DynamicLayoutMBean for [" + name + "].", e);
- } catch (final java.beans.IntrospectionException e) {
- cat.error("Could not add DynamicLayoutMBean for [" + name + "].", e);
- } catch (final RuntimeException e) {
- cat.error("Could not add DynamicLayoutMBean for [" + name + "].", e);
- }
- }
-
- @Override
- public void setAttribute(final Attribute attribute)
- throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException {
-
- // Check attribute is not null to avoid NullPointerException later on
- if (attribute == null) {
- throw new RuntimeOperationsException(
- new IllegalArgumentException("Attribute cannot be null"),
- "Cannot invoke a setter of " + dClassName + " with null attribute");
- }
- final String name = attribute.getName();
- Object value = attribute.getValue();
-
- if (name == null) {
- throw new RuntimeOperationsException(
- new IllegalArgumentException("Attribute name cannot be null"),
- "Cannot invoke the setter of " + dClassName + " with null attribute name");
- }
-
- final MethodUnion mu = (MethodUnion) dynamicProps.get(name);
-
- if (mu != null && mu.writeMethod != null) {
- final Object[] o = new Object[1];
-
- final Class[] params = mu.writeMethod.getParameterTypes();
- if (params[0] == org.apache.log4j.Priority.class) {
- value = OptionConverter.toLevel((String) value, (Level) getAttribute(name));
- }
- o[0] = value;
-
- try {
- mu.writeMethod.invoke(appender, o);
-
- } catch (final InvocationTargetException e) {
- if (e.getTargetException() instanceof InterruptedException
- || e.getTargetException() instanceof InterruptedIOException) {
- Thread.currentThread().interrupt();
- }
- cat.error("FIXME", e);
- } catch (final IllegalAccessException e) {
- cat.error("FIXME", e);
- } catch (final RuntimeException e) {
- cat.error("FIXME", e);
- }
- } else if (name.endsWith(".layout")) {
-
- } else {
- throw (new AttributeNotFoundException(
- "Attribute " + name + " not found in " + this.getClass().getName()));
- }
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/jmx/HierarchyDynamicMBean.java b/log4j-1.2-api/src/main/java/org/apache/log4j/jmx/HierarchyDynamicMBean.java
deleted file mode 100644
index 7b3c20980fe..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/jmx/HierarchyDynamicMBean.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.jmx;
-
-import java.lang.reflect.Constructor;
-import java.util.Vector;
-import javax.management.Attribute;
-import javax.management.AttributeNotFoundException;
-import javax.management.InvalidAttributeValueException;
-import javax.management.JMException;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanConstructorInfo;
-import javax.management.MBeanException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanNotificationInfo;
-import javax.management.MBeanOperationInfo;
-import javax.management.MBeanParameterInfo;
-import javax.management.Notification;
-import javax.management.NotificationBroadcaster;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationFilter;
-import javax.management.NotificationFilterSupport;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
-import javax.management.RuntimeOperationsException;
-import org.apache.log4j.Appender;
-import org.apache.log4j.Category;
-import org.apache.log4j.Level;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.Logger;
-import org.apache.log4j.helpers.OptionConverter;
-import org.apache.log4j.spi.HierarchyEventListener;
-import org.apache.log4j.spi.LoggerRepository;
-
-public class HierarchyDynamicMBean extends AbstractDynamicMBean
- implements HierarchyEventListener, NotificationBroadcaster {
-
- static final String ADD_APPENDER = "addAppender.";
- static final String THRESHOLD = "threshold";
-
- private static final Logger log = Logger.getLogger(HierarchyDynamicMBean.class);
- private final MBeanConstructorInfo[] dConstructors = new MBeanConstructorInfo[1];
-
- private final MBeanOperationInfo[] dOperations = new MBeanOperationInfo[1];
- private final Vector vAttributes = new Vector();
- private final String dClassName = this.getClass().getName();
-
- private final String dDescription = "This MBean acts as a management facade for org.apache.log4j.Hierarchy.";
-
- private final NotificationBroadcasterSupport nbs = new NotificationBroadcasterSupport();
-
- private final LoggerRepository hierarchy;
-
- public HierarchyDynamicMBean() {
- hierarchy = LogManager.getLoggerRepository();
- buildDynamicMBeanInfo();
- }
-
- @Override
- public void addAppenderEvent(final Category logger, final Appender appender) {
- log.debug("addAppenderEvent called: logger=" + logger.getName() + ", appender=" + appender.getName());
- final Notification n = new Notification(ADD_APPENDER + logger.getName(), this, 0);
- n.setUserData(appender);
- log.debug("sending notification.");
- nbs.sendNotification(n);
- }
-
- ObjectName addLoggerMBean(final Logger logger) {
- final String name = logger.getName();
- ObjectName objectName = null;
- try {
- final LoggerDynamicMBean loggerMBean = new LoggerDynamicMBean(logger);
- objectName = new ObjectName("log4j", "logger", name);
-
- if (!server.isRegistered(objectName)) {
- registerMBean(loggerMBean, objectName);
- final NotificationFilterSupport nfs = new NotificationFilterSupport();
- nfs.enableType(ADD_APPENDER + logger.getName());
- log.debug("---Adding logger [" + name + "] as listener.");
- nbs.addNotificationListener(loggerMBean, nfs, null);
- vAttributes.add(new MBeanAttributeInfo(
- "logger=" + name,
- "javax.management.ObjectName",
- "The " + name + " logger.",
- true,
- true, // this makes
- // the object
- // clickable
- false));
- }
-
- } catch (final JMException e) {
- log.error("Could not add loggerMBean for [" + name + "].", e);
- } catch (final RuntimeException e) {
- log.error("Could not add loggerMBean for [" + name + "].", e);
- }
- return objectName;
- }
-
- public ObjectName addLoggerMBean(final String name) {
- final Logger cat = LogManager.exists(name);
-
- if (cat != null) {
- return addLoggerMBean(cat);
- } else {
- return null;
- }
- }
-
- @Override
- public void addNotificationListener(
- final NotificationListener listener, final NotificationFilter filter, final java.lang.Object handback) {
- nbs.addNotificationListener(listener, filter, handback);
- }
-
- private void buildDynamicMBeanInfo() {
- final Constructor[] constructors = this.getClass().getConstructors();
- dConstructors[0] = new MBeanConstructorInfo(
- "HierarchyDynamicMBean(): Constructs a HierarchyDynamicMBean instance", constructors[0]);
-
- vAttributes.add(new MBeanAttributeInfo(
- THRESHOLD, "java.lang.String", "The \"threshold\" state of the hiearchy.", true, true, false));
-
- final MBeanParameterInfo[] params = new MBeanParameterInfo[1];
- params[0] = new MBeanParameterInfo("name", "java.lang.String", "Create a logger MBean");
- dOperations[0] = new MBeanOperationInfo(
- "addLoggerMBean",
- "addLoggerMBean(): add a loggerMBean",
- params,
- "javax.management.ObjectName",
- MBeanOperationInfo.ACTION);
- }
-
- @Override
- public Object getAttribute(final String attributeName)
- throws AttributeNotFoundException, MBeanException, ReflectionException {
-
- // Check attributeName is not null to avoid NullPointerException later on
- if (attributeName == null) {
- throw new RuntimeOperationsException(
- new IllegalArgumentException("Attribute name cannot be null"),
- "Cannot invoke a getter of " + dClassName + " with null attribute name");
- }
-
- log.debug("Called getAttribute with [" + attributeName + "].");
-
- // Check for a recognized attributeName and call the corresponding getter
- if (attributeName.equals(THRESHOLD)) {
- return hierarchy.getThreshold();
- } else if (attributeName.startsWith("logger")) {
- final int k = attributeName.indexOf("%3D");
- String val = attributeName;
- if (k > 0) {
- val = attributeName.substring(0, k) + '=' + attributeName.substring(k + 3);
- }
- try {
- return new ObjectName("log4j:" + val);
- } catch (final JMException e) {
- log.error("Could not create ObjectName" + val);
- } catch (final RuntimeException e) {
- log.error("Could not create ObjectName" + val);
- }
- }
-
- // If attributeName has not been recognized throw an AttributeNotFoundException
- throw (new AttributeNotFoundException("Cannot find " + attributeName + " attribute in " + dClassName));
- }
-
- @Override
- protected Logger getLogger() {
- return log;
- }
-
- @Override
- public MBeanInfo getMBeanInfo() {
- // cat.debug("getMBeanInfo called.");
-
- final MBeanAttributeInfo[] attribs = new MBeanAttributeInfo[vAttributes.size()];
- vAttributes.toArray(attribs);
-
- return new MBeanInfo(
- dClassName, dDescription, attribs, dConstructors, dOperations, new MBeanNotificationInfo[0]);
- }
-
- @Override
- public MBeanNotificationInfo[] getNotificationInfo() {
- return nbs.getNotificationInfo();
- }
-
- @Override
- public Object invoke(final String operationName, final Object params[], final String signature[])
- throws MBeanException, ReflectionException {
-
- if (operationName == null) {
- throw new RuntimeOperationsException(
- new IllegalArgumentException("Operation name cannot be null"),
- "Cannot invoke a null operation in " + dClassName);
- }
- // Check for a recognized operation name and call the corresponding operation
-
- if (operationName.equals("addLoggerMBean")) {
- return addLoggerMBean((String) params[0]);
- } else {
- throw new ReflectionException(
- new NoSuchMethodException(operationName),
- "Cannot find the operation " + operationName + " in " + dClassName);
- }
- }
-
- @Override
- public void postRegister(final java.lang.Boolean registrationDone) {
- log.debug("postRegister is called.");
- hierarchy.addHierarchyEventListener(this);
- final Logger root = hierarchy.getRootLogger();
- addLoggerMBean(root);
- }
-
- @Override
- public void removeAppenderEvent(final Category cat, final Appender appender) {
- log.debug("removeAppenderCalled: logger=" + cat.getName() + ", appender=" + appender.getName());
- }
-
- @Override
- public void removeNotificationListener(final NotificationListener listener) throws ListenerNotFoundException {
- nbs.removeNotificationListener(listener);
- }
-
- @Override
- public void setAttribute(final Attribute attribute)
- throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException {
-
- // Check attribute is not null to avoid NullPointerException later on
- if (attribute == null) {
- throw new RuntimeOperationsException(
- new IllegalArgumentException("Attribute cannot be null"),
- "Cannot invoke a setter of " + dClassName + " with null attribute");
- }
- final String name = attribute.getName();
- final Object value = attribute.getValue();
-
- if (name == null) {
- throw new RuntimeOperationsException(
- new IllegalArgumentException("Attribute name cannot be null"),
- "Cannot invoke the setter of " + dClassName + " with null attribute name");
- }
-
- if (name.equals(THRESHOLD)) {
- final Level l = OptionConverter.toLevel((String) value, hierarchy.getThreshold());
- hierarchy.setThreshold(l);
- }
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/jmx/LayoutDynamicMBean.java b/log4j-1.2-api/src/main/java/org/apache/log4j/jmx/LayoutDynamicMBean.java
deleted file mode 100644
index d31e63d7713..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/jmx/LayoutDynamicMBean.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.jmx;
-
-import java.beans.BeanInfo;
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-import java.io.InterruptedIOException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Hashtable;
-import java.util.Vector;
-import javax.management.Attribute;
-import javax.management.AttributeNotFoundException;
-import javax.management.InvalidAttributeValueException;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanConstructorInfo;
-import javax.management.MBeanException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanNotificationInfo;
-import javax.management.MBeanOperationInfo;
-import javax.management.MBeanParameterInfo;
-import javax.management.ReflectionException;
-import javax.management.RuntimeOperationsException;
-import org.apache.log4j.Layout;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.helpers.OptionConverter;
-import org.apache.log4j.spi.OptionHandler;
-
-public class LayoutDynamicMBean extends AbstractDynamicMBean {
-
- // This category instance is for logging.
- private static final Logger cat = Logger.getLogger(LayoutDynamicMBean.class);
- private final MBeanConstructorInfo[] dConstructors = new MBeanConstructorInfo[1];
- private final Vector dAttributes = new Vector();
-
- private final String dClassName = this.getClass().getName();
- private final Hashtable dynamicProps = new Hashtable(5);
- private final MBeanOperationInfo[] dOperations = new MBeanOperationInfo[1];
-
- private final String dDescription = "This MBean acts as a management facade for log4j layouts.";
-
- // We wrap this layout instance.
- private final Layout layout;
-
- public LayoutDynamicMBean(final Layout layout) throws IntrospectionException {
- this.layout = layout;
- buildDynamicMBeanInfo();
- }
-
- private void buildDynamicMBeanInfo() throws IntrospectionException {
- final Constructor[] constructors = this.getClass().getConstructors();
- dConstructors[0] = new MBeanConstructorInfo(
- "LayoutDynamicMBean(): Constructs a LayoutDynamicMBean instance", constructors[0]);
-
- final BeanInfo bi = Introspector.getBeanInfo(layout.getClass());
- final PropertyDescriptor[] pd = bi.getPropertyDescriptors();
-
- final int size = pd.length;
-
- for (int i = 0; i < size; i++) {
- final String name = pd[i].getName();
- final Method readMethod = pd[i].getReadMethod();
- final Method writeMethod = pd[i].getWriteMethod();
- if (readMethod != null) {
- final Class returnClass = readMethod.getReturnType();
- if (isSupportedType(returnClass)) {
- String returnClassName;
- if (returnClass.isAssignableFrom(Level.class)) {
- returnClassName = "java.lang.String";
- } else {
- returnClassName = returnClass.getName();
- }
-
- dAttributes.add(
- new MBeanAttributeInfo(name, returnClassName, "Dynamic", true, writeMethod != null, false));
- dynamicProps.put(name, new MethodUnion(readMethod, writeMethod));
- }
- }
- }
-
- final MBeanParameterInfo[] params = new MBeanParameterInfo[0];
-
- dOperations[0] = new MBeanOperationInfo(
- "activateOptions", "activateOptions(): add an layout", params, "void", MBeanOperationInfo.ACTION);
- }
-
- @Override
- public Object getAttribute(final String attributeName)
- throws AttributeNotFoundException, MBeanException, ReflectionException {
-
- // Check attributeName is not null to avoid NullPointerException later on
- if (attributeName == null) {
- throw new RuntimeOperationsException(
- new IllegalArgumentException("Attribute name cannot be null"),
- "Cannot invoke a getter of " + dClassName + " with null attribute name");
- }
-
- final MethodUnion mu = (MethodUnion) dynamicProps.get(attributeName);
-
- cat.debug("----name=" + attributeName + ", mu=" + mu);
-
- if (mu != null && mu.readMethod != null) {
- try {
- return mu.readMethod.invoke(layout, null);
- } catch (final InvocationTargetException e) {
- if (e.getTargetException() instanceof InterruptedException
- || e.getTargetException() instanceof InterruptedIOException) {
- Thread.currentThread().interrupt();
- }
- return null;
- } catch (final IllegalAccessException e) {
- return null;
- } catch (final RuntimeException e) {
- return null;
- }
- }
-
- // If attributeName has not been recognized throw an AttributeNotFoundException
- throw (new AttributeNotFoundException("Cannot find " + attributeName + " attribute in " + dClassName));
- }
-
- @Override
- protected Logger getLogger() {
- return cat;
- }
-
- @Override
- public MBeanInfo getMBeanInfo() {
- cat.debug("getMBeanInfo called.");
-
- final MBeanAttributeInfo[] attribs = new MBeanAttributeInfo[dAttributes.size()];
- dAttributes.toArray(attribs);
-
- return new MBeanInfo(
- dClassName, dDescription, attribs, dConstructors, dOperations, new MBeanNotificationInfo[0]);
- }
-
- @Override
- public Object invoke(final String operationName, final Object params[], final String signature[])
- throws MBeanException, ReflectionException {
-
- if (operationName.equals("activateOptions") && layout instanceof OptionHandler) {
- final OptionHandler oh = (OptionHandler) layout;
- oh.activateOptions();
- return "Options activated.";
- }
- return null;
- }
-
- private boolean isSupportedType(final Class clazz) {
- if (clazz.isPrimitive() || (clazz == String.class) || clazz.isAssignableFrom(Level.class)) {
- return true;
- }
-
- return false;
- }
-
- @Override
- public void setAttribute(final Attribute attribute)
- throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException {
-
- // Check attribute is not null to avoid NullPointerException later on
- if (attribute == null) {
- throw new RuntimeOperationsException(
- new IllegalArgumentException("Attribute cannot be null"),
- "Cannot invoke a setter of " + dClassName + " with null attribute");
- }
- final String name = attribute.getName();
- Object value = attribute.getValue();
-
- if (name == null) {
- throw new RuntimeOperationsException(
- new IllegalArgumentException("Attribute name cannot be null"),
- "Cannot invoke the setter of " + dClassName + " with null attribute name");
- }
-
- final MethodUnion mu = (MethodUnion) dynamicProps.get(name);
-
- if (mu != null && mu.writeMethod != null) {
- final Object[] o = new Object[1];
-
- final Class[] params = mu.writeMethod.getParameterTypes();
- if (params[0] == org.apache.log4j.Priority.class) {
- value = OptionConverter.toLevel((String) value, (Level) getAttribute(name));
- }
- o[0] = value;
-
- try {
- mu.writeMethod.invoke(layout, o);
-
- } catch (final InvocationTargetException e) {
- if (e.getTargetException() instanceof InterruptedException
- || e.getTargetException() instanceof InterruptedIOException) {
- Thread.currentThread().interrupt();
- }
- cat.error("FIXME", e);
- } catch (final IllegalAccessException e) {
- cat.error("FIXME", e);
- } catch (final RuntimeException e) {
- cat.error("FIXME", e);
- }
- } else {
- throw (new AttributeNotFoundException(
- "Attribute " + name + " not found in " + this.getClass().getName()));
- }
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/jmx/LoggerDynamicMBean.java b/log4j-1.2-api/src/main/java/org/apache/log4j/jmx/LoggerDynamicMBean.java
deleted file mode 100644
index 7be0f070f5f..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/jmx/LoggerDynamicMBean.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.jmx;
-
-import java.lang.reflect.Constructor;
-import java.util.Enumeration;
-import java.util.Vector;
-import javax.management.Attribute;
-import javax.management.AttributeNotFoundException;
-import javax.management.InvalidAttributeValueException;
-import javax.management.JMException;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanConstructorInfo;
-import javax.management.MBeanException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanNotificationInfo;
-import javax.management.MBeanOperationInfo;
-import javax.management.MBeanParameterInfo;
-import javax.management.MalformedObjectNameException;
-import javax.management.Notification;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
-import javax.management.RuntimeOperationsException;
-import org.apache.log4j.Appender;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.helpers.OptionConverter;
-
-public class LoggerDynamicMBean extends AbstractDynamicMBean implements NotificationListener {
-
- // This Logger instance is for logging.
- private static final Logger cat = Logger.getLogger(LoggerDynamicMBean.class);
- private final MBeanConstructorInfo[] dConstructors = new MBeanConstructorInfo[1];
-
- private final MBeanOperationInfo[] dOperations = new MBeanOperationInfo[1];
- private final Vector dAttributes = new Vector();
-
- private final String dClassName = this.getClass().getName();
-
- private final String dDescription =
- "This MBean acts as a management facade for a org.apache.log4j.Logger instance.";
-
- // We wrap this Logger instance.
- private final Logger logger;
-
- public LoggerDynamicMBean(final Logger logger) {
- this.logger = logger;
- buildDynamicMBeanInfo();
- }
-
- void addAppender(final String appenderClass, final String appenderName) {
- cat.debug("addAppender called with " + appenderClass + ", " + appenderName);
- final Appender appender =
- (Appender) OptionConverter.instantiateByClassName(appenderClass, org.apache.log4j.Appender.class, null);
- appender.setName(appenderName);
- logger.addAppender(appender);
-
- // appenderMBeanRegistration();
-
- }
-
- void appenderMBeanRegistration() {
- final Enumeration enumeration = logger.getAllAppenders();
- while (enumeration.hasMoreElements()) {
- final Appender appender = (Appender) enumeration.nextElement();
- registerAppenderMBean(appender);
- }
- }
-
- private void buildDynamicMBeanInfo() {
- final Constructor[] constructors = this.getClass().getConstructors();
- dConstructors[0] = new MBeanConstructorInfo(
- "HierarchyDynamicMBean(): Constructs a HierarchyDynamicMBean instance", constructors[0]);
-
- dAttributes.add(
- new MBeanAttributeInfo("name", "java.lang.String", "The name of this Logger.", true, false, false));
-
- dAttributes.add(new MBeanAttributeInfo(
- "priority", "java.lang.String", "The priority of this logger.", true, true, false));
-
- final MBeanParameterInfo[] params = new MBeanParameterInfo[2];
- params[0] = new MBeanParameterInfo("class name", "java.lang.String", "add an appender to this logger");
- params[1] = new MBeanParameterInfo("appender name", "java.lang.String", "name of the appender");
-
- dOperations[0] = new MBeanOperationInfo(
- "addAppender", "addAppender(): add an appender", params, "void", MBeanOperationInfo.ACTION);
- }
-
- @Override
- public Object getAttribute(final String attributeName)
- throws AttributeNotFoundException, MBeanException, ReflectionException {
-
- // Check attributeName is not null to avoid NullPointerException later on
- if (attributeName == null) {
- throw new RuntimeOperationsException(
- new IllegalArgumentException("Attribute name cannot be null"),
- "Cannot invoke a getter of " + dClassName + " with null attribute name");
- }
-
- // Check for a recognized attributeName and call the corresponding getter
- if (attributeName.equals("name")) {
- return logger.getName();
- } else if (attributeName.equals("priority")) {
- final Level l = logger.getLevel();
- if (l == null) {
- return null;
- } else {
- return l.toString();
- }
- } else if (attributeName.startsWith("appender=")) {
- try {
- return new ObjectName("log4j:" + attributeName);
- } catch (final MalformedObjectNameException e) {
- cat.error("Could not create ObjectName" + attributeName);
- } catch (final RuntimeException e) {
- cat.error("Could not create ObjectName" + attributeName);
- }
- }
-
- // If attributeName has not been recognized throw an AttributeNotFoundException
- throw (new AttributeNotFoundException("Cannot find " + attributeName + " attribute in " + dClassName));
- }
-
- @Override
- protected Logger getLogger() {
- return logger;
- }
-
- @Override
- public MBeanInfo getMBeanInfo() {
- // cat.debug("getMBeanInfo called.");
-
- final MBeanAttributeInfo[] attribs = new MBeanAttributeInfo[dAttributes.size()];
- dAttributes.toArray(attribs);
-
- final MBeanInfo mb = new MBeanInfo(
- dClassName, dDescription, attribs, dConstructors, dOperations, new MBeanNotificationInfo[0]);
- // cat.debug("getMBeanInfo exit.");
- return mb;
- }
-
- @Override
- public void handleNotification(final Notification notification, final Object handback) {
- cat.debug("Received notification: " + notification.getType());
- registerAppenderMBean((Appender) notification.getUserData());
- }
-
- @Override
- public Object invoke(final String operationName, final Object params[], final String signature[])
- throws MBeanException, ReflectionException {
-
- if (operationName.equals("addAppender")) {
- addAppender((String) params[0], (String) params[1]);
- return "Hello world.";
- }
-
- return null;
- }
-
- @Override
- public void postRegister(final java.lang.Boolean registrationDone) {
- appenderMBeanRegistration();
- }
-
- void registerAppenderMBean(final Appender appender) {
- final String name = getAppenderName(appender);
- cat.debug("Adding AppenderMBean for appender named " + name);
- ObjectName objectName = null;
- try {
- final AppenderDynamicMBean appenderMBean = new AppenderDynamicMBean(appender);
- objectName = new ObjectName("log4j", "appender", name);
- if (!server.isRegistered(objectName)) {
- registerMBean(appenderMBean, objectName);
- dAttributes.add(new MBeanAttributeInfo(
- "appender=" + name,
- "javax.management.ObjectName",
- "The " + name + " appender.",
- true,
- true,
- false));
- }
-
- } catch (final JMException e) {
- cat.error("Could not add appenderMBean for [" + name + "].", e);
- } catch (final java.beans.IntrospectionException e) {
- cat.error("Could not add appenderMBean for [" + name + "].", e);
- } catch (final RuntimeException e) {
- cat.error("Could not add appenderMBean for [" + name + "].", e);
- }
- }
-
- @Override
- public void setAttribute(final Attribute attribute)
- throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException {
-
- // Check attribute is not null to avoid NullPointerException later on
- if (attribute == null) {
- throw new RuntimeOperationsException(
- new IllegalArgumentException("Attribute cannot be null"),
- "Cannot invoke a setter of " + dClassName + " with null attribute");
- }
- final String name = attribute.getName();
- final Object value = attribute.getValue();
-
- if (name == null) {
- throw new RuntimeOperationsException(
- new IllegalArgumentException("Attribute name cannot be null"),
- "Cannot invoke the setter of " + dClassName + " with null attribute name");
- }
-
- if (name.equals("priority")) {
- if (value instanceof String) {
- final String s = (String) value;
- Level p = logger.getLevel();
- if (s.equalsIgnoreCase("NULL")) {
- p = null;
- } else {
- p = OptionConverter.toLevel(s, p);
- }
- logger.setLevel(p);
- }
- } else {
- throw (new AttributeNotFoundException(
- "Attribute " + name + " not found in " + this.getClass().getName()));
- }
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/jmx/MethodUnion.java b/log4j-1.2-api/src/main/java/org/apache/log4j/jmx/MethodUnion.java
deleted file mode 100644
index f7a4a80e6b8..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/jmx/MethodUnion.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.jmx;
-
-import java.lang.reflect.Method;
-
-class MethodUnion {
-
- Method readMethod;
- Method writeMethod;
-
- MethodUnion(final Method readMethod, final Method writeMethod) {
- this.readMethod = readMethod;
- this.writeMethod = writeMethod;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/jmx/package-info.java b/log4j-1.2-api/src/main/java/org/apache/log4j/jmx/package-info.java
deleted file mode 100644
index b502a304c98..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/jmx/package-info.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-/**
- * This package lets you manage log4j settings using JMX. It is unfortunately not of production quality.
- */
-@Export
-@Version("2.20.1")
-package org.apache.log4j.jmx;
-
-import org.osgi.annotation.bundle.Export;
-import org.osgi.annotation.versioning.Version;
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/layout/Log4j1SyslogLayout.java b/log4j-1.2-api/src/main/java/org/apache/log4j/layout/Log4j1SyslogLayout.java
deleted file mode 100644
index ba3f41a96d5..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/layout/Log4j1SyslogLayout.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.layout;
-
-import static org.apache.logging.log4j.util.Strings.toRootLowerCase;
-
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.StringLayout;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.layout.AbstractStringLayout;
-import org.apache.logging.log4j.core.net.Facility;
-import org.apache.logging.log4j.core.net.Priority;
-import org.apache.logging.log4j.core.pattern.DatePatternConverter;
-import org.apache.logging.log4j.core.pattern.LogEventPatternConverter;
-import org.apache.logging.log4j.core.util.NetUtils;
-import org.apache.logging.log4j.plugins.Configurable;
-import org.apache.logging.log4j.plugins.Factory;
-import org.apache.logging.log4j.plugins.Plugin;
-import org.apache.logging.log4j.plugins.PluginBuilderAttribute;
-import org.apache.logging.log4j.plugins.PluginElement;
-import org.apache.logging.log4j.util.Chars;
-
-/**
- * Port of the layout used by SyslogAppender in Log4j 1.x. Provided for
- * compatibility with existing Log4j 1 configurations.
- *
- * Originally developed by Ceki Gülcü and Anders Kristensen.
- */
-@Configurable(elementType = Layout.ELEMENT_TYPE, printObject = true)
-@Plugin
-public final class Log4j1SyslogLayout extends AbstractStringLayout {
-
- /**
- * Builds a SyslogLayout.
- * The main arguments are
- *
- * facility: The Facility is used to try to classify the message.
- * includeNewLine: If true a newline will be appended to the result.
- * escapeNL: Pattern to use for replacing newlines.
- * charset: The character set.
- *
- */
- public static class Builder extends AbstractStringLayout.Builder
- implements org.apache.logging.log4j.plugins.util.Builder {
-
- public Builder() {
- setCharset(StandardCharsets.UTF_8);
- }
-
- @PluginBuilderAttribute
- private Facility facility = Facility.USER;
-
- @PluginBuilderAttribute
- private boolean facilityPrinting;
-
- @PluginBuilderAttribute
- private boolean header;
-
- @PluginElement("Layout")
- private Layout messageLayout;
-
- @Override
- public Log4j1SyslogLayout build() {
- if (messageLayout != null && !(messageLayout instanceof StringLayout)) {
- LOGGER.error("Log4j1SyslogLayout: the message layout must be a StringLayout.");
- return null;
- }
- return new Log4j1SyslogLayout(
- getConfiguration(), facility, facilityPrinting, header, (StringLayout) messageLayout, getCharset());
- }
-
- public Facility getFacility() {
- return facility;
- }
-
- public boolean isFacilityPrinting() {
- return facilityPrinting;
- }
-
- public boolean isHeader() {
- return header;
- }
-
- public Layout getMessageLayout() {
- return messageLayout;
- }
-
- public Builder setFacility(final Facility facility) {
- this.facility = facility;
- return asBuilder();
- }
-
- public Builder setFacilityPrinting(final boolean facilityPrinting) {
- this.facilityPrinting = facilityPrinting;
- return asBuilder();
- }
-
- public Builder setHeader(final boolean header) {
- this.header = header;
- return asBuilder();
- }
-
- public Builder setMessageLayout(final Layout messageLayout) {
- this.messageLayout = messageLayout;
- return asBuilder();
- }
- }
-
- @Factory
- public static Builder newBuilder() {
- return new Builder().asBuilder();
- }
-
- /**
- * Host name used to identify messages from this appender.
- */
- private static final String localHostname = NetUtils.getLocalHostname();
-
- private final Facility facility;
- private final boolean facilityPrinting;
- private final boolean header;
- private final StringLayout messageLayout;
-
- /**
- * Date format used if header = true.
- */
- private static final String[] dateFormatOptions = {"MMM dd HH:mm:ss", null, "en"};
-
- private final LogEventPatternConverter dateConverter;
-
- private Log4j1SyslogLayout(
- final Configuration config,
- final Facility facility,
- final boolean facilityPrinting,
- final boolean header,
- final StringLayout messageLayout,
- final Charset charset) {
- super(config, charset);
- this.facility = facility;
- this.facilityPrinting = facilityPrinting;
- this.header = header;
- this.messageLayout = messageLayout;
- this.dateConverter = DatePatternConverter.newInstance(config, dateFormatOptions);
- }
-
- /**
- * Formats a {@link LogEvent} in conformance with the BSD Log record format.
- *
- * @param event The LogEvent
- * @return the event formatted as a String.
- */
- @Override
- public String toSerializable(final LogEvent event) {
- // The messageLayout also uses the thread-bound StringBuilder,
- // so we generate the message first
- final String message = messageLayout != null
- ? messageLayout.toSerializable(event)
- : event.getMessage().getFormattedMessage();
- final StringBuilder buf = stringBuilderRecycler.acquire();
-
- try {
- buf.append('<');
- buf.append(Priority.getPriority(facility, event.getLevel()));
- buf.append('>');
-
- if (header) {
- final int index = buf.length() + 4;
- dateConverter.format(event, buf);
- // RFC 3164 says leading space, not leading zero on days 1-9
- if (buf.charAt(index) == '0') {
- buf.setCharAt(index, Chars.SPACE);
- }
-
- buf.append(Chars.SPACE);
- buf.append(localHostname);
- buf.append(Chars.SPACE);
- }
-
- if (facilityPrinting) {
- buf.append(facility != null ? toRootLowerCase(facility.name()) : "user")
- .append(':');
- }
-
- buf.append(message);
- // TODO: splitting message into 1024 byte chunks?
- return buf.toString();
- } finally {
- stringBuilderRecycler.release(buf);
- }
- }
-
- /**
- * Gets this SyslogLayout's content format. Specified by:
- *
- * Key: "structured" Value: "false"
- * Key: "dateFormat" Value: "MMM dd HH:mm:ss"
- * Key: "format" Value: "<LEVEL>TIMESTAMP PROP(HOSTNAME) MESSAGE"
- * Key: "formatType" Value: "logfilepatternreceiver" (format uses the keywords supported by
- * LogFilePatternReceiver)
- *
- *
- * @return Map of content format keys supporting SyslogLayout
- */
- @Override
- public Map getContentFormat() {
- final Map result = new HashMap<>();
- result.put("structured", "false");
- result.put("formatType", "logfilepatternreceiver");
- result.put("dateFormat", dateFormatOptions[0]);
- if (header) {
- result.put("format", "TIMESTAMP PROP(HOSTNAME) MESSAGE");
- } else {
- result.put("format", "MESSAGE");
- }
- return result;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/layout/Log4j1XmlLayout.java b/log4j-1.2-api/src/main/java/org/apache/log4j/layout/Log4j1XmlLayout.java
deleted file mode 100644
index ccb57282f81..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/layout/Log4j1XmlLayout.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.layout;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.nio.charset.StandardCharsets;
-import java.util.List;
-import java.util.Objects;
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.plugins.PluginConfiguration;
-import org.apache.logging.log4j.core.layout.AbstractStringLayout;
-import org.apache.logging.log4j.core.layout.ByteBufferDestination;
-import org.apache.logging.log4j.core.layout.Encoder;
-import org.apache.logging.log4j.core.util.Transform;
-import org.apache.logging.log4j.plugins.Configurable;
-import org.apache.logging.log4j.plugins.Plugin;
-import org.apache.logging.log4j.plugins.PluginAttribute;
-import org.apache.logging.log4j.plugins.PluginFactory;
-import org.apache.logging.log4j.util.ReadOnlyStringMap;
-import org.apache.logging.log4j.util.Strings;
-
-/**
- * Port of XMLLayout in Log4j 1.x. Provided for compatibility with existing Log4j 1 configurations.
- *
- * Originally developed by Ceki Gülcü, Mathias Bogaert.
- */
-@Configurable(elementType = Layout.ELEMENT_TYPE, printObject = true)
-@Plugin
-public final class Log4j1XmlLayout extends AbstractStringLayout {
-
- /** We yield to the \r\n heresy. */
- private static final String EOL = "\r\n";
-
- private final boolean locationInfo;
- private final boolean properties;
-
- @PluginFactory
- public static Log4j1XmlLayout createLayout(
- // @formatter:off
- @PluginConfiguration final Configuration configuration,
- @PluginAttribute(value = "locationInfo") final boolean locationInfo,
- @PluginAttribute(value = "properties") final boolean properties
- // @formatter:on
- ) {
- return new Log4j1XmlLayout(configuration, locationInfo, properties);
- }
-
- private Log4j1XmlLayout(final Configuration configuration, final boolean locationInfo, final boolean properties) {
- super(configuration, StandardCharsets.UTF_8);
- this.locationInfo = locationInfo;
- this.properties = properties;
- }
-
- public boolean isLocationInfo() {
- return locationInfo;
- }
-
- public boolean isProperties() {
- return properties;
- }
-
- @Override
- public void encode(final LogEvent event, final ByteBufferDestination destination) {
- final StringBuilder text = stringBuilderRecycler.acquire();
- try {
- formatTo(event, text);
- final Encoder stringBuilderEncoder = stringBuilderEncoderRecycler.acquire();
- try {
- stringBuilderEncoder.encode(text, destination);
- } finally {
- stringBuilderEncoderRecycler.release(stringBuilderEncoder);
- }
- } finally {
- stringBuilderRecycler.release(text);
- }
- }
-
- @Override
- public String toSerializable(final LogEvent event) {
- final StringBuilder text = stringBuilderRecycler.acquire();
- try {
- formatTo(event, text);
- return text.toString();
- } finally {
- stringBuilderRecycler.release(text);
- }
- }
-
- @SuppressFBWarnings(
- value = "INFORMATION_EXPOSURE_THROUGH_AN_ERROR_MESSAGE",
- justification = "The throwable is formatted into a log file, which should be private.")
- private void formatTo(final LogEvent event, final StringBuilder buf) {
- buf.append("");
- buf.append(EOL);
-
- buf.append(" ");
- buf.append(EOL);
-
- final List ndc = event.getContextStack().asList();
- if (!ndc.isEmpty()) {
- buf.append(" ");
- buf.append(EOL);
- }
-
- @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
- final Throwable thrown = event.getThrown();
- if (thrown != null) {
- buf.append(" ");
- buf.append(EOL);
- }
-
- if (locationInfo) {
- final StackTraceElement source = event.getSource();
- if (source != null) {
- buf.append(" ");
- buf.append(EOL);
- }
- }
-
- if (properties) {
- final ReadOnlyStringMap contextMap = event.getContextData();
- if (!contextMap.isEmpty()) {
- buf.append("\r\n");
- contextMap.forEach((key, val) -> {
- if (val != null) {
- buf.append(" ");
- buf.append(EOL);
- }
- });
- buf.append(" ");
- buf.append(EOL);
- }
- }
-
- buf.append(" ");
- buf.append(EOL);
- buf.append(EOL);
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/layout/package-info.java b/log4j-1.2-api/src/main/java/org/apache/log4j/layout/package-info.java
deleted file mode 100644
index e67a53cf024..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/layout/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-@ExportTo("org.apache.logging.log4j.core")
-@Open("org.apache.logging.log4j.core")
-package org.apache.log4j.layout;
-
-import aQute.bnd.annotation.jpms.ExportTo;
-import aQute.bnd.annotation.jpms.Open;
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/legacy/core/CategoryUtil.java b/log4j-1.2-api/src/main/java/org/apache/log4j/legacy/core/CategoryUtil.java
deleted file mode 100644
index ee31ff53802..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/legacy/core/CategoryUtil.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.legacy.core;
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Optional;
-import java.util.function.Supplier;
-import org.apache.log4j.bridge.AppenderAdapter;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.LoggerConfig;
-import org.apache.logging.log4j.spi.LoggerContext;
-
-/**
- * Delegates to {@code Logger} methods implemented by {@code log4j-core} if appropriate.
- */
-public final class CategoryUtil {
-
- private static org.apache.logging.log4j.core.Logger asCore(final Logger logger) {
- return (org.apache.logging.log4j.core.Logger) logger;
- }
-
- private static T get(final Logger logger, final Supplier run, final T defaultValue) {
- return isCore(logger) ? run.get() : defaultValue;
- }
-
- /**
- * Gets the appenders attached directly to this logger.
- *
- * @param logger The target logger.
- * @return A Map containing the Appender's name as the key and the Appender as the value.
- */
- public static Map getAppenders(final Logger logger) {
- return get(logger, () -> getDirectAppenders(logger), Collections.emptyMap());
- }
-
- private static Map getDirectAppenders(final Logger logger) {
- return CategoryUtil.getExactLoggerConfig(logger)
- .map(LoggerConfig::getAppenders)
- .orElse(Collections.emptyMap());
- }
-
- private static Optional getExactLoggerConfig(final Logger logger) {
- return Optional.of(asCore(logger).get()).filter(lc -> logger.getName().equals(lc.getName()));
- }
-
- /**
- * Delegates to {@link org.apache.logging.log4j.core.Logger#getFilters()} if appropriate.
- *
- * @param logger The target logger.
- * @return An Iterator over all the Filters associated with the Logger.
- */
- public static Iterator getFilters(final Logger logger) {
- return get(logger, asCore(logger)::getFilters, null);
- }
-
- /**
- * Delegates to {@link org.apache.logging.log4j.core.Logger#getContext()} if appropriate.
- *
- * @param logger The target logger.
- * @return the LoggerContext.
- */
- public static LoggerContext getLoggerContext(final Logger logger) {
- return get(logger, asCore(logger)::getContext, null);
- }
-
- /**
- * Delegates to {@link org.apache.logging.log4j.core.Logger#getParent()} if appropriate.
- *
- * @param logger The target logger.
- * @return The parent Logger.
- */
- public static Logger getParent(final Logger logger) {
- return get(logger, asCore(logger)::getParent, null);
- }
-
- /**
- * Delegates to {@link org.apache.logging.log4j.core.Logger#isAdditive()} if appropriate.
- *
- * @param logger The target logger.
- * @return true if the associated LoggerConfig is additive, false otherwise.
- */
- public static boolean isAdditive(final Logger logger) {
- return get(logger, asCore(logger)::isAdditive, false);
- }
-
- private static boolean isCore(final Logger logger) {
- return logger instanceof org.apache.logging.log4j.core.Logger;
- }
-
- /**
- * Delegates to {@link org.apache.logging.log4j.core.Logger#setAdditive(boolean)} if appropriate.
- *
- * @param logger The target logger.
- * @param additive Boolean value to indicate whether the Logger is additive or not.
- */
- public static void setAdditivity(final Logger logger, final boolean additive) {
- if (isCore(logger)) {
- asCore(logger).setAdditive(additive);
- }
- }
-
- /**
- * Delegates to {@link org.apache.logging.log4j.core.Logger#setLevel(Level)} if appropriate.
- *
- * @param logger The target logger.
- * @param level The Level to use on this Logger, may be null.
- */
- public static void setLevel(final Logger logger, final Level level) {
- if (isCore(logger)) {
- asCore(logger).setLevel(level);
- }
- }
-
- /**
- * Adds an appender to the logger. This method requires a check for the presence
- * of Log4j Core or it will cause a {@code ClassNotFoundException}.
- *
- * @param logger The target logger.
- * @param appender A Log4j2 appender.
- */
- public static void addAppender(final Logger logger, final Appender appender) {
- if (appender instanceof AppenderAdapter.Adapter) {
- appender.start();
- }
- asCore(logger).addAppender(appender);
- }
-
- /**
- * Sends the event to all appenders directly connected with the logger. This
- * method requires a check for the presence of Log4j Core or it will cause a
- * {@code ClassNotFoundException}.
- *
- * @param logger The target logger.
- * @param event The event to send.
- */
- public static void log(final Logger logger, final LogEvent event) {
- getExactLoggerConfig(logger).ifPresent(lc -> lc.log(event));
- }
-
- private CategoryUtil() {}
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/legacy/core/ContextUtil.java b/log4j-1.2-api/src/main/java/org/apache/log4j/legacy/core/ContextUtil.java
deleted file mode 100644
index bf94a8d4093..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/legacy/core/ContextUtil.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.legacy.core;
-
-import org.apache.logging.log4j.spi.LoggerContext;
-
-/**
- * Delegates to {@code LoggerContext} methods implemented by {@code log4j-core} if appropriate.
- */
-public final class ContextUtil {
-
- /**
- * Delegates to {@link org.apache.logging.log4j.core.LoggerContext#reconfigure()} if appropriate.
- *
- * @param loggerContext The target logger context.
- */
- public static void reconfigure(final LoggerContext loggerContext) {
- if (loggerContext instanceof org.apache.logging.log4j.core.LoggerContext) {
- ((org.apache.logging.log4j.core.LoggerContext) loggerContext).reconfigure();
- }
- }
-
- /**
- * Delegates to {@link org.apache.logging.log4j.core.LoggerContext#close()} if appropriate.
- *
- * @param loggerContext The target logger context.
- */
- public static void shutdown(final LoggerContext loggerContext) {
- if (loggerContext instanceof org.apache.logging.log4j.core.LoggerContext) {
- ((org.apache.logging.log4j.core.LoggerContext) loggerContext).close();
- }
- }
-
- private ContextUtil() {}
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/or/DefaultRenderer.java b/log4j-1.2-api/src/main/java/org/apache/log4j/or/DefaultRenderer.java
deleted file mode 100644
index a677d13037a..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/or/DefaultRenderer.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.or;
-
-/**
- * The default ObjectRenderer renders objects by calling their {@code toString()} method.
- *
- * @since 1.0
- */
-class DefaultRenderer implements ObjectRenderer {
-
- DefaultRenderer() {}
-
- /**
- * Render the object passed as parameter by calling its {@code toString()} method.
- */
- public String doRender(final Object o) {
- try {
- return o.toString();
- } catch (Exception ex) {
- return ex.toString();
- }
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/or/ObjectRenderer.java b/log4j-1.2-api/src/main/java/org/apache/log4j/or/ObjectRenderer.java
deleted file mode 100644
index e114cf51d92..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/or/ObjectRenderer.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.or;
-
-/**
- * Converts objects to Strings.
- */
-public interface ObjectRenderer {
- /**
- * Render the object passed as parameter as a String.
- * @param o The object to render.
- * @return The String representation of the object.
- */
- String doRender(Object o);
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/or/RendererMap.java b/log4j-1.2-api/src/main/java/org/apache/log4j/or/RendererMap.java
deleted file mode 100644
index e78576193d1..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/or/RendererMap.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.or;
-
-import java.util.Hashtable;
-import org.apache.log4j.helpers.OptionConverter;
-import org.apache.log4j.spi.RendererSupport;
-import org.apache.logging.log4j.core.util.Loader;
-import org.apache.logging.log4j.status.StatusLogger;
-
-/**
- * Map class objects to an {@link ObjectRenderer}.
- *
- * @author Ceki Gülcü
- * @since version 1.0
- */
-public class RendererMap {
-
- Hashtable map;
-
- static ObjectRenderer defaultRenderer = new DefaultRenderer();
-
- public RendererMap() {
- map = new Hashtable();
- }
-
- /**
- * Add a renderer to a hierarchy passed as parameter.
- */
- public static void addRenderer(
- final RendererSupport repository, final String renderedClassName, final String renderingClassName) {
- StatusLogger.getLogger()
- .debug("Rendering class: [" + renderingClassName + "], Rendered class: [" + renderedClassName + "].");
- final ObjectRenderer renderer =
- (ObjectRenderer) OptionConverter.instantiateByClassName(renderingClassName, ObjectRenderer.class, null);
- if (renderer == null) {
- StatusLogger.getLogger().error("Could not instantiate renderer [" + renderingClassName + "].");
- return;
- }
- try {
- final Class renderedClass = Loader.loadClass(renderedClassName);
- repository.setRenderer(renderedClass, renderer);
- } catch (ClassNotFoundException e) {
- StatusLogger.getLogger().error("Could not find class [" + renderedClassName + "].", e);
- }
- }
-
- /**
- * Find the appropriate renderer for the class type of the o
parameter. This is accomplished by calling the
- * {@link #get(Class)} method. Once a renderer is found, it is applied on the object o
and the result is
- * returned as a {@link String}.
- */
- public String findAndRender(final Object o) {
- if (o == null) return null;
- else return get(o.getClass()).doRender(o);
- }
-
- /**
- * Syntactic sugar method that calls {@link #get(Class)} with the class of the object parameter.
- */
- public ObjectRenderer get(final Object o) {
- if (o == null) return null;
- else return get(o.getClass());
- }
-
- /**
- * Search the parents of clazz
for a renderer. The renderer closest in the hierarchy will be returned. If
- * no renderers could be found, then the default renderer is returned.
- *
- *
- * The search first looks for a renderer configured for clazz
. If a renderer could not be found, then the
- * search continues by looking at all the interfaces implemented by clazz
including the super-interfaces of
- * each interface. If a renderer cannot be found, then the search looks for a renderer defined for the parent
- * (superclass) of clazz
. If that fails, then all the interfaces implemented by the parent of
- * clazz
are searched and so on.
- *
- *
- * For example, if A0, A1, A2 are classes and X0, X1, X2, Y0, Y1 are interfaces where A2 extends A1 which in turn
- * extends A0 and similarly X2 extends X1 which extends X0 and Y1 extends Y0. Let us also assume that A1 implements the
- * Y0 interface and that A2 implements the X2 interface.
- *
- *
- * The table below shows the results returned by the get(A2.class)
method depending on the renderers added
- * to the map.
- *
- *
- *
- *
- * Added renderers
- * Value returned by get(A2.class)
- *
- *
- * A0Renderer
- * A0Renderer
- *
- *
- * A0Renderer, A1Renderer
- * A1Renderer
- *
- *
- * X0Renderer
- * X0Renderer
- *
- *
- * A1Renderer, X0Renderer
- * X0Renderer
- *
- *
- *
- *
- * This search algorithm is not the most natural, although it is particularly easy to implement. Future log4j versions
- * may implement a more intuitive search algorithm. However, the present algorithm should be acceptable in the
- * vast majority of circumstances.
- *
- */
- public ObjectRenderer get(final Class clazz) {
- // System.out.println("\nget: "+clazz);
- ObjectRenderer r = null;
- for (Class c = clazz; c != null; c = c.getSuperclass()) {
- // System.out.println("Searching for class: "+c);
- r = (ObjectRenderer) map.get(c);
- if (r != null) {
- return r;
- }
- r = searchInterfaces(c);
- if (r != null) return r;
- }
- return defaultRenderer;
- }
-
- ObjectRenderer searchInterfaces(Class c) {
- // System.out.println("Searching interfaces of class: "+c);
-
- ObjectRenderer r = (ObjectRenderer) map.get(c);
- if (r != null) {
- return r;
- }
- final Class[] ia = c.getInterfaces();
- for (int i = 0; i < ia.length; i++) {
- r = searchInterfaces(ia[i]);
- if (r != null) return r;
- }
- return null;
- }
-
- public ObjectRenderer getDefaultRenderer() {
- return defaultRenderer;
- }
-
- public void clear() {
- map.clear();
- }
-
- /**
- * Register an {@link ObjectRenderer} for clazz
.
- */
- public void put(final Class clazz, final ObjectRenderer or) {
- map.put(clazz, or);
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/or/ThreadGroupRenderer.java b/log4j-1.2-api/src/main/java/org/apache/log4j/or/ThreadGroupRenderer.java
deleted file mode 100644
index 3da0dbedb49..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/or/ThreadGroupRenderer.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.or;
-
-import org.apache.log4j.Layout;
-
-/**
- */
-public class ThreadGroupRenderer implements ObjectRenderer {
-
- @Override
- public String doRender(final Object obj) {
- if (obj instanceof ThreadGroup) {
- final StringBuilder sb = new StringBuilder();
- final ThreadGroup threadGroup = (ThreadGroup) obj;
- sb.append("java.lang.ThreadGroup[name=");
- sb.append(threadGroup.getName());
- sb.append(", maxpri=");
- sb.append(threadGroup.getMaxPriority());
- sb.append("]");
- final Thread[] threads = new Thread[threadGroup.activeCount()];
- threadGroup.enumerate(threads);
- for (Thread thread : threads) {
- sb.append(Layout.LINE_SEP);
- sb.append(" Thread=[");
- sb.append(thread.getName());
- sb.append(",");
- sb.append(thread.getPriority());
- sb.append(",");
- sb.append(thread.isDaemon());
- sb.append("]");
- }
- return sb.toString();
- }
- try {
- // this is the best we can do
- return obj.toString();
- } catch (Exception ex) {
- return ex.toString();
- }
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/or/jms/MessageRenderer.java b/log4j-1.2-api/src/main/java/org/apache/log4j/or/jms/MessageRenderer.java
deleted file mode 100644
index ffc5e9385af..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/or/jms/MessageRenderer.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.or.jms;
-
-import javax.jms.DeliveryMode;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import org.apache.log4j.or.ObjectRenderer;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.status.StatusLogger;
-
-/**
- * Log4j 1.x JMS Message Renderer
- */
-public class MessageRenderer implements ObjectRenderer {
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- /**
- * Render a {@link javax.jms.Message}.
- */
- @Override
- public String doRender(final Object obj) {
- if (obj instanceof Message) {
- final StringBuilder sb = new StringBuilder();
- final Message message = (Message) obj;
- try {
- sb.append("DeliveryMode=");
- switch (message.getJMSDeliveryMode()) {
- case DeliveryMode.NON_PERSISTENT:
- sb.append("NON_PERSISTENT");
- break;
- case DeliveryMode.PERSISTENT:
- sb.append("PERSISTENT");
- break;
- default:
- sb.append("UNKNOWN");
- }
- sb.append(", CorrelationID=");
- sb.append(message.getJMSCorrelationID());
-
- sb.append(", Destination=");
- sb.append(message.getJMSDestination());
-
- sb.append(", Expiration=");
- sb.append(message.getJMSExpiration());
-
- sb.append(", MessageID=");
- sb.append(message.getJMSMessageID());
-
- sb.append(", Priority=");
- sb.append(message.getJMSPriority());
-
- sb.append(", Redelivered=");
- sb.append(message.getJMSRedelivered());
-
- sb.append(", ReplyTo=");
- sb.append(message.getJMSReplyTo());
-
- sb.append(", Timestamp=");
- sb.append(message.getJMSTimestamp());
-
- sb.append(", Type=");
- sb.append(message.getJMSType());
-
- } catch (JMSException e) {
- LOGGER.error("Could not parse Message.", e);
- }
- return sb.toString();
- }
- return obj.toString();
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/or/jms/package-info.java b/log4j-1.2-api/src/main/java/org/apache/log4j/or/jms/package-info.java
deleted file mode 100644
index 85922fd2e41..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/or/jms/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-@Export
-@Version("2.20.1")
-package org.apache.log4j.or.jms;
-
-import org.osgi.annotation.bundle.Export;
-import org.osgi.annotation.versioning.Version;
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/or/package-info.java b/log4j-1.2-api/src/main/java/org/apache/log4j/or/package-info.java
deleted file mode 100644
index 4cee049d061..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/or/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-@Export
-@Version("2.20.1")
-package org.apache.log4j.or;
-
-import org.osgi.annotation.bundle.Export;
-import org.osgi.annotation.versioning.Version;
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/package-info.java b/log4j-1.2-api/src/main/java/org/apache/log4j/package-info.java
deleted file mode 100644
index 7462396fa7f..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/package-info.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-/**
- * Log4j 1.x compatibility layer.
- */
-@Export
-@Version("2.20.2")
-package org.apache.log4j;
-
-import org.osgi.annotation.bundle.Export;
-import org.osgi.annotation.versioning.Version;
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/pattern/FormattingInfo.java b/log4j-1.2-api/src/main/java/org/apache/log4j/pattern/FormattingInfo.java
deleted file mode 100644
index a51f9e2d3cd..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/pattern/FormattingInfo.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.pattern;
-
-/**
- * Modifies the output of a pattern converter for a specified minimum and maximum width and alignment.
- */
-public final class FormattingInfo {
- /**
- * Array of spaces.
- */
- private static final char[] SPACES = new char[] {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '};
-
- /**
- * Default instance.
- */
- private static final FormattingInfo DEFAULT = new FormattingInfo(false, 0, Integer.MAX_VALUE);
-
- /**
- * Gets default instance.
- *
- * @return default instance.
- */
- public static FormattingInfo getDefault() {
- return DEFAULT;
- }
-
- /**
- * Minimum length.
- */
- private final int minLength;
-
- /**
- * Maximum length.
- */
- private final int maxLength;
-
- /**
- * Alignment.
- */
- private final boolean leftAlign;
-
- /**
- * Creates new instance.
- *
- * @param leftAlign left align if true.
- * @param minLength minimum length.
- * @param maxLength maximum length.
- */
- public FormattingInfo(final boolean leftAlign, final int minLength, final int maxLength) {
- this.leftAlign = leftAlign;
- this.minLength = minLength;
- this.maxLength = maxLength;
- }
-
- /**
- * Adjust the content of the buffer based on the specified lengths and alignment.
- *
- * @param fieldStart start of field in buffer.
- * @param buffer buffer to be modified.
- */
- public void format(final int fieldStart, final StringBuffer buffer) {
- final int rawLength = buffer.length() - fieldStart;
-
- if (rawLength > maxLength) {
- buffer.delete(fieldStart, buffer.length() - maxLength);
- } else if (rawLength < minLength) {
- if (leftAlign) {
- final int fieldEnd = buffer.length();
- buffer.setLength(fieldStart + minLength);
-
- for (int i = fieldEnd; i < buffer.length(); i++) {
- buffer.setCharAt(i, ' ');
- }
- } else {
- int padLength = minLength - rawLength;
-
- for (; padLength > 8; padLength -= 8) {
- buffer.insert(fieldStart, SPACES);
- }
-
- buffer.insert(fieldStart, SPACES, 0, padLength);
- }
- }
- }
-
- /**
- * Get maximum length.
- *
- * @return maximum length.
- */
- public int getMaxLength() {
- return maxLength;
- }
-
- /**
- * Get minimum length.
- *
- * @return minimum length.
- */
- public int getMinLength() {
- return minLength;
- }
-
- /**
- * Determine if left aligned.
- *
- * @return true if left aligned.
- */
- public boolean isLeftAligned() {
- return leftAlign;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/pattern/Log4j1LevelPatternConverter.java b/log4j-1.2-api/src/main/java/org/apache/log4j/pattern/Log4j1LevelPatternConverter.java
deleted file mode 100644
index f93c9f8de2b..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/pattern/Log4j1LevelPatternConverter.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.pattern;
-
-import org.apache.log4j.helpers.OptionConverter;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.pattern.ConverterKeys;
-import org.apache.logging.log4j.core.pattern.LogEventPatternConverter;
-import org.apache.logging.log4j.core.pattern.PatternConverter;
-import org.apache.logging.log4j.plugins.Namespace;
-import org.apache.logging.log4j.plugins.Plugin;
-
-/**
- * Outputs the Log4j 1.x level name.
- */
-@Namespace(PatternConverter.CATEGORY)
-@Plugin("Log4j1LevelPatternConverter")
-@ConverterKeys({"v1Level"})
-public final class Log4j1LevelPatternConverter extends LogEventPatternConverter {
-
- private static final Log4j1LevelPatternConverter INSTANCE = new Log4j1LevelPatternConverter();
-
- public static Log4j1LevelPatternConverter newInstance(final String[] options) {
- return INSTANCE;
- }
-
- private Log4j1LevelPatternConverter() {
- super("Log4j1Level", "v1Level");
- }
-
- @Override
- public void format(final LogEvent event, final StringBuilder toAppendTo) {
- toAppendTo.append(OptionConverter.convertLevel(event.getLevel()).toString());
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/pattern/Log4j1MdcPatternConverter.java b/log4j-1.2-api/src/main/java/org/apache/log4j/pattern/Log4j1MdcPatternConverter.java
deleted file mode 100644
index 97a7b81675c..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/pattern/Log4j1MdcPatternConverter.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.pattern;
-
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.pattern.ConverterKeys;
-import org.apache.logging.log4j.core.pattern.LogEventPatternConverter;
-import org.apache.logging.log4j.core.pattern.PatternConverter;
-import org.apache.logging.log4j.plugins.Namespace;
-import org.apache.logging.log4j.plugins.Plugin;
-import org.apache.logging.log4j.util.TriConsumer;
-
-/**
- * Able to handle the contents of the LogEvent's MDC and either
- * output the entire contents of the properties, or to output the value of a specific key
- * within the property bundle when this pattern converter has the option set.
- */
-@Namespace(PatternConverter.CATEGORY)
-@Plugin("Log4j1MdcPatternConverter")
-@ConverterKeys({"properties"})
-public final class Log4j1MdcPatternConverter extends LogEventPatternConverter {
- /**
- * Name of property to output.
- */
- private final String key;
-
- /**
- * Private constructor.
- *
- * @param options options, may be null.
- */
- private Log4j1MdcPatternConverter(final String[] options) {
- super(options != null && options.length > 0 ? "Log4j1MDC{" + options[0] + '}' : "Log4j1MDC", "property");
- if (options != null && options.length > 0) {
- key = options[0];
- } else {
- key = null;
- }
- }
-
- /**
- * Obtains an instance of PropertiesPatternConverter.
- *
- * @param options options, may be null or first element contains name of property to format.
- * @return instance of PropertiesPatternConverter.
- */
- public static Log4j1MdcPatternConverter newInstance(final String[] options) {
- return new Log4j1MdcPatternConverter(options);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void format(final LogEvent event, final StringBuilder toAppendTo) {
- if (key == null) {
- // if there is no additional options, we output every single Key/Value pair for the MDC
- toAppendTo.append('{');
- event.getContextData().forEach(APPEND_EACH, toAppendTo);
- toAppendTo.append('}');
- } else {
- // otherwise they just want a single key output
- final Object val = event.getContextData().getValue(key);
- if (val != null) {
- toAppendTo.append(val);
- }
- }
- }
-
- private static TriConsumer APPEND_EACH = (key, value, toAppendTo) ->
- toAppendTo.append('{').append(key).append(',').append(value).append('}');
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/pattern/Log4j1NdcPatternConverter.java b/log4j-1.2-api/src/main/java/org/apache/log4j/pattern/Log4j1NdcPatternConverter.java
deleted file mode 100644
index cb86b09f907..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/pattern/Log4j1NdcPatternConverter.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.pattern;
-
-import java.util.List;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.pattern.ConverterKeys;
-import org.apache.logging.log4j.core.pattern.LogEventPatternConverter;
-import org.apache.logging.log4j.core.pattern.PatternConverter;
-import org.apache.logging.log4j.plugins.Namespace;
-import org.apache.logging.log4j.plugins.Plugin;
-import org.apache.logging.log4j.util.Strings;
-
-/**
- * Returns the event's NDC in a StringBuilder.
- */
-@Namespace(PatternConverter.CATEGORY)
-@Plugin("Log4j1NdcPatternConverter")
-@ConverterKeys({"ndc"})
-public final class Log4j1NdcPatternConverter extends LogEventPatternConverter {
- /**
- * Singleton.
- */
- private static final Log4j1NdcPatternConverter INSTANCE = new Log4j1NdcPatternConverter();
-
- /**
- * Private constructor.
- */
- private Log4j1NdcPatternConverter() {
- super("Log4j1NDC", "ndc");
- }
-
- /**
- * Obtains an instance of NdcPatternConverter.
- *
- * @param options options, may be null.
- * @return instance of NdcPatternConverter.
- */
- public static Log4j1NdcPatternConverter newInstance(final String[] options) {
- return INSTANCE;
- }
-
- @Override
- public void format(final LogEvent event, final StringBuilder toAppendTo) {
- final List ndc = event.getContextStack().asList();
- toAppendTo.append(Strings.join(ndc, ' '));
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/pattern/NameAbbreviator.java b/log4j-1.2-api/src/main/java/org/apache/log4j/pattern/NameAbbreviator.java
deleted file mode 100644
index fc7488fa57a..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/pattern/NameAbbreviator.java
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.pattern;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * NameAbbreviator generates abbreviated logger and class names.
- */
-public abstract class NameAbbreviator {
-
- /**
- * Abbreviator that drops starting path elements.
- */
- private static class DropElementAbbreviator extends NameAbbreviator {
- /**
- * Maximum number of path elements to output.
- */
- private final int count;
-
- /**
- * Create new instance.
- *
- * @param count maximum number of path elements to output.
- */
- public DropElementAbbreviator(final int count) {
- this.count = count;
- }
-
- /**
- * Abbreviate name.
- *
- * @param buf buffer to append abbreviation.
- * @param nameStart start of name to abbreviate.
- */
- @Override
- public void abbreviate(final int nameStart, final StringBuffer buf) {
- int i = count;
- for (int pos = buf.indexOf(".", nameStart); pos != -1; pos = buf.indexOf(".", pos + 1)) {
- if (--i == 0) {
- buf.delete(nameStart, pos + 1);
- break;
- }
- }
- }
- }
-
- /**
- * Abbreviator that drops starting path elements.
- */
- private static class MaxElementAbbreviator extends NameAbbreviator {
- /**
- * Maximum number of path elements to output.
- */
- private final int count;
-
- /**
- * Create new instance.
- *
- * @param count maximum number of path elements to output.
- */
- public MaxElementAbbreviator(final int count) {
- this.count = count;
- }
-
- /**
- * Abbreviate name.
- *
- * @param buf buffer to append abbreviation.
- * @param nameStart start of name to abbreviate.
- */
- @Override
- public void abbreviate(final int nameStart, final StringBuffer buf) {
- // We substract 1 from 'len' when assigning to 'end' to avoid out of
- // bounds exception in return r.substring(end+1, len). This can happen if
- // precision is 1 and the category name ends with a dot.
- int end = buf.length() - 1;
-
- final String bufString = buf.toString();
- for (int i = count; i > 0; i--) {
- end = bufString.lastIndexOf(".", end - 1);
-
- if ((end == -1) || (end < nameStart)) {
- return;
- }
- }
-
- buf.delete(nameStart, end + 1);
- }
- }
-
- /**
- * Abbreviator that simply appends full name to buffer.
- */
- private static class NOPAbbreviator extends NameAbbreviator {
- /**
- * Constructor.
- */
- public NOPAbbreviator() {}
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void abbreviate(final int nameStart, final StringBuffer buf) {}
- }
-
- /**
- * Pattern abbreviator.
- *
- *
- */
- private static class PatternAbbreviator extends NameAbbreviator {
- /**
- * Element abbreviation patterns.
- */
- private final PatternAbbreviatorFragment[] fragments;
-
- /**
- * Create PatternAbbreviator.
- *
- * @param fragments element abbreviation patterns.
- */
- public PatternAbbreviator(final List fragments) {
- if (fragments.size() == 0) {
- throw new IllegalArgumentException("fragments must have at least one element");
- }
-
- this.fragments = new PatternAbbreviatorFragment[fragments.size()];
- fragments.toArray(this.fragments);
- }
-
- /**
- * Abbreviate name.
- *
- * @param buf buffer that abbreviated name is appended.
- * @param nameStart start of name.
- */
- @Override
- public void abbreviate(final int nameStart, final StringBuffer buf) {
- //
- // all non-terminal patterns are executed once
- //
- int pos = nameStart;
-
- for (int i = 0; (i < (fragments.length - 1)) && (pos < buf.length()); i++) {
- pos = fragments[i].abbreviate(buf, pos);
- }
-
- //
- // last pattern in executed repeatedly
- //
- final PatternAbbreviatorFragment terminalFragment = fragments[fragments.length - 1];
-
- while ((pos < buf.length()) && (pos >= 0)) {
- pos = terminalFragment.abbreviate(buf, pos);
- }
- }
- }
-
- /**
- * Fragment of an pattern abbreviator.
- *
- */
- private static class PatternAbbreviatorFragment {
- /**
- * Count of initial characters of element to output.
- */
- private final int charCount;
-
- /**
- * Character used to represent dropped characters. '\0' indicates no representation of dropped characters.
- */
- private final char ellipsis;
-
- /**
- * Creates a PatternAbbreviatorFragment.
- *
- * @param charCount number of initial characters to preserve.
- * @param ellipsis character to represent elimination of characters, '\0' if no ellipsis is desired.
- */
- public PatternAbbreviatorFragment(final int charCount, final char ellipsis) {
- this.charCount = charCount;
- this.ellipsis = ellipsis;
- }
-
- /**
- * Abbreviate element of name.
- *
- * @param buf buffer to receive element.
- * @param startPos starting index of name element.
- * @return starting index of next element.
- */
- public int abbreviate(final StringBuffer buf, final int startPos) {
- int nextDot = buf.toString().indexOf(".", startPos);
-
- if (nextDot != -1) {
- if ((nextDot - startPos) > charCount) {
- buf.delete(startPos + charCount, nextDot);
- nextDot = startPos + charCount;
-
- if (ellipsis != '\0') {
- buf.insert(nextDot, ellipsis);
- nextDot++;
- }
- }
-
- nextDot++;
- }
-
- return nextDot;
- }
- }
-
- /**
- * Default (no abbreviation) abbreviator.
- */
- private static final NameAbbreviator DEFAULT = new NOPAbbreviator();
-
- /**
- * Gets an abbreviator.
- *
- * For example, "%logger{2}" will output only 2 elements of the logger name, %logger{-2} will drop 2 elements from the
- * logger name, "%logger{1.}" will output only the first character of the non-final elements in the name,
- * "%logger{1~.2~} will output the first character of the first element, two characters of the second and subsequent
- * elements and will use a tilde to indicate abbreviated characters.
- *
- * @param pattern abbreviation pattern.
- * @return abbreviator, will not be null.
- */
- public static NameAbbreviator getAbbreviator(final String pattern) {
- if (pattern.length() > 0) {
- // if pattern is just spaces and numbers then
- // use MaxElementAbbreviator
- final String trimmed = pattern.trim();
-
- if (trimmed.length() == 0) {
- return DEFAULT;
- }
-
- int i = 0;
- if (trimmed.length() > 0) {
- if (trimmed.charAt(0) == '-') {
- i++;
- }
- for (; (i < trimmed.length()) && (trimmed.charAt(i) >= '0') && (trimmed.charAt(i) <= '9'); i++) {}
- }
-
- //
- // if all blanks and digits
- //
- if (i == trimmed.length()) {
- final int elements = Integer.parseInt(trimmed);
- if (elements >= 0) {
- return new MaxElementAbbreviator(elements);
- } else {
- return new DropElementAbbreviator(-elements);
- }
- }
-
- final ArrayList fragments = new ArrayList(5);
- char ellipsis;
- int charCount;
- int pos = 0;
-
- while ((pos < trimmed.length()) && (pos >= 0)) {
- int ellipsisPos = pos;
-
- if (trimmed.charAt(pos) == '*') {
- charCount = Integer.MAX_VALUE;
- ellipsisPos++;
- } else {
- if ((trimmed.charAt(pos) >= '0') && (trimmed.charAt(pos) <= '9')) {
- charCount = trimmed.charAt(pos) - '0';
- ellipsisPos++;
- } else {
- charCount = 0;
- }
- }
-
- ellipsis = '\0';
-
- if (ellipsisPos < trimmed.length()) {
- ellipsis = trimmed.charAt(ellipsisPos);
-
- if (ellipsis == '.') {
- ellipsis = '\0';
- }
- }
-
- fragments.add(new PatternAbbreviatorFragment(charCount, ellipsis));
- pos = trimmed.indexOf(".", pos);
-
- if (pos == -1) {
- break;
- }
-
- pos++;
- }
-
- return new PatternAbbreviator(fragments);
- }
-
- //
- // no matching abbreviation, return defaultAbbreviator
- //
- return DEFAULT;
- }
-
- /**
- * Gets default abbreviator.
- *
- * @return default abbreviator.
- */
- public static NameAbbreviator getDefaultAbbreviator() {
- return DEFAULT;
- }
-
- /**
- * Abbreviates a name in a StringBuffer.
- *
- * @param nameStart starting position of name in buf.
- * @param buf buffer, may not be null.
- */
- public abstract void abbreviate(final int nameStart, final StringBuffer buf);
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/pattern/package-info.java b/log4j-1.2-api/src/main/java/org/apache/log4j/pattern/package-info.java
deleted file mode 100644
index dea0a473e4e..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/pattern/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-@Export
-@Version("2.20.1")
-package org.apache.log4j.pattern;
-
-import org.osgi.annotation.bundle.Export;
-import org.osgi.annotation.versioning.Version;
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/rewrite/MapRewritePolicy.java b/log4j-1.2-api/src/main/java/org/apache/log4j/rewrite/MapRewritePolicy.java
deleted file mode 100644
index f62f9fb0f6c..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/rewrite/MapRewritePolicy.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.rewrite;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.log4j.bridge.LogEventAdapter;
-import org.apache.log4j.helpers.OptionConverter;
-import org.apache.log4j.spi.LocationInfo;
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.impl.Log4jLogEvent;
-import org.apache.logging.log4j.message.MapMessage;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.message.SimpleMessage;
-import org.apache.logging.log4j.util.SortedArrayStringMap;
-
-/**
- * This policy rewrites events where the message of the
- * original event implements java.util.Map.
- * All other events are passed through unmodified.
- * If the map contains a "message" entry, the value will be
- * used as the message for the rewritten event. The rewritten
- * event will have a property set that is the combination of the
- * original property set and the other members of the message map.
- * If both the original property set and the message map
- * contain the same entry, the value from the message map
- * will overwrite the original property set.
- *
- * The combination of the RewriteAppender and this policy
- * performs the same actions as the MapFilter from log4j 1.3.
- *
- */
-public class MapRewritePolicy implements RewritePolicy {
- /**
- * {@inheritDoc}
- */
- @Override
- public LoggingEvent rewrite(final LoggingEvent source) {
- final Object msg = source.getMessage();
- if (msg instanceof MapMessage || msg instanceof Map) {
- final Map props =
- source.getProperties() != null ? new HashMap<>(source.getProperties()) : new HashMap<>();
- @SuppressWarnings("unchecked")
- final Map eventProps = msg instanceof Map ? (Map) msg : ((MapMessage) msg).getData();
- //
- // if the map sent in the logging request
- // has "message" entry, use that as the message body
- // otherwise, use the entire map.
- //
- Message newMessage = null;
- final Object newMsg = eventProps.get("message");
- if (newMsg != null) {
- newMessage = new SimpleMessage(newMsg.toString());
- for (Map.Entry entry : eventProps.entrySet()) {
- if (!("message".equals(entry.getKey()))) {
- props.put(entry.getKey(), entry.getValue().toString());
- }
- }
- } else {
- return source;
- }
-
- LogEvent event;
- if (source instanceof LogEventAdapter) {
- event = new Log4jLogEvent.Builder(((LogEventAdapter) source).getEvent())
- .setMessage(newMessage)
- .setContextData(new SortedArrayStringMap(props))
- .build();
- } else {
- final LocationInfo info = source.getLocationInformation();
- final StackTraceElement element = new StackTraceElement(
- info.getClassName(),
- info.getMethodName(),
- info.getFileName(),
- Integer.parseInt(info.getLineNumber()));
- final Thread thread = getThread(source.getThreadName());
- final long threadId = thread != null ? thread.getId() : 0;
- final int threadPriority = thread != null ? thread.getPriority() : 0;
- event = Log4jLogEvent.newBuilder()
- .setContextData(new SortedArrayStringMap(props))
- .setLevel(OptionConverter.convertLevel(source.getLevel()))
- .setLoggerFqcn(source.getFQNOfLoggerClass())
- .setMarker(null)
- .setMessage(newMessage)
- .setSource(element)
- .setLoggerName(source.getLoggerName())
- .setThreadName(source.getThreadName())
- .setThreadId(threadId)
- .setThreadPriority(threadPriority)
- .setThrown(source.getThrowableInformation().getThrowable())
- .setTimeMillis(source.getTimeStamp())
- .setNanoTime(0)
- .setThrownProxy(null)
- .build();
- }
- return new LogEventAdapter(event);
- }
- return source;
- }
-
- private Thread getThread(final String name) {
- for (Thread thread : Thread.getAllStackTraces().keySet()) {
- if (thread.getName().equals(name)) {
- return thread;
- }
- }
- return null;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/rewrite/PropertyRewritePolicy.java b/log4j-1.2-api/src/main/java/org/apache/log4j/rewrite/PropertyRewritePolicy.java
deleted file mode 100644
index fd99674f405..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/rewrite/PropertyRewritePolicy.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.rewrite;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.StringTokenizer;
-import org.apache.log4j.bridge.LogEventAdapter;
-import org.apache.log4j.helpers.OptionConverter;
-import org.apache.log4j.spi.LocationInfo;
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.impl.Log4jLogEvent;
-import org.apache.logging.log4j.message.SimpleMessage;
-import org.apache.logging.log4j.util.SortedArrayStringMap;
-
-/**
- * This policy rewrites events by adding
- * a user-specified list of properties to the event.
- * Existing properties are not modified.
- *
- * The combination of the RewriteAppender and this policy
- * performs the same actions as the PropertyFilter from log4j 1.3.
- *
- */
-public class PropertyRewritePolicy implements RewritePolicy {
- private Map properties = Collections.EMPTY_MAP;
-
- public PropertyRewritePolicy() {}
-
- /**
- * Set a string representing the property name/value pairs.
- *
- * Form:
- *
- *
- * propname1=propvalue1,propname2=propvalue2
- *
- *
- * @param properties The properties.
- */
- public void setProperties(final String properties) {
- final Map newMap = new HashMap<>();
- final StringTokenizer pairs = new StringTokenizer(properties, ",");
- while (pairs.hasMoreTokens()) {
- final StringTokenizer entry = new StringTokenizer(pairs.nextToken(), "=");
- newMap.put(
- entry.nextElement().toString().trim(),
- entry.nextElement().toString().trim());
- }
- synchronized (this) {
- this.properties = newMap;
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public LoggingEvent rewrite(final LoggingEvent source) {
- if (!properties.isEmpty()) {
- final Map rewriteProps =
- source.getProperties() != null ? new HashMap<>(source.getProperties()) : new HashMap<>();
- for (Map.Entry entry : properties.entrySet()) {
- if (!rewriteProps.containsKey(entry.getKey())) {
- rewriteProps.put(entry.getKey(), entry.getValue());
- }
- }
- LogEvent event;
- if (source instanceof LogEventAdapter) {
- event = new Log4jLogEvent.Builder(((LogEventAdapter) source).getEvent())
- .setContextData(new SortedArrayStringMap(rewriteProps))
- .build();
- } else {
- final LocationInfo info = source.getLocationInformation();
- final StackTraceElement element = new StackTraceElement(
- info.getClassName(),
- info.getMethodName(),
- info.getFileName(),
- Integer.parseInt(info.getLineNumber()));
- final Thread thread = getThread(source.getThreadName());
- final long threadId = thread != null ? thread.getId() : 0;
- final int threadPriority = thread != null ? thread.getPriority() : 0;
- event = Log4jLogEvent.newBuilder()
- .setContextData(new SortedArrayStringMap(rewriteProps))
- .setLevel(OptionConverter.convertLevel(source.getLevel()))
- .setLoggerFqcn(source.getFQNOfLoggerClass())
- .setMarker(null)
- .setMessage(new SimpleMessage(source.getRenderedMessage()))
- .setSource(element)
- .setLoggerName(source.getLoggerName())
- .setThreadName(source.getThreadName())
- .setThreadId(threadId)
- .setThreadPriority(threadPriority)
- .setThrown(source.getThrowableInformation().getThrowable())
- .setTimeMillis(source.getTimeStamp())
- .setNanoTime(0)
- .setThrownProxy(null)
- .build();
- }
- return new LogEventAdapter(event);
- }
- return source;
- }
-
- private Thread getThread(final String name) {
- for (Thread thread : Thread.getAllStackTraces().keySet()) {
- if (thread.getName().equals(name)) {
- return thread;
- }
- }
- return null;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/rewrite/RewritePolicy.java b/log4j-1.2-api/src/main/java/org/apache/log4j/rewrite/RewritePolicy.java
deleted file mode 100644
index 36b051fc0c5..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/rewrite/RewritePolicy.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.rewrite;
-
-import org.apache.log4j.spi.LoggingEvent;
-
-/**
- * This interface is implemented to provide a rewrite
- * strategy for RewriteAppender. RewriteAppender will
- * call the rewrite method with a source logging event.
- * The strategy may return that event, create a new event
- * or return null to suppress the logging request.
- */
-public interface RewritePolicy {
- /**
- * Rewrite a logging event.
- * @param source a logging event that may be returned or
- * used to create a new logging event.
- * @return a logging event or null to suppress processing.
- */
- LoggingEvent rewrite(final LoggingEvent source);
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/rewrite/package-info.java b/log4j-1.2-api/src/main/java/org/apache/log4j/rewrite/package-info.java
deleted file mode 100644
index 154ce83725b..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/rewrite/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-@Export
-@Version("2.20.1")
-package org.apache.log4j.rewrite;
-
-import org.osgi.annotation.bundle.Export;
-import org.osgi.annotation.versioning.Version;
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/AppenderAttachable.java b/log4j-1.2-api/src/main/java/org/apache/log4j/spi/AppenderAttachable.java
deleted file mode 100644
index 8bc4a43f803..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/AppenderAttachable.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.spi;
-
-import java.util.Enumeration;
-import org.apache.log4j.Appender;
-
-/**
- * Interface for attaching appenders to objects.
- */
-public interface AppenderAttachable {
-
- /**
- * Add an appender.
- * @param newAppender The Appender to add.
- */
- void addAppender(Appender newAppender);
-
- /**
- * Get all previously added appenders as an Enumeration.
- * @return The Enumeration of the Appenders.
- */
- Enumeration getAllAppenders();
-
- /**
- * Get an appender by name.
- * @param name The name of the Appender.
- * @return The Appender.
- */
- Appender getAppender(String name);
-
- /**
- * Returns true
if the specified appender is in list of
- * attached, false
otherwise.
- * @param appender The Appender to check.
- * @return true if the Appender is attached.
- *
- * @since 1.2
- */
- boolean isAttached(Appender appender);
-
- /**
- * Remove all previously added appenders.
- */
- void removeAllAppenders();
-
- /**
- * Remove the appender passed as parameter from the list of appenders.
- * @param appender The Appender to remove.
- */
- void removeAppender(Appender appender);
-
- /**
- * Remove the appender with the name passed as parameter from the
- * list of appenders.
- * @param name The name of the Appender to remove.
- */
- void removeAppender(String name);
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/Configurator.java b/log4j-1.2-api/src/main/java/org/apache/log4j/spi/Configurator.java
deleted file mode 100644
index a3f790ec5b1..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/Configurator.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.spi;
-
-import java.io.InputStream;
-import java.net.URL;
-
-/**
- * Log4j 1.x Configurator interface.
- */
-public interface Configurator {
-
- /**
- * Special level value signifying inherited behavior. The current value of this string constant is inherited .
- * {@link #NULL} is a synonym.
- */
- public static final String INHERITED = "inherited";
-
- /**
- * Special level signifying inherited behavior, same as {@link #INHERITED}. The current value of this string constant
- * is null .
- */
- public static final String NULL = "null";
-
- /**
- * Interpret a resource pointed by a InputStream and set up log4j accordingly.
- *
- * The configuration is done relative to the hierarchy
parameter.
- *
- * @param inputStream The InputStream to parse
- * @param loggerRepository The hierarchy to operation upon.
- *
- * @since 1.2.17
- */
- void doConfigure(InputStream inputStream, final LoggerRepository loggerRepository);
-
- /**
- * Interpret a resource pointed by a URL and set up log4j accordingly.
- *
- * The configuration is done relative to the hierarchy
parameter.
- *
- * @param url The URL to parse
- * @param loggerRepository The hierarchy to operation upon.
- */
- void doConfigure(URL url, final LoggerRepository loggerRepository);
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/DefaultRepositorySelector.java b/log4j-1.2-api/src/main/java/org/apache/log4j/spi/DefaultRepositorySelector.java
deleted file mode 100644
index 5b51f5dd7d8..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/DefaultRepositorySelector.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.spi;
-
-public class DefaultRepositorySelector implements RepositorySelector {
-
- final LoggerRepository repository;
-
- public DefaultRepositorySelector(final LoggerRepository repository) {
- this.repository = repository;
- }
-
- @Override
- public LoggerRepository getLoggerRepository() {
- return repository;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/ErrorCode.java b/log4j-1.2-api/src/main/java/org/apache/log4j/spi/ErrorCode.java
deleted file mode 100644
index b18367feaa6..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/ErrorCode.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.spi;
-
-/**
- * This interface defines commonly encountered error codes.
- */
-public interface ErrorCode {
-
- public final int GENERIC_FAILURE = 0;
- public final int WRITE_FAILURE = 1;
- public final int FLUSH_FAILURE = 2;
- public final int CLOSE_FAILURE = 3;
- public final int FILE_OPEN_FAILURE = 4;
- public final int MISSING_LAYOUT = 5;
- public final int ADDRESS_PARSE_FAILURE = 6;
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/ErrorHandler.java b/log4j-1.2-api/src/main/java/org/apache/log4j/spi/ErrorHandler.java
deleted file mode 100644
index 5e94d343b38..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/ErrorHandler.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.spi;
-
-import org.apache.log4j.Appender;
-import org.apache.log4j.Logger;
-
-/**
- * Appenders may delegate their error handling to
- * ErrorHandlers
.
- *
- * Error handling is a particularly tedious to get right because by
- * definition errors are hard to predict and to reproduce.
- *
- */
-public interface ErrorHandler {
-
- /**
- * Add a reference to a logger to which the failing appender might
- * be attached to. The failing appender will be searched and
- * replaced only in the loggers you add through this method.
- *
- * @param logger One of the loggers that will be searched for the failing
- * appender in view of replacement.
- * @since 1.2
- */
- void setLogger(Logger logger);
-
- /**
- * Equivalent to the {@link #error(String, Exception, int,
- * LoggingEvent)} with the event parameter set to
- * null
.
- *
- * @param message The message associated with the error.
- * @param e The Exception that was thrown when the error occurred.
- * @param errorCode The error code associated with the error.
- */
- void error(String message, Exception e, int errorCode);
-
- /**
- * This method is normally used to just print the error message
- * passed as a parameter.
- *
- * @param message The message associated with the error.
- */
- void error(String message);
-
- /**
- * This method is invoked to handle the error.
- *
- * @param message The message associated with the error.
- * @param e The Exception that was thrown when the error occurred.
- * @param errorCode The error code associated with the error.
- * @param event The logging event that the failing appender is asked
- * to log.
- * @since 1.2
- */
- void error(String message, Exception e, int errorCode, LoggingEvent event);
-
- /**
- * Set the appender for which errors are handled. This method is
- * usually called when the error handler is configured.
- *
- * @param appender The appender
- * @since 1.2
- */
- void setAppender(Appender appender);
-
- /**
- * Set the appender to fallback upon in case of failure.
- *
- * @param appender The backup appender
- * @since 1.2
- */
- void setBackupAppender(Appender appender);
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/Filter.java b/log4j-1.2-api/src/main/java/org/apache/log4j/spi/Filter.java
deleted file mode 100644
index 12026824a9f..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/Filter.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.spi;
-
-/**
- * @since 0.9.0
- */
-public abstract class Filter {
-
- static {
- boolean temp;
- try {
- temp = Class.forName("org.apache.logging.log4j.core.Filter") != null;
- } catch (Exception | LinkageError e) {
- temp = false;
- }
- isCorePresent = temp;
- }
-
- /**
- * The log event must be dropped immediately without consulting
- * with the remaining filters, if any, in the chain.
- */
- public static final int DENY = -1;
-
- /**
- * This filter is neutral with respect to the log event. The
- * remaining filters, if any, should be consulted for a final decision.
- */
- public static final int NEUTRAL = 0;
-
- /**
- * The log event must be logged immediately without consulting with
- * the remaining filters, if any, in the chain.
- */
- public static final int ACCEPT = 1;
-
- /**
- * Points to the next filter in the filter chain.
- *
- * @deprecated As of 1.2.12, use {@link #getNext} and {@link #setNext} instead
- */
- @Deprecated
- public Filter next;
-
- private static final boolean isCorePresent;
-
- /**
- * Usually filters options become active when set. We provide a
- * default do-nothing implementation for convenience.
- */
- public void activateOptions() {
- // noop
- }
-
- /**
- * If the decision is DENY
, then the event will be
- * dropped. If the decision is NEUTRAL
, then the next
- * filter, if any, will be invoked. If the decision is ACCEPT then
- * the event will be logged without consulting with other filters in
- * the chain.
- *
- * @param event The LoggingEvent to decide upon.
- * @return decision The decision of the filter.
- */
- public abstract int decide(LoggingEvent event);
-
- /**
- * Set the next filter pointer.
- * @param next The next Filter.
- */
- public void setNext(final Filter next) {
- this.next = next;
- }
-
- /**
- * Return the pointer to the next filter.
- * @return The next Filter.
- */
- public Filter getNext() {
- return next;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/HierarchyEventListener.java b/log4j-1.2-api/src/main/java/org/apache/log4j/spi/HierarchyEventListener.java
deleted file mode 100644
index db39828f6a1..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/HierarchyEventListener.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.spi;
-
-import org.apache.log4j.Appender;
-import org.apache.log4j.Category;
-
-/**
- * Listen to events occurring within a Hierarchy.
- *
- * @since 1.2
- *
- */
-public interface HierarchyEventListener {
-
- void addAppenderEvent(Category cat, Appender appender);
-
- void removeAppenderEvent(Category cat, Appender appender);
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/LocationInfo.java b/log4j-1.2-api/src/main/java/org/apache/log4j/spi/LocationInfo.java
deleted file mode 100644
index d705b856f55..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/LocationInfo.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.spi;
-
-import java.io.Serializable;
-import java.util.Objects;
-import org.apache.logging.log4j.core.util.Integers;
-
-/**
- * The internal representation of caller location information.
- *
- * @since 0.8.3
- */
-public class LocationInfo implements Serializable {
-
- /**
- * When location information is not available the constant NA
is returned. Current value of this string
- * constant is ? .
- */
- public static final String NA = "?";
-
- static final long serialVersionUID = -1325822038990805636L;
-
- private final StackTraceElement stackTraceElement;
-
- public String fullInfo;
-
- /**
- * Constructs a new instance.
- */
- public LocationInfo(final StackTraceElement stackTraceElement) {
- this.stackTraceElement = Objects.requireNonNull(stackTraceElement, "stackTraceElement");
- this.fullInfo = stackTraceElement.toString();
- }
-
- /**
- * Constructs a new instance.
- *
- * @param file source file name
- * @param declaringClass class name
- * @param methodName method
- * @param line source line number
- *
- * @since 1.2.15
- */
- public LocationInfo(final String file, final String declaringClass, final String methodName, final String line) {
- this(new StackTraceElement(declaringClass, methodName, file, Integer.parseInt(line)));
- }
-
- /**
- * Constructs a new instance.
- */
- public LocationInfo(final Throwable throwable, final String fqnOfCallingClass) {
- String declaringClass = null, methodName = null, file = null, line = null;
- if (throwable != null && fqnOfCallingClass != null) {
- final StackTraceElement[] elements = throwable.getStackTrace();
- String prevClass = NA;
- for (int i = elements.length - 1; i >= 0; i--) {
- final String thisClass = elements[i].getClassName();
- if (fqnOfCallingClass.equals(thisClass)) {
- final int caller = i + 1;
- if (caller < elements.length) {
- declaringClass = prevClass;
- methodName = elements[caller].getMethodName();
- file = elements[caller].getFileName();
- if (file == null) {
- file = NA;
- }
- final int lineNo = elements[caller].getLineNumber();
- if (lineNo < 0) {
- line = NA;
- } else {
- line = String.valueOf(lineNo);
- }
- final StringBuilder builder = new StringBuilder();
- builder.append(declaringClass);
- builder.append(".");
- builder.append(methodName);
- builder.append("(");
- builder.append(file);
- builder.append(":");
- builder.append(line);
- builder.append(")");
- this.fullInfo = builder.toString();
- }
- break;
- }
- prevClass = thisClass;
- }
- }
- if (declaringClass != null && methodName != null) {
- this.stackTraceElement = new StackTraceElement(declaringClass, methodName, file, Integers.parseInt(line));
- this.fullInfo = stackTraceElement.toString();
- } else {
- this.stackTraceElement = null;
- this.fullInfo = null;
- }
- }
-
- /**
- * Gets the fully qualified class name of the caller making the logging request.
- */
- public String getClassName() {
- return stackTraceElement != null ? stackTraceElement.getClassName() : NA;
- }
-
- /**
- * Gets the file name of the caller.
- */
- public String getFileName() {
- return stackTraceElement != null ? stackTraceElement.getFileName() : NA;
- }
-
- /**
- * Gets the line number of the caller.
- */
- public String getLineNumber() {
- return stackTraceElement != null ? Integer.toString(stackTraceElement.getLineNumber()) : NA;
- }
-
- /**
- * Gets the method name of the caller.
- */
- public String getMethodName() {
- return stackTraceElement != null ? stackTraceElement.getMethodName() : NA;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/LoggerFactory.java b/log4j-1.2-api/src/main/java/org/apache/log4j/spi/LoggerFactory.java
deleted file mode 100644
index 1cca0912d4c..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/LoggerFactory.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.spi;
-
-import org.apache.log4j.Logger;
-
-/**
- * Implement this interface to create new instances of Logger or a sub-class of Logger.
- *
- *
- * See examples/subclass/MyLogger.java
for an example.
- *
- */
-public interface LoggerFactory {
-
- Logger makeNewLoggerInstance(String name);
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/LoggerRepository.java b/log4j-1.2-api/src/main/java/org/apache/log4j/spi/LoggerRepository.java
deleted file mode 100644
index 3820f075d86..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/LoggerRepository.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.spi;
-
-import java.util.Enumeration;
-import org.apache.log4j.Appender;
-import org.apache.log4j.Category;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-
-/**
- * A LoggerRepository
is used to create and retrieve Loggers
.
- *
- * The relation between loggers in a repository depends on the repository but typically loggers are arranged in a named
- * hierarchy.
- *
- *
- * In addition to the creational methods, a LoggerRepository
can be queried for existing loggers, can act
- * as a point of registry for events related to loggers.
- *
- *
- * @since 1.2
- */
-public interface LoggerRepository {
-
- /**
- * Add a {@link HierarchyEventListener} event to the repository.
- *
- * @param listener The listener
- */
- void addHierarchyEventListener(HierarchyEventListener listener);
-
- /**
- * Returns whether this repository is disabled for a given
- * level. The answer depends on the repository threshold and the
- * level
parameter. See also {@link #setThreshold}
- * method.
- *
- * @param level The level
- * @return whether this repository is disabled.
- */
- boolean isDisabled(int level);
-
- /**
- * Set the repository-wide threshold. All logging requests below the
- * threshold are immediately dropped. By default, the threshold is
- * set to Level.ALL
which has the lowest possible rank.
- *
- * @param level The level
- */
- void setThreshold(Level level);
-
- /**
- * Another form of {@link #setThreshold(Level)} accepting a string
- * parameter instead of a Level
.
- *
- * @param val The threshold value
- */
- void setThreshold(String val);
-
- void emitNoAppenderWarning(Category cat);
-
- /**
- * Get the repository-wide threshold. See {@link #setThreshold(Level)} for an explanation.
- *
- * @return the level.
- */
- Level getThreshold();
-
- Logger getLogger(String name);
-
- Logger getLogger(String name, LoggerFactory factory);
-
- Logger getRootLogger();
-
- Logger exists(String name);
-
- void shutdown();
-
- @SuppressWarnings("rawtypes")
- Enumeration getCurrentLoggers();
-
- /**
- * Deprecated. Please use {@link #getCurrentLoggers} instead.
- *
- * @return an enumeration of loggers.
- */
- @SuppressWarnings("rawtypes")
- Enumeration getCurrentCategories();
-
- void fireAddAppenderEvent(Category logger, Appender appender);
-
- void resetConfiguration();
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/LoggingEvent.java b/log4j-1.2-api/src/main/java/org/apache/log4j/spi/LoggingEvent.java
deleted file mode 100644
index f17f56603de..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/LoggingEvent.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.spi;
-
-import java.util.Map;
-import java.util.Set;
-import org.apache.log4j.Category;
-import org.apache.log4j.Level;
-import org.apache.log4j.Priority;
-import org.apache.log4j.bridge.LogEventAdapter;
-
-/**
- * No-op version of Log4j 1.2 LoggingEvent. This class is not directly used by Log4j 1.x clients but is used by
- * the Log4j 2 LogEvent adapter to be compatible with Log4j 1.x components.
- */
-public class LoggingEvent {
-
- /**
- * Returns the time when the application started, in milliseconds
- * elapsed since 01.01.1970.
- * @return the JVM start time.
- */
- public static long getStartTime() {
- return LogEventAdapter.getStartTime();
- }
-
- /**
- * The number of milliseconds elapsed from 1/1/1970 until logging event was created.
- */
- public final long timeStamp;
-
- /**
- * Constructs a new instance.
- */
- public LoggingEvent() {
- timeStamp = System.currentTimeMillis();
- }
-
- /**
- * Create new instance.
- *
- * @since 1.2.15
- * @param fqnOfCategoryClass Fully qualified class name of Logger implementation.
- * @param logger The logger generating this event.
- * @param timeStamp the timestamp of this logging event
- * @param level The level of this event.
- * @param message The message of this event.
- * @param threadName thread name
- * @param throwable The throwable of this event.
- * @param ndc Nested diagnostic context
- * @param info Location info
- * @param properties MDC properties
- */
- public LoggingEvent(
- final String fqnOfCategoryClass,
- final Category logger,
- final long timeStamp,
- final Level level,
- final Object message,
- final String threadName,
- final ThrowableInformation throwable,
- final String ndc,
- final LocationInfo info,
- final Map properties) {
- this.timeStamp = timeStamp;
- }
-
- /**
- * Instantiate a LoggingEvent from the supplied parameters.
- *
- *
- * Except {@link #timeStamp} all the other fields of LoggingEvent
are filled when actually needed.
- *
- *
- * @param logger The logger generating this event.
- * @param timeStamp the timestamp of this logging event
- * @param level The level of this event.
- * @param message The message of this event.
- * @param throwable The throwable of this event.
- */
- public LoggingEvent(
- String fqnOfCategoryClass,
- Category logger,
- long timeStamp,
- Priority level,
- Object message,
- Throwable throwable) {
- this.timeStamp = timeStamp;
- }
-
- /**
- * Instantiate a LoggingEvent from the supplied parameters.
- *
- *
- * Except {@link #timeStamp} all the other fields of LoggingEvent
are filled when actually needed.
- *
- *
- * @param logger The logger generating this event.
- * @param level The level of this event.
- * @param message The message of this event.
- * @param throwable The throwable of this event.
- */
- public LoggingEvent(
- final String fqnOfCategoryClass,
- final Category logger,
- final Priority level,
- final Object message,
- final Throwable throwable) {
- timeStamp = System.currentTimeMillis();
- }
-
- public String getFQNOfLoggerClass() {
- return null;
- }
-
- /**
- * Return the level of this event. Use this form instead of directly
- * accessing the level
field.
- * @return Always returns null.
- */
- public Level getLevel() {
- return null;
- }
-
- /**
- * Set the location information for this logging event. The collected
- * information is cached for future use.
- * @return Always returns null.
- */
- public LocationInfo getLocationInformation() {
- return null;
- }
-
- /**
- * Gets the logger of the event.
- * Use should be restricted to cloning events.
- * @return Always returns null.
- * @since 1.2.15
- */
- public Category getLogger() {
- return null;
- }
-
- /**
- * Return the name of the logger. Use this form instead of directly
- * accessing the categoryName
field.
- * @return Always returns null.
- */
- public String getLoggerName() {
- return null;
- }
-
- public Object getMDC(final String key) {
- return null;
- }
-
- /**
- * Obtain a copy of this thread's MDC prior to serialization or
- * asynchronous logging.
- */
- public void getMDCCopy() {}
-
- /**
- * Return the message for this logging event.
- *
- *
Before serialization, the returned object is the message
- * passed by the user to generate the logging event. After
- * serialization, the returned value equals the String form of the
- * message possibly after object rendering.
- * @return Always returns null.
- * @since 1.1 */
- public Object getMessage() {
- return null;
- }
-
- public String getNDC() {
- return null;
- }
-
- public Map getProperties() {
- return null;
- }
-
- public String getProperty(final String key) {
- return null;
- }
-
- public Set getPropertyKeySet() {
- return null;
- }
-
- public String getRenderedMessage() {
- return null;
- }
-
- public String getThreadName() {
- return null;
- }
-
- /**
- * Returns the throwable information contained within this
- * event. May be null
if there is no such information.
- *
- *
Note that the {@link Throwable} object contained within a
- * {@link ThrowableInformation} does not survive serialization.
- * @return Always returns null.
- * @since 1.1 */
- public ThrowableInformation getThrowableInformation() {
- return null;
- }
-
- /**
- * Return this event's throwable's string[] representation.
- * @return Always returns null.
- */
- public String[] getThrowableStrRep() {
- return null;
- }
-
- public long getTimeStamp() {
- return 0;
- }
-
- public Object removeProperty(final String propName) {
- return null;
- }
-
- public void setProperty(final String propName, final String propValue) {}
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/NOPLogger.java b/log4j-1.2-api/src/main/java/org/apache/log4j/spi/NOPLogger.java
deleted file mode 100644
index c47a30f019e..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/NOPLogger.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.spi;
-
-import java.util.Enumeration;
-import java.util.ResourceBundle;
-import java.util.Vector;
-import org.apache.log4j.Appender;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.Priority;
-
-/**
- * No-operation implementation of Logger used by NOPLoggerRepository.
- *
- * @since 1.2.15
- */
-public final class NOPLogger extends Logger {
-
- /**
- * Create instance of Logger.
- *
- * @param repo repository, may not be null.
- * @param name name, may not be null, use "root" for root logger.
- */
- public NOPLogger(final NOPLoggerRepository repo, final String name) {
- super(name);
- this.repository = repo;
- this.level = Level.OFF;
- this.parent = this;
- }
-
- /** {@inheritDoc} */
- @Override
- public void addAppender(final Appender newAppender) {
- // NOP
- }
-
- /** {@inheritDoc} */
- @Override
- public void assertLog(final boolean assertion, final String msg) {
- // NOP
- }
-
- /** {@inheritDoc} */
- @Override
- public void callAppenders(final LoggingEvent event) {
- // NOP
- }
-
- void closeNestedAppenders() {
- // NOP
- }
-
- /** {@inheritDoc} */
- @Override
- public void debug(final Object message) {
- // NOP
- }
-
- /** {@inheritDoc} */
- @Override
- public void debug(final Object message, final Throwable t) {
- // NOP
- }
-
- /** {@inheritDoc} */
- @Override
- public void error(final Object message) {
- // NOP
- }
-
- /** {@inheritDoc} */
- @Override
- public void error(final Object message, final Throwable t) {
- // NOP
- }
-
- /** {@inheritDoc} */
- @Override
- public void fatal(final Object message) {
- // NOP
- }
-
- /** {@inheritDoc} */
- @Override
- public void fatal(final Object message, final Throwable t) {
- // NOP
- }
-
- /** {@inheritDoc} */
- @Override
- public Enumeration getAllAppenders() {
- return new Vector<>().elements();
- }
-
- /** {@inheritDoc} */
- @Override
- public Appender getAppender(final String name) {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override
- public Priority getChainedPriority() {
- return getEffectiveLevel();
- }
-
- /** {@inheritDoc} */
- @Override
- public Level getEffectiveLevel() {
- return Level.OFF;
- }
-
- /** {@inheritDoc} */
- @Override
- public ResourceBundle getResourceBundle() {
- return null;
- }
-
- /** {@inheritDoc} */
- @Override
- public void info(final Object message) {
- // NOP
- }
-
- /** {@inheritDoc} */
- @Override
- public void info(final Object message, final Throwable t) {
- // NOP
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isAttached(final Appender appender) {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isDebugEnabled() {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isEnabledFor(final Priority level) {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isInfoEnabled() {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
- public boolean isTraceEnabled() {
- return false;
- }
-
- /** {@inheritDoc} */
- @Override
- public void l7dlog(final Priority priority, final String key, final Object[] params, final Throwable t) {
- // NOP
- }
-
- /** {@inheritDoc} */
- @Override
- public void l7dlog(final Priority priority, final String key, final Throwable t) {
- // NOP
- }
-
- /** {@inheritDoc} */
- @Override
- public void log(final Priority priority, final Object message) {
- // NOP
- }
-
- /** {@inheritDoc} */
- @Override
- public void log(final Priority priority, final Object message, final Throwable t) {
- // NOP
- }
-
- /** {@inheritDoc} */
- @Override
- public void log(final String callerFQCN, final Priority level, final Object message, final Throwable t) {
- // NOP
- }
-
- /** {@inheritDoc} */
- @Override
- public void removeAllAppenders() {
- // NOP
- }
-
- /** {@inheritDoc} */
- @Override
- public void removeAppender(final Appender appender) {
- // NOP
- }
-
- /** {@inheritDoc} */
- @Override
- public void removeAppender(final String name) {
- // NOP
- }
-
- /** {@inheritDoc} */
- @Override
- public void setLevel(final Level level) {
- // NOP
- }
-
- /** {@inheritDoc} */
- @Override
- public void setPriority(final Priority priority) {
- // NOP
- }
-
- /** {@inheritDoc} */
- @Override
- public void setResourceBundle(final ResourceBundle bundle) {
- // NOP
- }
-
- /** {@inheritDoc} */
- @Override
- public void trace(final Object message) {
- // NOP
- }
-
- /** {@inheritDoc} */
- @Override
- public void trace(final Object message, final Throwable t) {
- // NOP
- }
-
- /** {@inheritDoc} */
- @Override
- public void warn(final Object message) {
- // NOP
- }
-
- /** {@inheritDoc} */
- @Override
- public void warn(final Object message, final Throwable t) {
- // NOP
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/NOPLoggerRepository.java b/log4j-1.2-api/src/main/java/org/apache/log4j/spi/NOPLoggerRepository.java
deleted file mode 100644
index 77031c75070..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/NOPLoggerRepository.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.spi;
-
-import java.util.Enumeration;
-import java.util.Vector;
-import org.apache.log4j.Appender;
-import org.apache.log4j.Category;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-
-/**
- * No-operation implementation of LoggerRepository which is used when LogManager.repositorySelector is erroneously
- * nulled during class reloading.
- *
- * @since 1.2.15
- */
-public final class NOPLoggerRepository implements LoggerRepository {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void addHierarchyEventListener(final HierarchyEventListener listener) {
- // NOP
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void emitNoAppenderWarning(final Category cat) {
- // NOP
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Logger exists(final String name) {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void fireAddAppenderEvent(final Category logger, final Appender appender) {
- // NOP
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Enumeration getCurrentCategories() {
- return getCurrentLoggers();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Enumeration getCurrentLoggers() {
- return new Vector<>().elements();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Logger getLogger(final String name) {
- return new NOPLogger(this, name);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Logger getLogger(final String name, final LoggerFactory factory) {
- return new NOPLogger(this, name);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Logger getRootLogger() {
- return new NOPLogger(this, "root");
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Level getThreshold() {
- return Level.OFF;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isDisabled(final int level) {
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void resetConfiguration() {
- // NOP
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setThreshold(final Level level) {
- // NOP
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setThreshold(final String val) {
- // NOP
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void shutdown() {
- // NOP
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/OptionHandler.java b/log4j-1.2-api/src/main/java/org/apache/log4j/spi/OptionHandler.java
deleted file mode 100644
index b9ffe7e4d33..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/OptionHandler.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.spi;
-
-/**
- * Log4j 1 Interface for dealing with configuration. Ignored in Log4j 2.
- */
-public interface OptionHandler {
-
- void activateOptions();
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/RendererSupport.java b/log4j-1.2-api/src/main/java/org/apache/log4j/spi/RendererSupport.java
deleted file mode 100644
index 9a89ccc987f..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/RendererSupport.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.spi;
-
-import org.apache.log4j.or.ObjectRenderer;
-import org.apache.log4j.or.RendererMap;
-
-public interface RendererSupport {
-
- public RendererMap getRendererMap();
-
- public void setRenderer(Class renderedClass, ObjectRenderer renderer);
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/RepositorySelector.java b/log4j-1.2-api/src/main/java/org/apache/log4j/spi/RepositorySelector.java
deleted file mode 100644
index 460dc6993fe..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/RepositorySelector.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.spi;
-
-/**
- *
- * The LogManager
uses one (and only one) RepositorySelector
implementation to select the
- * {@link LoggerRepository} for a particular application context.
- *
- *
- * It is the responsibility of the RepositorySelector
implementation to track the application context.
- * Log4j makes no assumptions about the application context or on its management.
- *
- *
- *
- * See also {@link org.apache.log4j.LogManager LogManager}.
- *
- * @since 1.2
- */
-public interface RepositorySelector {
-
- /**
- * Gets a {@link LoggerRepository} depending on the context. Implementers must make sure that a valid (non-null)
- * LoggerRepository is returned.
- *
- * @return a LoggerRepository.
- */
- LoggerRepository getLoggerRepository();
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/RootLogger.java b/log4j-1.2-api/src/main/java/org/apache/log4j/spi/RootLogger.java
deleted file mode 100644
index 9773bb246a8..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/RootLogger.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.spi;
-
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.helpers.LogLog;
-
-/**
- * RootLogger sits at the top of the logger hierarchy. It is a regular logger except that it provides several guarantees.
- *
- * First, it cannot be assigned a null
level. Second, since root logger cannot have a parent, the
- * {@link #getChainedLevel} method always returns the value of the level field without walking the hierarchy.
- *
- */
-public final class RootLogger extends Logger {
-
- /**
- * The root logger names itself as "root". However, the root logger cannot be retrieved by name.
- */
- public RootLogger(final Level level) {
- // The Log4j 1 root logger name is "root".
- // The Log4j 2 root logger name is "".
- super("root");
- setLevel(level);
- }
-
- /**
- * Gets the assigned level value without walking the logger hierarchy.
- */
- public final Level getChainedLevel() {
- return getLevel();
- }
-
- /**
- * Sets the log level.
- *
- * Setting a null value to the level of the root logger may have catastrophic results. We prevent this here.
- *
- * @since 0.8.3
- */
- public final void setLevel(final Level level) {
- if (level == null) {
- LogLog.error("You have tried to set a null level to root.", new Throwable());
- } else {
- super.setLevel(level);
- }
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/ThrowableInformation.java b/log4j-1.2-api/src/main/java/org/apache/log4j/spi/ThrowableInformation.java
deleted file mode 100644
index a6acbed90e3..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/ThrowableInformation.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.spi;
-
-import java.io.Serializable;
-import java.lang.reflect.Method;
-import java.util.List;
-import org.apache.log4j.Category;
-import org.apache.logging.log4j.util.Strings;
-
-/**
- * Log4j's internal representation of throwables.
- */
-public class ThrowableInformation implements Serializable {
-
- static final long serialVersionUID = -4748765566864322735L;
-
- private transient Throwable throwable;
- private transient Category category;
- private String[] rep;
- private static final Method TO_STRING_LIST;
-
- static {
- Method method = null;
- try {
- final Class> throwables = Class.forName("org.apache.logging.log4j.core.util.Throwables");
- method = throwables.getMethod("toStringList", Throwable.class);
- } catch (ClassNotFoundException | NoSuchMethodException ex) {
- // Ignore the exception if Log4j-core is not present.
- }
- TO_STRING_LIST = method;
- }
-
- /**
- * Constructs new instance.
- *
- * @since 1.2.15
- * @param r String representation of throwable.
- */
- public ThrowableInformation(final String[] r) {
- this.rep = r != null ? r.clone() : null;
- }
-
- /**
- * Constructs new instance.
- */
- public ThrowableInformation(final Throwable throwable) {
- this.throwable = throwable;
- }
-
- /**
- * Constructs a new instance.
- *
- * @param throwable throwable, may not be null.
- * @param category category used to obtain ThrowableRenderer, may be null.
- * @since 1.2.16
- */
- public ThrowableInformation(final Throwable throwable, final Category category) {
- this(throwable);
- this.category = category;
- this.rep = null;
- }
-
- public Throwable getThrowable() {
- return throwable;
- }
-
- public synchronized String[] getThrowableStrRep() {
- if (TO_STRING_LIST != null && throwable != null) {
- try {
- @SuppressWarnings("unchecked")
- final List elements = (List) TO_STRING_LIST.invoke(null, throwable);
- if (elements != null) {
- return elements.toArray(Strings.EMPTY_ARRAY);
- }
- } catch (final ReflectiveOperationException ex) {
- // Ignore the exception.
- }
- }
- return rep;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/ThrowableRenderer.java b/log4j-1.2-api/src/main/java/org/apache/log4j/spi/ThrowableRenderer.java
deleted file mode 100644
index efaab324a22..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/ThrowableRenderer.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.spi;
-
-/**
- * Implemented by classes that render instances of java.lang.Throwable (exceptions and errors) into a string
- * representation.
- *
- * @since 1.2.16
- */
-public interface ThrowableRenderer {
-
- /**
- * Render Throwable.
- *
- * @param t throwable, may not be null.
- * @return String representation.
- */
- public String[] doRender(Throwable t);
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/ThrowableRendererSupport.java b/log4j-1.2-api/src/main/java/org/apache/log4j/spi/ThrowableRendererSupport.java
deleted file mode 100644
index 5c28778808b..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/ThrowableRendererSupport.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.spi;
-
-/**
- * Implemented by logger repositories that support configurable rendering of Throwables.
- *
- * @since 1.2.16
- */
-public interface ThrowableRendererSupport {
- /**
- * Get throwable renderer.
- *
- * @return throwable renderer, may be null.
- */
- ThrowableRenderer getThrowableRenderer();
-
- /**
- * Set throwable renderer.
- *
- * @param renderer renderer, may be null.
- */
- void setThrowableRenderer(ThrowableRenderer renderer);
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/TriggeringEventEvaluator.java b/log4j-1.2-api/src/main/java/org/apache/log4j/spi/TriggeringEventEvaluator.java
deleted file mode 100644
index ad63c708e97..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/TriggeringEventEvaluator.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.spi;
-
-/**
- * Implementors decide when to perform an appender specific action.
- *
- * @since version 1.0
- */
-public interface TriggeringEventEvaluator {
-
- /**
- * Tests if this the triggering event.
- *
- * @param event The vent to test.
- * @return Whether this the triggering event.
- */
- public boolean isTriggeringEvent(LoggingEvent event);
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/package-info.java b/log4j-1.2-api/src/main/java/org/apache/log4j/spi/package-info.java
deleted file mode 100644
index 4aeced5ea93..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/spi/package-info.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-/**
- * Log4j 1.x compatibility layer.
- */
-@Export
-@Version("2.20.1")
-package org.apache.log4j.spi;
-
-import org.osgi.annotation.bundle.Export;
-import org.osgi.annotation.versioning.Version;
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/varia/DenyAllFilter.java b/log4j-1.2-api/src/main/java/org/apache/log4j/varia/DenyAllFilter.java
deleted file mode 100644
index 901ceeb7132..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/varia/DenyAllFilter.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.varia;
-
-import org.apache.log4j.spi.Filter;
-import org.apache.log4j.spi.LoggingEvent;
-
-/**
- * Denies all logging events.
- *
- *
- * You can add this filter to the end of a filter chain to switch from the default "accept all unless instructed
- * otherwise" filtering behavior to a "deny all unless instructed otherwise" behavior.
- *
- *
- * @since 0.9.0
- */
-public class DenyAllFilter extends Filter {
-
- /**
- * Always returns the integer constant {@link Filter#DENY} regardless of the {@link LoggingEvent} parameter.
- *
- * @param event The LoggingEvent to filter.
- * @return Always returns {@link Filter#DENY}.
- */
- @Override
- public int decide(final LoggingEvent event) {
- return Filter.DENY;
- }
-
- /**
- * Returns null
as there are no options.
- *
- * @deprecated We now use JavaBeans introspection to configure components. Options strings are no longer needed.
- */
- @Deprecated
- public String[] getOptionStrings() {
- return null;
- }
-
- /**
- * No options to set.
- *
- * @deprecated Use the setter method for the option directly instead of the generic setOption
method.
- */
- @Deprecated
- public void setOption(final String key, final String value) {
- // noop
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/varia/FallbackErrorHandler.java b/log4j-1.2-api/src/main/java/org/apache/log4j/varia/FallbackErrorHandler.java
deleted file mode 100644
index 593f0411d8f..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/varia/FallbackErrorHandler.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.varia;
-
-import java.io.InterruptedIOException;
-import java.util.Vector;
-import org.apache.log4j.Appender;
-import org.apache.log4j.Logger;
-import org.apache.log4j.helpers.LogLog;
-import org.apache.log4j.spi.ErrorHandler;
-import org.apache.log4j.spi.LoggingEvent;
-
-/**
- * An ErrorHandler with a secondary appender. This secondary appender takes over if the primary appender fails for
- * whatever reason.
- *
- *
- * The error message is printed on System.err
, and logged in the new secondary appender.
- *
- */
-public class FallbackErrorHandler implements ErrorHandler {
-
- Appender backup;
- Appender primary;
- Vector loggers;
-
- public FallbackErrorHandler() {
- // noop
- }
-
- /**
- * No options to activate.
- */
- public void activateOptions() {
- // noop
- }
-
- /**
- * Print a the error message passed as parameter on System.err
.
- */
- @Override
- public void error(final String message) {
- // if(firstTime) {
- // LogLog.error(message);
- // firstTime = false;
- // }
- }
-
- /**
- * Prints the message and the stack trace of the exception on System.err
.
- */
- @Override
- public void error(final String message, final Exception e, final int errorCode) {
- error(message, e, errorCode, null);
- }
-
- /**
- * Prints the message and the stack trace of the exception on System.err
.
- */
- @Override
- public void error(final String message, final Exception e, final int errorCode, final LoggingEvent event) {
- if (e instanceof InterruptedIOException) {
- Thread.currentThread().interrupt();
- }
- LogLog.debug("FB: The following error reported: " + message, e);
- LogLog.debug("FB: INITIATING FALLBACK PROCEDURE.");
- if (loggers != null) {
- for (int i = 0; i < loggers.size(); i++) {
- final Logger l = (Logger) loggers.elementAt(i);
- LogLog.debug("FB: Searching for [" + primary.getName() + "] in logger [" + l.getName() + "].");
- LogLog.debug("FB: Replacing [" + primary.getName() + "] by [" + backup.getName() + "] in logger ["
- + l.getName() + "].");
- l.removeAppender(primary);
- LogLog.debug("FB: Adding appender [" + backup.getName() + "] to logger " + l.getName());
- l.addAppender(backup);
- }
- }
- }
-
- /**
- * The appender to which this error handler is attached.
- */
- @Override
- public void setAppender(final Appender primary) {
- LogLog.debug("FB: Setting primary appender to [" + primary.getName() + "].");
- this.primary = primary;
- }
-
- /**
- * Set the backup appender.
- */
- @Override
- public void setBackupAppender(final Appender backup) {
- LogLog.debug("FB: Setting backup appender to [" + backup.getName() + "].");
- this.backup = backup;
- }
-
- /**
- * Adds the logger passed as parameter to the list of loggers that we need to search for in case of appender
- * failure.
- */
- @Override
- public void setLogger(final Logger logger) {
- LogLog.debug("FB: Adding logger [" + logger.getName() + "].");
- if (loggers == null) {
- loggers = new Vector();
- }
- loggers.addElement(logger);
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/varia/LevelMatchFilter.java b/log4j-1.2-api/src/main/java/org/apache/log4j/varia/LevelMatchFilter.java
deleted file mode 100644
index fb7cb77ccbf..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/varia/LevelMatchFilter.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.varia;
-
-import org.apache.log4j.Level;
-import org.apache.log4j.helpers.OptionConverter;
-import org.apache.log4j.spi.Filter;
-import org.apache.log4j.spi.LoggingEvent;
-
-/**
- * Simple filter based on level matching.
- *
- *
- * The filter admits two options LevelToMatch and AcceptOnMatch . If there is an exact match between the
- * value of the LevelToMatch option and the level of the {@link LoggingEvent}, then the {@link #decide} method
- * returns {@link Filter#ACCEPT} in case the AcceptOnMatch option value is set to true
, if it is
- * false
then {@link Filter#DENY} is returned. If there is no match, {@link Filter#NEUTRAL} is returned.
- *
- *
- * @since 1.2
- */
-public class LevelMatchFilter extends Filter {
-
- /**
- * Do we return ACCEPT when a match occurs. Default is true
.
- */
- boolean acceptOnMatch = true;
-
- /**
- */
- Level levelToMatch;
-
- /**
- * Return the decision of this filter.
- *
- * Returns {@link Filter#NEUTRAL} if the LevelToMatch option is not set or if there is not match. Otherwise, if
- * there is a match, then the returned decision is {@link Filter#ACCEPT} if the AcceptOnMatch property is set to
- * true
. The returned decision is {@link Filter#DENY} if the AcceptOnMatch property is set to false.
- *
- */
- @Override
- public int decide(final LoggingEvent event) {
- if (this.levelToMatch == null) {
- return Filter.NEUTRAL;
- }
-
- boolean matchOccured = false;
- if (this.levelToMatch.equals(event.getLevel())) {
- matchOccured = true;
- }
-
- if (matchOccured) {
- if (this.acceptOnMatch) {
- return Filter.ACCEPT;
- }
- return Filter.DENY;
- }
- return Filter.NEUTRAL;
- }
-
- public boolean getAcceptOnMatch() {
- return acceptOnMatch;
- }
-
- public String getLevelToMatch() {
- return levelToMatch == null ? null : levelToMatch.toString();
- }
-
- public void setAcceptOnMatch(final boolean acceptOnMatch) {
- this.acceptOnMatch = acceptOnMatch;
- }
-
- public void setLevelToMatch(final String level) {
- levelToMatch = OptionConverter.toLevel(level, null);
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/varia/LevelRangeFilter.java b/log4j-1.2-api/src/main/java/org/apache/log4j/varia/LevelRangeFilter.java
deleted file mode 100644
index 546d2fa409f..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/varia/LevelRangeFilter.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.varia;
-
-import org.apache.log4j.Level;
-import org.apache.log4j.spi.Filter;
-import org.apache.log4j.spi.LoggingEvent;
-
-/**
- * This is a very simple filter based on level matching, which can be used to reject messages with priorities outside a
- * certain range.
- *
- * The filter admits three options LevelMin , LevelMax and AcceptOnMatch .
- *
- *
- * If the level of the {@link LoggingEvent} is not between Min and Max (inclusive), then {@link Filter#DENY} is
- * returned.
- *
- *
- * If the Logging event level is within the specified range, then if AcceptOnMatch is true, {@link Filter#ACCEPT}
- * is returned, and if AcceptOnMatch is false, {@link Filter#NEUTRAL} is returned.
- *
- *
- * If LevelMin
w is not defined, then there is no minimum acceptable level (ie a level is never rejected for
- * being too "low"/unimportant). If LevelMax
is not defined, then there is no maximum acceptable level (ie
- * a level is never rejected for beeing too "high"/important).
- *
- *
- * Refer to the {@link org.apache.log4j.AppenderSkeleton#setThreshold setThreshold} method available to all
- * appenders extending {@link org.apache.log4j.AppenderSkeleton} for a more convenient way to filter out events by
- * level.
- *
- */
-public class LevelRangeFilter extends Filter {
-
- /**
- * Do we return ACCEPT when a match occurs. Default is false
, so that later filters get run by default
- */
- boolean acceptOnMatch;
-
- Level levelMin;
- Level levelMax;
-
- /**
- * Return the decision of this filter.
- */
- @Override
- public int decide(final LoggingEvent event) {
- if (this.levelMin != null) {
- if (!event.getLevel().isGreaterOrEqual(levelMin)) {
- // level of event is less than minimum
- return Filter.DENY;
- }
- }
-
- if (this.levelMax != null) {
- if (event.getLevel().toInt() > levelMax.toInt()) {
- // level of event is greater than maximum
- // Alas, there is no Level.isGreater method. and using
- // a combo of isGreaterOrEqual && !Equal seems worse than
- // checking the int values of the level objects..
- return Filter.DENY;
- }
- }
-
- if (acceptOnMatch) {
- // this filter set up to bypass later filters and always return
- // accept if level in range
- return Filter.ACCEPT;
- }
- // event is ok for this filter; allow later filters to have a look..
- return Filter.NEUTRAL;
- }
-
- /**
- * Get the value of the AcceptOnMatch
option.
- */
- public boolean getAcceptOnMatch() {
- return acceptOnMatch;
- }
-
- /**
- * Get the value of the LevelMax
option.
- */
- public Level getLevelMax() {
- return levelMax;
- }
-
- /**
- * Get the value of the LevelMin
option.
- */
- public Level getLevelMin() {
- return levelMin;
- }
-
- /**
- * Set the AcceptOnMatch
option.
- */
- public void setAcceptOnMatch(final boolean acceptOnMatch) {
- this.acceptOnMatch = acceptOnMatch;
- }
-
- /**
- * Set the LevelMax
option.
- */
- public void setLevelMax(final Level levelMax) {
- this.levelMax = levelMax;
- }
-
- /**
- * Set the LevelMin
option.
- */
- public void setLevelMin(final Level levelMin) {
- this.levelMin = levelMin;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/varia/NullAppender.java b/log4j-1.2-api/src/main/java/org/apache/log4j/varia/NullAppender.java
deleted file mode 100644
index 4733c5a2a17..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/varia/NullAppender.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.varia;
-
-import org.apache.log4j.AppenderSkeleton;
-import org.apache.log4j.spi.LoggingEvent;
-
-/**
- * A NullAppender never outputs a message to any device.
- */
-public class NullAppender extends AppenderSkeleton {
-
- private static final NullAppender INSTANCE = new NullAppender();
-
- /**
- * Whenever you can, use this method to retreive an instance instead of instantiating a new one with new
.
- */
- public static NullAppender getNullAppender() {
- return INSTANCE;
- }
-
- public NullAppender() {
- // noop
- }
-
- /**
- * There are no options to acticate.
- */
- @Override
- public void activateOptions() {
- // noop
- }
-
- /**
- * Does not do anything.
- */
- @Override
- protected void append(final LoggingEvent event) {
- // noop
- }
-
- @Override
- public void close() {
- // noop
- }
-
- /**
- * Does not do anything.
- */
- @Override
- public void doAppend(final LoggingEvent event) {
- // noop
- }
-
- /**
- * Whenever you can, use this method to retreive an instance instead of instantiating a new one with new
.
- *
- * @deprecated Use getNullAppender instead. getInstance should have been static.
- */
- @Deprecated
- public NullAppender getInstance() {
- return INSTANCE;
- }
-
- /**
- * NullAppenders do not need a layout.
- */
- @Override
- public boolean requiresLayout() {
- return false;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/varia/ReloadingPropertyConfigurator.java b/log4j-1.2-api/src/main/java/org/apache/log4j/varia/ReloadingPropertyConfigurator.java
deleted file mode 100644
index d1b646e015d..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/varia/ReloadingPropertyConfigurator.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.varia;
-
-import java.io.InputStream;
-import java.net.URL;
-import org.apache.log4j.PropertyConfigurator;
-import org.apache.log4j.spi.Configurator;
-import org.apache.log4j.spi.LoggerRepository;
-
-public class ReloadingPropertyConfigurator implements Configurator {
-
- PropertyConfigurator delegate = new PropertyConfigurator();
-
- public ReloadingPropertyConfigurator() {}
-
- /**
- * @since 1.2.17
- */
- @Override
- public void doConfigure(final InputStream inputStream, final LoggerRepository repository) {
- // noop
- }
-
- @Override
- public void doConfigure(final URL url, final LoggerRepository repository) {
- // noop
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/varia/StringMatchFilter.java b/log4j-1.2-api/src/main/java/org/apache/log4j/varia/StringMatchFilter.java
deleted file mode 100644
index b1d60188a26..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/varia/StringMatchFilter.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.varia;
-
-import org.apache.log4j.helpers.OptionConverter;
-import org.apache.log4j.spi.Filter;
-import org.apache.log4j.spi.LoggingEvent;
-
-/**
- * Simple filter based on string matching.
- *
- *
- * The filter admits two options StringToMatch and AcceptOnMatch . If there is a match between the value of
- * the StringToMatch option and the message of the {@link org.apache.log4j.spi.LoggingEvent}, then the
- * {@link #decide(LoggingEvent)} method returns {@link org.apache.log4j.spi.Filter#ACCEPT} if the AcceptOnMatch
- * option value is true, if it is false then {@link org.apache.log4j.spi.Filter#DENY} is returned. If there is no match,
- * {@link org.apache.log4j.spi.Filter#NEUTRAL} is returned.
- *
- *
- * @since 0.9.0
- */
-public class StringMatchFilter extends Filter {
-
- /**
- * @deprecated Options are now handled using the JavaBeans paradigm. This constant is not longer needed and will be
- * removed in the near term.
- */
- @Deprecated
- public static final String STRING_TO_MATCH_OPTION = "StringToMatch";
-
- /**
- * @deprecated Options are now handled using the JavaBeans paradigm. This constant is not longer needed and will be
- * removed in the near term.
- */
- @Deprecated
- public static final String ACCEPT_ON_MATCH_OPTION = "AcceptOnMatch";
-
- boolean acceptOnMatch = true;
- String stringToMatch;
-
- /**
- * Returns {@link Filter#NEUTRAL} is there is no string match.
- */
- @Override
- public int decide(final LoggingEvent event) {
- final String msg = event.getRenderedMessage();
- if (msg == null || stringToMatch == null) {
- return Filter.NEUTRAL;
- }
- if (msg.indexOf(stringToMatch) == -1) {
- return Filter.NEUTRAL;
- }
- return acceptOnMatch ? Filter.ACCEPT : Filter.DENY;
- }
-
- public boolean getAcceptOnMatch() {
- return acceptOnMatch;
- }
-
- /**
- * @deprecated We now use JavaBeans introspection to configure components. Options strings are no longer needed.
- */
- @Deprecated
- public String[] getOptionStrings() {
- return new String[] {STRING_TO_MATCH_OPTION, ACCEPT_ON_MATCH_OPTION};
- }
-
- public String getStringToMatch() {
- return stringToMatch;
- }
-
- public void setAcceptOnMatch(final boolean acceptOnMatch) {
- this.acceptOnMatch = acceptOnMatch;
- }
-
- /**
- * @deprecated Use the setter method for the option directly instead of the generic setOption
method.
- */
- @Deprecated
- public void setOption(final String key, final String value) {
- if (key.equalsIgnoreCase(STRING_TO_MATCH_OPTION)) {
- stringToMatch = value;
- } else if (key.equalsIgnoreCase(ACCEPT_ON_MATCH_OPTION)) {
- acceptOnMatch = OptionConverter.toBoolean(value, acceptOnMatch);
- }
- }
-
- public void setStringToMatch(final String s) {
- stringToMatch = s;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/varia/package-info.java b/log4j-1.2-api/src/main/java/org/apache/log4j/varia/package-info.java
deleted file mode 100644
index c8c79ec86a2..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/varia/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-@Export
-@Version("2.20.1")
-package org.apache.log4j.varia;
-
-import org.osgi.annotation.bundle.Export;
-import org.osgi.annotation.versioning.Version;
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/xml/DOMConfigurator.java b/log4j-1.2-api/src/main/java/org/apache/log4j/xml/DOMConfigurator.java
deleted file mode 100644
index 933b9ea2fc2..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/xml/DOMConfigurator.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.xml;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-import java.net.URL;
-import java.net.URLConnection;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Properties;
-import javax.xml.parsers.FactoryConfigurationError;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.config.PropertySetter;
-import org.apache.log4j.helpers.OptionConverter;
-import org.apache.log4j.spi.LoggerRepository;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.ConfigurationSource;
-import org.apache.logging.log4j.core.config.Configurator;
-import org.apache.logging.log4j.core.net.UrlConnectionFactory;
-import org.w3c.dom.Element;
-
-/**
- * Use this class to initialize the log4j environment using a DOM tree.
- *
- *
- * The DTD is specified in log4j.dtd .
- *
- *
- * Sometimes it is useful to see how log4j is reading configuration files. You can enable log4j internal logging by
- * defining the log4j.debug variable on the java command line. Alternatively, set the debug
- * attribute in the log4j:configuration
element. As in
- *
- *
- * <log4j:configuration debug="true" xmlns:log4j="http://jakarta.apache.org/log4j/">
- * ...
- * </log4j:configuration>
- *
- *
- *
- * There are sample XML files included in the package.
- *
- * @since 0.8.3
- */
-public class DOMConfigurator {
-
- public static void configure(final Element element) {}
-
- @SuppressFBWarnings(value = "PATH_TRAVERSAL_IN", justification = "The filename comes from a system property.")
- public static void configure(final String fileName) throws FactoryConfigurationError {
- final Path path = Paths.get(fileName);
- try (final InputStream inputStream = Files.newInputStream(path)) {
- final ConfigurationSource source = new ConfigurationSource(inputStream, path);
- final LoggerContext context = LoggerContext.getContext(false);
- Configuration configuration;
- configuration = new XmlConfigurationFactory().getConfiguration(context, source);
- LogManager.getRootLogger().removeAllAppenders();
- Configurator.reconfigure(configuration);
- } catch (final IOException e) {
- throw new FactoryConfigurationError(e);
- }
- }
-
- public static void configure(final URL url) throws FactoryConfigurationError {
- new DOMConfigurator().doConfigure(url, LogManager.getLoggerRepository());
- }
-
- public static void configureAndWatch(final String fileName) {
- // TODO Watch
- configure(fileName);
- }
-
- public static void configureAndWatch(final String fileName, final long delay) {
- final XMLWatchdog xdog = new XMLWatchdog(fileName);
- xdog.setDelay(delay);
- xdog.start();
- }
-
- public static Object parseElement(
- final Element element, final Properties props, @SuppressWarnings("rawtypes") final Class expectedClass) {
- return null;
- }
-
- public static void setParameter(final Element elem, final PropertySetter propSetter, final Properties props) {}
-
- public static String subst(final String value, final Properties props) {
- return OptionConverter.substVars(value, props);
- }
-
- private void doConfigure(final ConfigurationSource source) {
- final LoggerContext context = LoggerContext.getContext(false);
- Configuration configuration;
- configuration = new XmlConfigurationFactory().getConfiguration(context, source);
- Configurator.reconfigure(configuration);
- }
-
- public void doConfigure(final Element element, final LoggerRepository repository) {}
-
- public void doConfigure(final InputStream inputStream, final LoggerRepository repository)
- throws FactoryConfigurationError {
- try {
- doConfigure(new ConfigurationSource(inputStream));
- } catch (final IOException e) {
- throw new FactoryConfigurationError(e);
- }
- }
-
- public void doConfigure(final Reader reader, final LoggerRepository repository) throws FactoryConfigurationError {
- try {
- final ByteArrayOutputStream out = new ByteArrayOutputStream();
- final OutputStreamWriter writer = new OutputStreamWriter(out, StandardCharsets.UTF_8);
- reader.transferTo(writer);
- final ByteArrayInputStream inputStream = new ByteArrayInputStream(out.toByteArray());
- doConfigure(new ConfigurationSource(inputStream));
- } catch (final IOException e) {
- throw new FactoryConfigurationError(e);
- }
- }
-
- public void doConfigure(final String fileName, final LoggerRepository repository) {
- configure(fileName);
- }
-
- public void doConfigure(final URL url, final LoggerRepository repository) {
- try {
- final URLConnection connection = UrlConnectionFactory.createConnection(url);
- try (final InputStream inputStream = connection.getInputStream()) {
- doConfigure(new ConfigurationSource(inputStream, url));
- }
- } catch (final IOException e) {
- throw new FactoryConfigurationError(e);
- }
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/xml/Log4jEntityResolver.java b/log4j-1.2-api/src/main/java/org/apache/log4j/xml/Log4jEntityResolver.java
deleted file mode 100644
index 1533fc89389..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/xml/Log4jEntityResolver.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.xml;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.util.Constants;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
-
-/**
- * An {@link EntityResolver} specifically designed to return
- * log4j.dtd
which is embedded within the log4j jar
- * file.
- */
-public class Log4jEntityResolver implements EntityResolver {
- private static final Logger LOGGER = StatusLogger.getLogger();
- private static final String PUBLIC_ID = "-//APACHE//DTD LOG4J 1.2//EN";
-
- @Override
- public InputSource resolveEntity(final String publicId, final String systemId) {
- if (systemId.endsWith("log4j.dtd") || PUBLIC_ID.equals(publicId)) {
- final Class> clazz = getClass();
- InputStream in = clazz.getResourceAsStream("/org/apache/log4j/xml/log4j.dtd");
- if (in == null) {
- LOGGER.warn(
- "Could not find [log4j.dtd] using [{}] class loader, parsed without DTD.",
- clazz.getClassLoader());
- in = new ByteArrayInputStream(Constants.EMPTY_BYTE_ARRAY);
- }
- return new InputSource(in);
- }
- return null;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/xml/UnrecognizedElementHandler.java b/log4j-1.2-api/src/main/java/org/apache/log4j/xml/UnrecognizedElementHandler.java
deleted file mode 100644
index 99451054aaa..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/xml/UnrecognizedElementHandler.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.xml;
-
-import java.util.Properties;
-import org.w3c.dom.Element;
-
-/**
- * When implemented by an object configured by DOMConfigurator,
- * the handle method will be called when an unrecognized child
- * element is encountered. Unrecognized child elements of
- * the log4j:configuration element will be dispatched to
- * the logger repository if it supports this interface.
- *
- * @since 1.2.15
- */
-public interface UnrecognizedElementHandler {
- /**
- * Called to inform a configured object when
- * an unrecognized child element is encountered.
- * @param element element, may not be null.
- * @param props properties in force, may be null.
- * @return true if configured object recognized the element
- * @throws Exception throw an exception to prevent activation
- * of the configured object.
- */
- boolean parseUnrecognizedElement(Element element, Properties props) throws Exception;
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/xml/XMLWatchdog.java b/log4j-1.2-api/src/main/java/org/apache/log4j/xml/XMLWatchdog.java
deleted file mode 100644
index 6356cced5db..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/xml/XMLWatchdog.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.xml;
-
-import org.apache.log4j.LogManager;
-import org.apache.log4j.helpers.FileWatchdog;
-import org.apache.log4j.spi.LoggerRepository;
-
-class XMLWatchdog extends FileWatchdog {
-
- XMLWatchdog(final String filename) {
- super(filename);
- }
-
- /**
- * Calls {@link DOMConfigurator#doConfigure(String, LoggerRepository)} with the filename
to reconfigure Log4j.
- */
- @Override
- public void doOnChange() {
- new DOMConfigurator().doConfigure(filename, LogManager.getLoggerRepository());
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/xml/XmlConfiguration.java b/log4j-1.2-api/src/main/java/org/apache/log4j/xml/XmlConfiguration.java
deleted file mode 100644
index efe481e4d6f..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/xml/XmlConfiguration.java
+++ /dev/null
@@ -1,835 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.xml;
-
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.function.Consumer;
-import java.util.stream.IntStream;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.FactoryConfigurationError;
-import org.apache.log4j.Appender;
-import org.apache.log4j.Layout;
-import org.apache.log4j.Level;
-import org.apache.log4j.bridge.AppenderAdapter;
-import org.apache.log4j.bridge.FilterAdapter;
-import org.apache.log4j.config.Log4j1Configuration;
-import org.apache.log4j.config.PropertySetter;
-import org.apache.log4j.helpers.OptionConverter;
-import org.apache.log4j.rewrite.RewritePolicy;
-import org.apache.log4j.spi.AppenderAttachable;
-import org.apache.log4j.spi.ErrorHandler;
-import org.apache.log4j.spi.Filter;
-import org.apache.logging.log4j.core.Filter.Result;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.appender.rolling.TriggeringPolicy;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.ConfigurationSource;
-import org.apache.logging.log4j.core.config.LoggerConfig;
-import org.apache.logging.log4j.core.config.status.StatusConfiguration;
-import org.apache.logging.log4j.core.filter.ThresholdFilter;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.util.LoaderUtil;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-/**
- * Class Description goes here.
- */
-public class XmlConfiguration extends Log4j1Configuration {
-
- private static final org.apache.logging.log4j.Logger LOGGER = StatusLogger.getLogger();
-
- private static final String CONFIGURATION_TAG = "log4j:configuration";
- private static final String OLD_CONFIGURATION_TAG = "configuration";
- private static final String RENDERER_TAG = "renderer";
- private static final String APPENDER_TAG = "appender";
- public static final String PARAM_TAG = "param";
- public static final String LAYOUT_TAG = "layout";
- private static final String CATEGORY = "category";
- private static final String LOGGER_ELEMENT = "logger";
- private static final String CATEGORY_FACTORY_TAG = "categoryFactory";
- private static final String LOGGER_FACTORY_TAG = "loggerFactory";
- public static final String NAME_ATTR = "name";
- private static final String CLASS_ATTR = "class";
- public static final String VALUE_ATTR = "value";
- private static final String ROOT_TAG = "root";
- private static final String LEVEL_TAG = "level";
- private static final String PRIORITY_TAG = "priority";
- public static final String FILTER_TAG = "filter";
- private static final String ERROR_HANDLER_TAG = "errorHandler";
- public static final String REF_ATTR = "ref";
- private static final String ADDITIVITY_ATTR = "additivity";
- private static final String CONFIG_DEBUG_ATTR = "configDebug";
- private static final String INTERNAL_DEBUG_ATTR = "debug";
- private static final String THRESHOLD_ATTR = "threshold";
- private static final String EMPTY_STR = "";
- private static final Class>[] ONE_STRING_PARAM = new Class[] {String.class};
- private static final String dbfKey = "javax.xml.parsers.DocumentBuilderFactory";
- private static final String THROWABLE_RENDERER_TAG = "throwableRenderer";
-
- public static final long DEFAULT_DELAY = 60000;
-
- /**
- * File name prefix for test configurations.
- */
- protected static final String TEST_PREFIX = "log4j-test";
-
- /**
- * File name prefix for standard configurations.
- */
- protected static final String DEFAULT_PREFIX = "log4j";
-
- // key: appenderName, value: appender
- private final Map appenderMap;
-
- private final Properties props = null;
-
- public XmlConfiguration(
- final LoggerContext loggerContext,
- final ConfigurationSource configurationSource,
- final int monitorIntervalSeconds) {
- super(loggerContext, configurationSource, monitorIntervalSeconds);
- appenderMap = new HashMap<>();
- }
-
- public void addAppenderIfAbsent(Appender appender) {
- appenderMap.putIfAbsent(appender.getName(), appender);
- }
-
- /**
- * Configures log4j by reading in a log4j.dtd compliant XML
- * configuration file.
- */
- @Override
- public void doConfigure() throws FactoryConfigurationError {
- final ConfigurationSource source = getConfigurationSource();
- final ParseAction action = new ParseAction() {
- @Override
- @SuppressFBWarnings(
- value = "XXE_DOCUMENT",
- justification = "The `DocumentBuilder` is configured to not resolve external entities.")
- public Document parse(final DocumentBuilder parser) throws SAXException, IOException {
- @SuppressWarnings("resource")
- final // The ConfigurationSource and its caller manages the InputStream.
- InputSource inputSource = new InputSource(source.getInputStream());
- inputSource.setSystemId("dummy://log4j.dtd");
- return parser.parse(inputSource);
- }
-
- @Override
- public String toString() {
- return getConfigurationSource().getLocation();
- }
- };
- doConfigure(action);
- }
-
- private void doConfigure(final ParseAction action) throws FactoryConfigurationError {
- DocumentBuilderFactory dbf;
- try {
- LOGGER.debug("System property is : {}", OptionConverter.getSystemProperty(dbfKey, null));
- dbf = DocumentBuilderFactory.newInstance();
- LOGGER.debug("Standard DocumentBuilderFactory search succeeded.");
- LOGGER.debug("DocumentBuilderFactory is: " + dbf.getClass().getName());
- } catch (FactoryConfigurationError fce) {
- final Exception e = fce.getException();
- LOGGER.debug("Could not instantiate a DocumentBuilderFactory.", e);
- throw fce;
- }
-
- try {
- dbf.setValidating(true);
-
- final DocumentBuilder docBuilder = dbf.newDocumentBuilder();
-
- docBuilder.setErrorHandler(new SAXErrorHandler());
- docBuilder.setEntityResolver(new Log4jEntityResolver());
-
- final Document doc = action.parse(docBuilder);
- parse(doc.getDocumentElement());
- } catch (Exception e) {
- if (e instanceof InterruptedException || e instanceof InterruptedIOException) {
- Thread.currentThread().interrupt();
- }
- // I know this is miserable...
- LOGGER.error("Could not parse " + action.toString() + ".", e);
- }
- }
-
- @Override
- public Configuration reconfigure() {
- try {
- final ConfigurationSource source = getConfigurationSource().resetInputStream();
- if (source == null) {
- return null;
- }
- final XmlConfigurationFactory factory = new XmlConfigurationFactory();
- final XmlConfiguration config = (XmlConfiguration) factory.getConfiguration(getLoggerContext(), source);
- return config == null || config.getState() != State.INITIALIZING ? null : config;
- } catch (final IOException ex) {
- LOGGER.error("Cannot locate file {}: {}", getConfigurationSource(), ex);
- }
- return null;
- }
-
- /**
- * Delegates unrecognized content to created instance if it supports UnrecognizedElementParser.
- *
- * @param instance instance, may be null.
- * @param element element, may not be null.
- * @param props properties
- * @throws IOException thrown if configuration of owner object should be abandoned.
- */
- private void parseUnrecognizedElement(final Object instance, final Element element, final Properties props)
- throws Exception {
- boolean recognized = false;
- if (instance instanceof UnrecognizedElementHandler) {
- recognized = ((UnrecognizedElementHandler) instance).parseUnrecognizedElement(element, props);
- }
- if (!recognized) {
- LOGGER.warn("Unrecognized element {}", element.getNodeName());
- }
- }
-
- /**
- * Delegates unrecognized content to created instance if
- * it supports UnrecognizedElementParser and catches and
- * logs any exception.
- *
- * @param instance instance, may be null.
- * @param element element, may not be null.
- * @param props properties
- * @since 1.2.15
- */
- private void quietParseUnrecognizedElement(final Object instance, final Element element, final Properties props) {
- try {
- parseUnrecognizedElement(instance, element, props);
- } catch (Exception ex) {
- if (ex instanceof InterruptedException || ex instanceof InterruptedIOException) {
- Thread.currentThread().interrupt();
- }
- LOGGER.error("Error in extension content: ", ex);
- }
- }
-
- /**
- * Substitutes property value for any references in expression.
- *
- * @param value value from configuration file, may contain
- * literal text, property references or both
- * @param props properties.
- * @return evaluated expression, may still contain expressions
- * if unable to expand.
- */
- public String subst(final String value, final Properties props) {
- try {
- return OptionConverter.substVars(value, props);
- } catch (IllegalArgumentException e) {
- LOGGER.warn("Could not perform variable substitution.", e);
- return value;
- }
- }
-
- /**
- * Sets a parameter based from configuration file content.
- *
- * @param elem param element, may not be null.
- * @param propSetter property setter, may not be null.
- * @param props properties
- * @since 1.2.15
- */
- public void setParameter(final Element elem, final PropertySetter propSetter, final Properties props) {
- final String name = subst(elem.getAttribute("name"), props);
- String value = (elem.getAttribute("value"));
- value = subst(OptionConverter.convertSpecialChars(value), props);
- propSetter.setProperty(name, value);
- }
-
- /**
- * Creates an object and processes any nested param elements
- * but does not call activateOptions. If the class also supports
- * UnrecognizedElementParser, the parseUnrecognizedElement method
- * will be call for any child elements other than param.
- *
- * @param element element, may not be null.
- * @param props properties
- * @param expectedClass interface or class expected to be implemented
- * by created class
- * @return created class or null.
- * @throws Exception thrown if the contain object should be abandoned.
- * @since 1.2.15
- */
- public Object parseElement(
- final Element element, final Properties props, @SuppressWarnings("rawtypes") final Class expectedClass)
- throws Exception {
- final String clazz = subst(element.getAttribute("class"), props);
- final Object instance = OptionConverter.instantiateByClassName(clazz, expectedClass, null);
-
- if (instance != null) {
- final PropertySetter propSetter = new PropertySetter(instance);
- final NodeList children = element.getChildNodes();
- final int length = children.getLength();
-
- for (int loop = 0; loop < length; loop++) {
- final Node currentNode = children.item(loop);
- if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
- final Element currentElement = (Element) currentNode;
- final String tagName = currentElement.getTagName();
- if (tagName.equals("param")) {
- setParameter(currentElement, propSetter, props);
- } else {
- parseUnrecognizedElement(instance, currentElement, props);
- }
- }
- }
- return instance;
- }
- return null;
- }
-
- /**
- * Used internally to parse appenders by IDREF name.
- */
- private Appender findAppenderByName(final Document doc, final String appenderName) {
- Appender appender = appenderMap.get(appenderName);
-
- if (appender != null) {
- return appender;
- }
- // Endre's hack:
- Element element = null;
- final NodeList list = doc.getElementsByTagName("appender");
- for (int t = 0; t < list.getLength(); t++) {
- final Node node = list.item(t);
- final NamedNodeMap map = node.getAttributes();
- final Node attrNode = map.getNamedItem("name");
- if (appenderName.equals(attrNode.getNodeValue())) {
- element = (Element) node;
- break;
- }
- }
- // Hack finished.
-
- if (element == null) {
-
- LOGGER.error("No appender named [{}] could be found.", appenderName);
- return null;
- }
- appender = parseAppender(element);
- if (appender != null) {
- appenderMap.put(appenderName, appender);
- }
- return appender;
- }
-
- /**
- * Used internally to parse appenders by IDREF element.
- * @param appenderRef The Appender Reference Element.
- * @return The Appender.
- */
- public Appender findAppenderByReference(final Element appenderRef) {
- final String appenderName = subst(appenderRef.getAttribute(REF_ATTR));
- final Document doc = appenderRef.getOwnerDocument();
- return findAppenderByName(doc, appenderName);
- }
-
- /**
- * Used internally to parse an appender element.
- * @param appenderElement The Appender Element.
- * @return The Appender.
- */
- public Appender parseAppender(final Element appenderElement) {
- final String className = subst(appenderElement.getAttribute(CLASS_ATTR));
- LOGGER.debug("Class name: [" + className + ']');
- Appender appender = manager.parseAppender(className, appenderElement, this);
- if (appender == null) {
- appender = buildAppender(className, appenderElement);
- }
- return appender;
- }
-
- private Appender buildAppender(final String className, final Element appenderElement) {
- try {
- final Appender appender = LoaderUtil.newInstanceOf(className);
- final PropertySetter propSetter = new PropertySetter(appender);
-
- appender.setName(subst(appenderElement.getAttribute(NAME_ATTR)));
- final AtomicReference filterChain = new AtomicReference<>();
- forEachElement(appenderElement.getChildNodes(), currentElement -> {
- // Parse appender parameters
- switch (currentElement.getTagName()) {
- case PARAM_TAG:
- setParameter(currentElement, propSetter);
- break;
- case LAYOUT_TAG:
- appender.setLayout(parseLayout(currentElement));
- break;
- case FILTER_TAG:
- addFilter(filterChain, currentElement);
- break;
- case ERROR_HANDLER_TAG:
- parseErrorHandler(currentElement, appender);
- break;
- case APPENDER_REF_TAG:
- final String refName = subst(currentElement.getAttribute(REF_ATTR));
- if (appender instanceof AppenderAttachable) {
- final AppenderAttachable aa = (AppenderAttachable) appender;
- final Appender child = findAppenderByReference(currentElement);
- LOGGER.debug(
- "Attaching appender named [{}] to appender named [{}].",
- refName,
- appender.getName());
- aa.addAppender(child);
- } else {
- LOGGER.error(
- "Requesting attachment of appender named [{}] to appender named [{}]"
- + "which does not implement org.apache.log4j.spi.AppenderAttachable.",
- refName,
- appender.getName());
- }
- break;
- default:
- try {
- parseUnrecognizedElement(appender, currentElement, props);
- } catch (Exception ex) {
- throw new ConsumerException(ex);
- }
- }
- });
- final Filter head = filterChain.get();
- if (head != null) {
- appender.addFilter(head);
- }
- propSetter.activate();
- return appender;
- } catch (ConsumerException ex) {
- final Throwable t = ex.getCause();
- if (t instanceof InterruptedException || t instanceof InterruptedIOException) {
- Thread.currentThread().interrupt();
- }
- LOGGER.error("Could not create an Appender. Reported error follows.", t);
- } catch (Exception oops) {
- if (oops instanceof InterruptedException || oops instanceof InterruptedIOException) {
- Thread.currentThread().interrupt();
- }
- LOGGER.error("Could not create an Appender. Reported error follows.", oops);
- }
- return null;
- }
-
- public RewritePolicy parseRewritePolicy(final Element rewritePolicyElement) {
- final String className = subst(rewritePolicyElement.getAttribute(CLASS_ATTR));
- LOGGER.debug("Class name: [" + className + ']');
- RewritePolicy policy = manager.parseRewritePolicy(className, rewritePolicyElement, this);
- if (policy == null) {
- policy = buildRewritePolicy(className, rewritePolicyElement);
- }
- return policy;
- }
-
- private RewritePolicy buildRewritePolicy(String className, Element element) {
- try {
- final RewritePolicy policy = LoaderUtil.newInstanceOf(className);
- final PropertySetter propSetter = new PropertySetter(policy);
-
- forEachElement(element.getChildNodes(), currentElement -> {
- if (currentElement.getTagName().equalsIgnoreCase(PARAM_TAG)) {
- setParameter(currentElement, propSetter);
- }
- });
- propSetter.activate();
- return policy;
- } catch (ConsumerException ex) {
- final Throwable t = ex.getCause();
- if (t instanceof InterruptedException || t instanceof InterruptedIOException) {
- Thread.currentThread().interrupt();
- }
- LOGGER.error("Could not create an RewritePolicy. Reported error follows.", t);
- } catch (Exception oops) {
- if (oops instanceof InterruptedException || oops instanceof InterruptedIOException) {
- Thread.currentThread().interrupt();
- }
- LOGGER.error("Could not create an RewritePolicy. Reported error follows.", oops);
- }
- return null;
- }
-
- /**
- * Used internally to parse an {@link ErrorHandler} element.
- */
- private void parseErrorHandler(Element element, Appender appender) {
- final ErrorHandler eh = (ErrorHandler) OptionConverter.instantiateByClassName(
- subst(element.getAttribute(CLASS_ATTR)), ErrorHandler.class, null);
-
- if (eh != null) {
- eh.setAppender(appender);
-
- final PropertySetter propSetter = new PropertySetter(eh);
- forEachElement(element.getChildNodes(), currentElement -> {
- final String tagName = currentElement.getTagName();
- if (tagName.equals(PARAM_TAG)) {
- setParameter(currentElement, propSetter);
- }
- });
- propSetter.activate();
- appender.setErrorHandler(eh);
- }
- }
-
- /**
- * Used internally to parse a filter element.
- * @param filterElement The Filter Element.
- * @return The Filter.
- */
- public void addFilter(final AtomicReference ref, final Element filterElement) {
- final Filter value = parseFilters(filterElement);
- ref.accumulateAndGet(value, FilterAdapter::addFilter);
- }
-
- /**
- * Used internally to parse a filter element.
- */
- public Filter parseFilters(final Element filterElement) {
- final String className = subst(filterElement.getAttribute(CLASS_ATTR));
- LOGGER.debug("Class name: [" + className + ']');
- Filter filter = manager.parseFilter(className, filterElement, this);
- if (filter == null) {
- filter = buildFilter(className, filterElement);
- }
- return filter;
- }
-
- private Filter buildFilter(final String className, final Element filterElement) {
- try {
- final Filter filter = LoaderUtil.newInstanceOf(className);
- final PropertySetter propSetter = new PropertySetter(filter);
-
- forEachElement(filterElement.getChildNodes(), currentElement -> {
- // Parse appender parameters
- switch (currentElement.getTagName()) {
- case PARAM_TAG:
- setParameter(currentElement, propSetter);
- break;
- }
- });
- propSetter.activate();
- return filter;
- } catch (ConsumerException ex) {
- final Throwable t = ex.getCause();
- if (t instanceof InterruptedException || t instanceof InterruptedIOException) {
- Thread.currentThread().interrupt();
- }
- LOGGER.error("Could not create an Filter. Reported error follows.", t);
- } catch (Exception oops) {
- if (oops instanceof InterruptedException || oops instanceof InterruptedIOException) {
- Thread.currentThread().interrupt();
- }
- LOGGER.error("Could not create an Filter. Reported error follows.", oops);
- }
- return null;
- }
-
- /**
- * Used internally to parse an category element.
- */
- private void parseCategory(final Element loggerElement) {
- // Create a new org.apache.log4j.Category object from the element.
- final String catName = subst(loggerElement.getAttribute(NAME_ATTR));
- final boolean additivity = OptionConverter.toBoolean(subst(loggerElement.getAttribute(ADDITIVITY_ATTR)), true);
- LoggerConfig loggerConfig = getLogger(catName);
- if (loggerConfig == null) {
- loggerConfig = new LoggerConfig(catName, org.apache.logging.log4j.Level.ERROR, additivity, this);
- addLogger(catName, loggerConfig);
- } else {
- loggerConfig.setAdditive(additivity);
- }
- parseChildrenOfLoggerElement(loggerElement, loggerConfig, false);
- }
-
- /**
- * Used internally to parse the root category element.
- */
- private void parseRoot(final Element rootElement) {
- final LoggerConfig root = getRootLogger();
- parseChildrenOfLoggerElement(rootElement, root, true);
- }
-
- /**
- * Used internally to parse the children of a LoggerConfig element.
- */
- private void parseChildrenOfLoggerElement(Element catElement, LoggerConfig loggerConfig, boolean isRoot) {
-
- final PropertySetter propSetter = new PropertySetter(loggerConfig);
- loggerConfig.getAppenderRefs().clear();
- forEachElement(catElement.getChildNodes(), currentElement -> {
- switch (currentElement.getTagName()) {
- case APPENDER_REF_TAG: {
- final Appender appender = findAppenderByReference(currentElement);
- final String refName = subst(currentElement.getAttribute(REF_ATTR));
- if (appender != null) {
- LOGGER.debug(
- "Adding appender named [{}] to loggerConfig [{}].", refName, loggerConfig.getName());
- loggerConfig.addAppender(getAppender(refName), null, null);
- } else {
- LOGGER.debug("Appender named [{}] not found.", refName);
- }
- break;
- }
- case LEVEL_TAG:
- case PRIORITY_TAG: {
- parseLevel(currentElement, loggerConfig, isRoot);
- break;
- }
- case PARAM_TAG: {
- setParameter(currentElement, propSetter);
- break;
- }
- default: {
- quietParseUnrecognizedElement(loggerConfig, currentElement, props);
- }
- }
- });
- propSetter.activate();
- }
-
- /**
- * Used internally to parse a layout element.
- * @param layoutElement The Layout Element.
- * @return The Layout.
- */
- public Layout parseLayout(final Element layoutElement) {
- final String className = subst(layoutElement.getAttribute(CLASS_ATTR));
- LOGGER.debug("Parsing layout of class: \"{}\"", className);
- Layout layout = manager.parseLayout(className, layoutElement, this);
- if (layout == null) {
- layout = buildLayout(className, layoutElement);
- }
- return layout;
- }
-
- private Layout buildLayout(final String className, final Element layout_element) {
- try {
- final Layout layout = LoaderUtil.newInstanceOf(className);
- final PropertySetter propSetter = new PropertySetter(layout);
- forEachElement(layout_element.getChildNodes(), currentElement -> {
- final String tagName = currentElement.getTagName();
- if (tagName.equals(PARAM_TAG)) {
- setParameter(currentElement, propSetter);
- } else {
- try {
- parseUnrecognizedElement(layout, currentElement, props);
- } catch (Exception ex) {
- throw new ConsumerException(ex);
- }
- }
- });
-
- propSetter.activate();
- return layout;
- } catch (Exception e) {
- final Throwable cause = e.getCause();
- if (e instanceof InterruptedException
- || e instanceof InterruptedIOException
- || cause instanceof InterruptedException
- || cause instanceof InterruptedIOException) {
- Thread.currentThread().interrupt();
- }
- LOGGER.error("Could not create the Layout. Reported error follows.", e);
- }
- return null;
- }
-
- public TriggeringPolicy parseTriggeringPolicy(final Element policyElement) {
- final String className = subst(policyElement.getAttribute(CLASS_ATTR));
- LOGGER.debug("Parsing triggering policy of class: \"{}\"", className);
- return manager.parseTriggeringPolicy(className, policyElement, this);
- }
-
- /**
- * Used internally to parse a level element.
- */
- private void parseLevel(Element element, LoggerConfig logger, boolean isRoot) {
- String catName = logger.getName();
- if (isRoot) {
- catName = "root";
- }
-
- final String priStr = subst(element.getAttribute(VALUE_ATTR));
- LOGGER.debug("Level value for {} is [{}].", catName, priStr);
-
- if (INHERITED.equalsIgnoreCase(priStr) || NULL.equalsIgnoreCase(priStr)) {
- if (isRoot) {
- LOGGER.error("Root level cannot be inherited. Ignoring directive.");
- } else {
- logger.setLevel(null);
- }
- } else {
- final String className = subst(element.getAttribute(CLASS_ATTR));
- final Level level;
- if (EMPTY_STR.equals(className)) {
- level = OptionConverter.toLevel(priStr, DEFAULT_LEVEL);
- } else {
- level = OptionConverter.toLevel(className, priStr, DEFAULT_LEVEL);
- }
- logger.setLevel(level != null ? level.getVersion2Level() : null);
- }
- LOGGER.debug("{} level set to {}", catName, logger.getLevel());
- }
-
- private void setParameter(Element element, PropertySetter propSetter) {
- final String name = subst(element.getAttribute(NAME_ATTR));
- String value = element.getAttribute(VALUE_ATTR);
- value = subst(OptionConverter.convertSpecialChars(value));
- propSetter.setProperty(name, value);
- }
-
- /**
- * Used internally to configure the log4j framework by parsing a DOM
- * tree of XML elements based on log4j.dtd .
- */
- private void parse(Element element) {
- final String rootElementName = element.getTagName();
-
- if (!rootElementName.equals(CONFIGURATION_TAG)) {
- if (rootElementName.equals(OLD_CONFIGURATION_TAG)) {
- LOGGER.warn("The <" + OLD_CONFIGURATION_TAG + "> element has been deprecated.");
- LOGGER.warn("Use the <" + CONFIGURATION_TAG + "> element instead.");
- } else {
- LOGGER.error("DOM element is - not a <" + CONFIGURATION_TAG + "> element.");
- return;
- }
- }
-
- final String debugAttrib = subst(element.getAttribute(INTERNAL_DEBUG_ATTR));
-
- LOGGER.debug("debug attribute= \"" + debugAttrib + "\".");
- // if the log4j.dtd is not specified in the XML file, then the
- // "debug" attribute is returned as the empty string.
- String status = "error";
- if (!debugAttrib.isEmpty() && !debugAttrib.equals("null")) {
- status = OptionConverter.toBoolean(debugAttrib, true) ? "debug" : "error";
- } else {
- LOGGER.debug("Ignoring " + INTERNAL_DEBUG_ATTR + " attribute.");
- }
-
- final String confDebug = subst(element.getAttribute(CONFIG_DEBUG_ATTR));
- if (!confDebug.isEmpty() && !confDebug.equals("null")) {
- LOGGER.warn("The \"" + CONFIG_DEBUG_ATTR + "\" attribute is deprecated.");
- LOGGER.warn("Use the \"" + INTERNAL_DEBUG_ATTR + "\" attribute instead.");
- status = OptionConverter.toBoolean(confDebug, true) ? "debug" : "error";
- }
-
- final StatusConfiguration statusConfig = new StatusConfiguration().setStatus(status);
- statusConfig.initialize();
-
- final String threshold = subst(element.getAttribute(THRESHOLD_ATTR));
- if (threshold != null) {
- final org.apache.logging.log4j.Level level =
- OptionConverter.convertLevel(threshold.trim(), org.apache.logging.log4j.Level.ALL);
- addFilter(ThresholdFilter.createFilter(level, Result.NEUTRAL, Result.DENY));
- }
-
- forEachElement(element.getChildNodes(), currentElement -> {
- switch (currentElement.getTagName()) {
- case CATEGORY:
- case LOGGER_ELEMENT:
- parseCategory(currentElement);
- break;
- case ROOT_TAG:
- parseRoot(currentElement);
- break;
- case RENDERER_TAG:
- LOGGER.warn("Log4j 1 renderers are not supported by Log4j 2 and will be ignored.");
- break;
- case THROWABLE_RENDERER_TAG:
- LOGGER.warn("Log4j 1 throwable renderers are not supported by Log4j 2 and will be ignored.");
- break;
- case CATEGORY_FACTORY_TAG:
- case LOGGER_FACTORY_TAG:
- LOGGER.warn("Log4j 1 logger factories are not supported by Log4j 2 and will be ignored.");
- break;
- case APPENDER_TAG:
- final Appender appender = parseAppender(currentElement);
- appenderMap.put(appender.getName(), appender);
- addAppender(AppenderAdapter.adapt(appender));
- break;
- default:
- quietParseUnrecognizedElement(null, currentElement, props);
- }
- });
- }
-
- private String subst(final String value) {
- return getStrSubstitutor().replace(value);
- }
-
- public static void forEachElement(final NodeList list, final Consumer consumer) {
- IntStream.range(0, list.getLength())
- .mapToObj(list::item)
- .filter(node -> node.getNodeType() == Node.ELEMENT_NODE)
- .forEach(node -> consumer.accept((Element) node));
- }
-
- private interface ParseAction {
- Document parse(final DocumentBuilder parser) throws SAXException, IOException;
- }
-
- private static class SAXErrorHandler implements org.xml.sax.ErrorHandler {
- private static final org.apache.logging.log4j.Logger LOGGER = StatusLogger.getLogger();
-
- @Override
- public void error(final SAXParseException ex) {
- emitMessage("Continuable parsing error ", ex);
- }
-
- @Override
- public void fatalError(final SAXParseException ex) {
- emitMessage("Fatal parsing error ", ex);
- }
-
- @Override
- public void warning(final SAXParseException ex) {
- emitMessage("Parsing warning ", ex);
- }
-
- private static void emitMessage(final String msg, final SAXParseException ex) {
- LOGGER.warn("{} {} and column {}", msg, ex.getLineNumber(), ex.getColumnNumber());
- LOGGER.warn(ex.getMessage(), ex.getException());
- }
- }
-
- private static class ConsumerException extends RuntimeException {
-
- ConsumerException(final Exception ex) {
- super(ex);
- }
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/xml/XmlConfigurationFactory.java b/log4j-1.2-api/src/main/java/org/apache/log4j/xml/XmlConfigurationFactory.java
deleted file mode 100644
index 4df966c86c2..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/xml/XmlConfigurationFactory.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.xml;
-
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.config.ConfigurationSource;
-import org.apache.logging.log4j.core.config.Order;
-import org.apache.logging.log4j.core.impl.CoreProperties.Version1Properties;
-import org.apache.logging.log4j.kit.env.PropertyEnvironment;
-import org.apache.logging.log4j.plugins.Namespace;
-import org.apache.logging.log4j.plugins.Plugin;
-
-/**
- * Constructs a Configuration usable in Log4j 2 from a Log4j 1 configuration file.
- */
-@Namespace(ConfigurationFactory.NAMESPACE)
-@Plugin("Log4j1XmlConfigurationFactory")
-@Order(2)
-public class XmlConfigurationFactory extends ConfigurationFactory {
-
- public static final String FILE_EXTENSION = ".xml";
-
- /**
- * File name prefix for test configurations.
- */
- protected static final String TEST_PREFIX = "log4j-test";
-
- /**
- * File name prefix for standard configurations.
- */
- protected static final String DEFAULT_PREFIX = "log4j";
-
- private final boolean enabled;
-
- public XmlConfigurationFactory() {
- this(PropertyEnvironment.getGlobal().getProperty(Version1Properties.class));
- }
-
- private XmlConfigurationFactory(final Version1Properties properties) {
- this.enabled = properties.compatibility() || properties.configuration() != null;
- }
-
- @Override
- protected String[] getSupportedTypes() {
- return enabled ? new String[] {FILE_EXTENSION} : null;
- }
-
- @Override
- public Configuration getConfiguration(final LoggerContext loggerContext, final ConfigurationSource source) {
- final int interval = loggerContext
- .getEnvironment()
- .getProperty(Version1Properties.class)
- .monitorInterval();
- return new XmlConfiguration(loggerContext, source, interval);
- }
-
- @Override
- public String getTestPrefix() {
- return TEST_PREFIX;
- }
-
- @Override
- public String getDefaultPrefix() {
- return DEFAULT_PREFIX;
- }
-
- @Override
- public String getVersion() {
- return LOG4J1_VERSION;
- }
-}
diff --git a/log4j-1.2-api/src/main/java/org/apache/log4j/xml/package-info.java b/log4j-1.2-api/src/main/java/org/apache/log4j/xml/package-info.java
deleted file mode 100644
index b7c3d31598d..00000000000
--- a/log4j-1.2-api/src/main/java/org/apache/log4j/xml/package-info.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache license, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the license for the specific language governing permissions and
- * limitations under the license.
- */
-/**
- * Log4j 1.x compatibility layer.
- */
-@Export
-@Version("2.20.2")
-package org.apache.log4j.xml;
-
-import org.osgi.annotation.bundle.Export;
-import org.osgi.annotation.versioning.Version;
diff --git a/log4j-1.2-api/src/main/resources/META-INF/log4j/propertyMapping.json b/log4j-1.2-api/src/main/resources/META-INF/log4j/propertyMapping.json
deleted file mode 100644
index eda0fc2d630..00000000000
--- a/log4j-1.2-api/src/main/resources/META-INF/log4j/propertyMapping.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "v1": {
- "compatibility": [
- "log4j1.compatibility"
- ],
- "configuration": [
- "log4j.configuration"
- ],
- "monitorInterval": [
- "log4j1.monitorInterval"
- ]
- }
-}
\ No newline at end of file
diff --git a/log4j-1.2-api/src/main/resources/org/apache/log4j/xml/log4j.dtd b/log4j-1.2-api/src/main/resources/org/apache/log4j/xml/log4j.dtd
deleted file mode 100644
index f8e433a50e6..00000000000
--- a/log4j-1.2-api/src/main/resources/org/apache/log4j/xml/log4j.dtd
+++ /dev/null
@@ -1,237 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/BasicConfigurationFactory.java b/log4j-1.2-api/src/test/java/org/apache/log4j/BasicConfigurationFactory.java
deleted file mode 100644
index fbf5ba1d5fb..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/BasicConfigurationFactory.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-import java.net.URI;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.AbstractConfiguration;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.ConfigurationFactory;
-import org.apache.logging.log4j.core.config.ConfigurationSource;
-import org.apache.logging.log4j.core.config.LoggerConfig;
-
-/**
- *
- */
-public class BasicConfigurationFactory extends ConfigurationFactory {
-
- @Override
- protected String[] getSupportedTypes() {
- return new String[] {"*"};
- }
-
- @Override
- public Configuration getConfiguration(final LoggerContext loggerContext, final ConfigurationSource source) {
- return new BasicConfiguration(loggerContext);
- }
-
- @Override
- public Configuration getConfiguration(
- final LoggerContext loggerContext, final String name, final URI configLocation) {
- return new BasicConfiguration(loggerContext);
- }
-
- public static class BasicConfiguration extends AbstractConfiguration {
-
- private static final String DEFAULT_LEVEL = "org.apache.logging.log4j.level";
-
- public BasicConfiguration(final LoggerContext loggerContext) {
- super(loggerContext, ConfigurationSource.NULL_SOURCE);
-
- final LoggerConfig root = getRootLogger();
- setName("BasicConfiguration");
- final String levelName = System.getProperty(DEFAULT_LEVEL);
- final Level level =
- (levelName != null && Level.getLevel(levelName) != null) ? Level.getLevel(levelName) : Level.DEBUG;
- root.setLevel(level);
- }
-
- @Override
- protected void doConfigure() {}
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/BasicConfiguratorTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/BasicConfiguratorTest.java
deleted file mode 100644
index 0d2d8f49003..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/BasicConfiguratorTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-import org.apache.log4j.varia.NullAppender;
-import org.junit.jupiter.api.Test;
-
-/**
- * Test {@link BasicConfigurator}.
- */
-public class BasicConfiguratorTest {
-
- @Test
- public void testConfigure() {
- // TODO More...
- BasicConfigurator.configure();
- }
-
- @Test
- public void testResetConfiguration() {
- // TODO More...
- BasicConfigurator.resetConfiguration();
- }
-
- @Test
- public void testConfigureAppender() {
- BasicConfigurator.configure(null);
- // TODO More...
- }
-
- @Test
- public void testConfigureConsoleAppender() {
- // TODO What to do? Map to Log4j 2 Appender deeper in the code?
- BasicConfigurator.configure(new ConsoleAppender());
- }
-
- @Test
- public void testConfigureNullAppender() {
- // The NullAppender name is null and we do not want an NPE when the name is used as a key in a
- // ConcurrentHashMap.
- BasicConfigurator.configure(NullAppender.getNullAppender());
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/CallerInformationTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/CallerInformationTest.java
deleted file mode 100644
index 607a8989281..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/CallerInformationTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.List;
-import org.apache.logging.log4j.core.test.appender.ListAppender;
-import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
-import org.junit.ClassRule;
-import org.junit.Test;
-
-public class CallerInformationTest {
-
- // config from log4j-core test-jar
- private static final String CONFIG = "log4j2-calling-class.xml";
-
- @ClassRule
- public static final LoggerContextRule ctx = new LoggerContextRule(CONFIG);
-
- @Test
- public void testClassLogger() {
- final ListAppender app = ctx.getListAppender("Class").clear();
- final Logger logger = Logger.getLogger("ClassLogger");
- logger.info("Ignored message contents.");
- logger.warn("Verifying the caller class is still correct.");
- logger.error("Hopefully nobody breaks me!");
- final List messages = app.getMessages();
- assertEquals("Incorrect number of messages.", 3, messages.size());
- for (final String message : messages) {
- assertEquals("Incorrect caller class name.", this.getClass().getName(), message);
- }
- }
-
- @Test
- public void testMethodLogger() {
- final ListAppender app = ctx.getListAppender("Method").clear();
- final Logger logger = Logger.getLogger("MethodLogger");
- logger.info("More messages.");
- logger.warn("CATASTROPHE INCOMING!");
- logger.error("ZOMBIES!!!");
- logger.warn("brains~~~");
- logger.info("Itchy. Tasty.");
- final List messages = app.getMessages();
- assertEquals("Incorrect number of messages.", 5, messages.size());
- for (final String message : messages) {
- assertEquals("Incorrect caller method name.", "testMethodLogger", message);
- }
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/CategoryTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/CategoryTest.java
deleted file mode 100644
index 0dc789bcf5a..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/CategoryTest.java
+++ /dev/null
@@ -1,428 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertSame;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import java.lang.reflect.Method;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Consumer;
-import org.apache.log4j.bridge.AppenderAdapter;
-import org.apache.log4j.bridge.AppenderWrapper;
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.layout.PatternLayout;
-import org.apache.logging.log4j.core.test.appender.ListAppender;
-import org.apache.logging.log4j.core.test.junit.ConfigurationFactoryType;
-import org.apache.logging.log4j.message.MapMessage;
-import org.apache.logging.log4j.message.Message;
-import org.apache.logging.log4j.message.ObjectMessage;
-import org.apache.logging.log4j.message.SimpleMessage;
-import org.apache.logging.log4j.util.Cast;
-import org.apache.logging.log4j.util.Constants;
-import org.apache.logging.log4j.util.Strings;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-/**
- * Tests of Category.
- */
-@ConfigurationFactoryType(BasicConfigurationFactory.class)
-public class CategoryTest {
-
- private static final String VERSION1_APPENDER_NAME = "Version1List";
- private static final String VERSION2_APPENDER_NAME = "List";
- private static final ListAppender appender = new ListAppender(VERSION2_APPENDER_NAME);
- private static final org.apache.log4j.ListAppender version1Appender = new org.apache.log4j.ListAppender();
-
- @BeforeAll
- public static void setupClass() {
- appender.start();
- version1Appender.setName(VERSION1_APPENDER_NAME);
- }
-
- @AfterAll
- public static void cleanupClass() {
- appender.stop();
- }
-
- @BeforeEach
- public void before() {
- appender.clear();
- }
-
- @Test
- public void testExist() {
- assertNull(Category.exists("Does not exist for sure"));
- }
-
- /**
- * Tests Category.forcedLog.
- */
- @Test
- @SuppressWarnings("deprecation")
- public void testForcedLog() {
- final MockCategory category = new MockCategory("org.example.foo");
- category.setAdditivity(false);
- category.setHierarchy(LogManager.getHierarchy());
- ((org.apache.logging.log4j.core.Logger) category.getLogger()).addAppender(appender);
- // Logging a String
- category.info("Hello, World");
- List list = appender.getEvents();
- int events = list.size();
- assertEquals(1, events, "Number of events should be 1, was " + events);
- LogEvent event = list.get(0);
- Message msg = event.getMessage();
- assertNotNull(msg, "No message");
- // LOG4J2-3080: use message type consistently
- assertTrue(msg instanceof SimpleMessage, "Incorrect Message type");
- assertEquals("Hello, World", msg.getFormat());
- appender.clear();
- // Logging a String map
- category.info(Collections.singletonMap("hello", "world"));
- list = appender.getEvents();
- events = list.size();
- assertTrue(events == 1, "Number of events should be 1, was " + events);
- event = list.get(0);
- msg = event.getMessage();
- assertNotNull(msg, "No message");
- assertTrue(msg instanceof MapMessage, "Incorrect Message type");
- Object[] objects = msg.getParameters();
- assertEquals("world", objects[0]);
- appender.clear();
- // Logging a generic map
- category.info(Collections.singletonMap(1234L, "world"));
- list = appender.getEvents();
- events = list.size();
- assertTrue(events == 1, "Number of events should be 1, was " + events);
- event = list.get(0);
- msg = event.getMessage();
- assertNotNull(msg, "No message");
- assertTrue(msg instanceof MapMessage, "Incorrect Message type");
- objects = msg.getParameters();
- assertEquals("world", objects[0]);
- appender.clear();
- // Logging an object
- final Object obj = new Object();
- category.info(obj);
- list = appender.getEvents();
- events = list.size();
- assertTrue(events == 1, "Number of events should be 1, was " + events);
- event = list.get(0);
- msg = event.getMessage();
- assertNotNull(msg, "No message");
- assertTrue(msg instanceof ObjectMessage, "Incorrect Message type");
- objects = msg.getParameters();
- assertEquals(obj, objects[0]);
- appender.clear();
-
- category.log(Priority.INFO, "Hello, World");
- list = appender.getEvents();
- events = list.size();
- assertTrue(events == 1, "Number of events should be 1, was " + events);
- event = list.get(0);
- msg = event.getMessage();
- assertNotNull(msg, "No message");
- assertTrue(msg instanceof SimpleMessage, "Incorrect Message type");
- assertEquals("Hello, World", msg.getFormat());
- appender.clear();
- }
-
- /**
- * Tests that the return type of getChainedPriority is Priority.
- *
- * @throws Exception thrown if Category.getChainedPriority can not be found.
- */
- @Test
- public void testGetChainedPriorityReturnType() throws Exception {
- final Method method = Category.class.getMethod("getChainedPriority", (Class[]) null);
- assertSame(method.getReturnType(), Priority.class);
- }
-
- /**
- * Tests l7dlog(Priority, String, Throwable).
- */
- @Test
- public void testL7dlog() {
- final Logger logger = Logger.getLogger("org.example.foo");
- logger.setLevel(Level.ERROR);
- final Priority debug = Level.DEBUG;
- logger.l7dlog(debug, "Hello, World", null);
- assertTrue(appender.getEvents().isEmpty());
- }
-
- /**
- * Tests l7dlog(Priority, String, Object[], Throwable).
- */
- @Test
- public void testL7dlog4Param() {
- final Logger logger = Logger.getLogger("org.example.foo");
- logger.setLevel(Level.ERROR);
- final Priority debug = Level.DEBUG;
- logger.l7dlog(debug, "Hello, World", Constants.EMPTY_OBJECT_ARRAY, null);
- assertTrue(appender.getEvents().isEmpty());
- }
-
- /**
- * Test using a pre-existing Log4j 2 logger
- */
- @Test
- public void testExistingLog4j2Logger() {
- // create the logger using LogManager
- org.apache.logging.log4j.LogManager.getLogger("existingLogger");
- // Logger will be the one created above
- final Logger logger = Logger.getLogger("existingLogger");
- final Logger l2 = LogManager.getLogger("existingLogger");
- assertEquals(logger, l2);
- logger.setLevel(Level.ERROR);
- final Priority debug = Level.DEBUG;
- // the next line will throw an exception if the LogManager loggers
- // aren't supported by 1.2 Logger/Category
- logger.l7dlog(debug, "Hello, World", Constants.EMPTY_OBJECT_ARRAY, null);
- assertTrue(appender.getEvents().isEmpty());
- }
-
- /**
- * Tests setPriority(Priority).
- *
- * @deprecated
- */
- @Deprecated
- @Test
- public void testSetPriority() {
- final Logger logger = Logger.getLogger("org.example.foo");
- final Priority debug = Level.DEBUG;
- logger.setPriority(debug);
- }
-
- /**
- * Tests setPriority(Priority).
- *
- * @deprecated
- */
- @Deprecated
- @Test
- public void testSetPriorityNull() {
- Logger.getLogger("org.example.foo").setPriority(null);
- }
-
- @Test
- public void testClassName() {
- final Category category = Category.getInstance("TestCategory");
- final Layout layout =
- PatternLayout.newBuilder().setPattern("%d %p %C{1.} [%t] %m%n").build();
- final ListAppender appender = new ListAppender("List2", null, layout, false, false);
- appender.start();
- category.setAdditivity(false);
- ((org.apache.logging.log4j.core.Logger) category.getLogger()).addAppender(appender);
- category.error("Test Message");
- final List msgs = appender.getMessages();
- assertEquals(1, msgs.size(), "Incorrect number of messages. Expected 1 got " + msgs.size());
- final String msg = msgs.get(0);
- appender.clear();
- final String threadName = Thread.currentThread().getName();
- final String expected = "ERROR o.a.l.CategoryTest [" + threadName + "] Test Message" + Strings.LINE_SEPARATOR;
- assertTrue(
- msg.endsWith(expected),
- "Incorrect message " + Strings.dquote(msg) + " expected " + Strings.dquote(expected));
- }
-
- @Test
- public void testStringLog() {
- final String payload = "payload";
- testMessageImplementation(
- payload, SimpleMessage.class, message -> assertEquals(message.getFormattedMessage(), payload));
- }
-
- @Test
- public void testCharSequenceLog() {
- final CharSequence payload = new CharSequence() {
-
- @Override
- public int length() {
- return 3;
- }
-
- @Override
- public char charAt(final int index) {
- return "abc".charAt(index);
- }
-
- @Override
- public CharSequence subSequence(final int start, final int end) {
- return "abc".subSequence(start, end);
- }
-
- @Override
- public String toString() {
- return "abc";
- }
- };
- testMessageImplementation(
- payload,
- SimpleMessage.class,
- message -> assertEquals(message.getFormattedMessage(), payload.toString()));
- }
-
- @Test
- public void testMapLog() {
- final String key = "key";
- final Object value = 0xDEADBEEF;
- final Map payload = Collections.singletonMap(key, value);
- testMessageImplementation(payload, MapMessage.class, message -> assertEquals(message.getData(), payload));
- }
-
- @Test
- public void testObjectLog() {
- final Object payload = new Object();
- testMessageImplementation(
- payload, ObjectMessage.class, message -> assertEquals(message.getParameter(), payload));
- }
-
- private void testMessageImplementation(
- final Object messagePayload, final Class expectedMessageClass, final Consumer messageTester) {
-
- // Setup the logger and the appender.
- final Category category = Category.getInstance("TestCategory");
- final org.apache.logging.log4j.core.Logger logger = (org.apache.logging.log4j.core.Logger) category.getLogger();
- logger.addAppender(appender);
-
- // Log the message payload.
- category.info(messagePayload);
-
- // Verify collected log events.
- final List events = appender.getEvents();
- assertEquals(1, events.size(), "was expecting a single event");
- final LogEvent logEvent = events.get(0);
-
- // Verify the collected message.
- final Message message = logEvent.getMessage();
- final Class extends Message> actualMessageClass = message.getClass();
- assertTrue(
- expectedMessageClass.isAssignableFrom(actualMessageClass),
- "was expecting message to be instance of " + expectedMessageClass + ", found: " + actualMessageClass);
- final M typedMessage = Cast.cast(message);
- messageTester.accept(typedMessage);
- }
-
- @Test
- public void testAddAppender() {
- try {
- final Logger rootLogger = LogManager.getRootLogger();
- int count = version1Appender.getEvents().size();
- rootLogger.addAppender(version1Appender);
- final Logger logger = LogManager.getLogger(CategoryTest.class);
- final org.apache.log4j.ListAppender appender = new org.apache.log4j.ListAppender();
- appender.setName("appender2");
- logger.addAppender(appender);
- // Root logger
- rootLogger.info("testAddLogger");
- assertEquals(++count, version1Appender.getEvents().size(), "adding at root works");
- assertEquals(0, appender.getEvents().size(), "adding at child works");
- // Another logger
- logger.info("testAddLogger2");
- assertEquals(++count, version1Appender.getEvents().size(), "adding at root works");
- assertEquals(1, appender.getEvents().size(), "adding at child works");
- // Call appenders
- final LoggingEvent event = new LoggingEvent();
- logger.callAppenders(event);
- assertEquals(++count, version1Appender.getEvents().size(), "callAppenders");
- assertEquals(2, appender.getEvents().size(), "callAppenders");
- } finally {
- LogManager.resetConfiguration();
- }
- }
-
- @Test
- public void testGetAppender() {
- try {
- final Logger rootLogger = LogManager.getRootLogger();
- final org.apache.logging.log4j.core.Logger v2RootLogger =
- (org.apache.logging.log4j.core.Logger) rootLogger.getLogger();
- v2RootLogger.addAppender(AppenderAdapter.adapt(version1Appender));
- v2RootLogger.addAppender(appender);
- final List rootAppenders = Collections.list(rootLogger.getAllAppenders());
- assertEquals(1, rootAppenders.size(), "only v1 appenders");
- assertTrue(rootAppenders.get(0) instanceof org.apache.log4j.ListAppender, "appender is a v1 ListAppender");
- assertEquals(
- VERSION1_APPENDER_NAME,
- rootLogger.getAppender(VERSION1_APPENDER_NAME).getName(),
- "explicitly named appender");
- final Appender v2ListAppender = rootLogger.getAppender(VERSION2_APPENDER_NAME);
- assertTrue(v2ListAppender instanceof AppenderWrapper, "explicitly named appender");
- assertTrue(
- ((AppenderWrapper) v2ListAppender).getAppender() instanceof ListAppender,
- "appender is a v2 ListAppender");
-
- final Logger logger = LogManager.getLogger(CategoryTest.class);
- final org.apache.logging.log4j.core.Logger v2Logger =
- (org.apache.logging.log4j.core.Logger) logger.getLogger();
- final org.apache.log4j.ListAppender loggerAppender = new org.apache.log4j.ListAppender();
- loggerAppender.setName("appender2");
- v2Logger.addAppender(AppenderAdapter.adapt(loggerAppender));
- final List appenders = Collections.list(logger.getAllAppenders());
- assertEquals(1, appenders.size(), "no parent appenders");
- assertEquals(loggerAppender, appenders.get(0));
- assertNull(logger.getAppender(VERSION1_APPENDER_NAME), "no parent appenders");
- assertNull(logger.getAppender(VERSION2_APPENDER_NAME), "no parent appenders");
-
- final Logger childLogger = LogManager.getLogger(CategoryTest.class.getName() + ".child");
- final Enumeration childAppenders = childLogger.getAllAppenders();
- assertFalse(childAppenders.hasMoreElements(), "no parent appenders");
- assertNull(childLogger.getAppender("appender2"), "no parent appenders");
- assertNull(childLogger.getAppender(VERSION1_APPENDER_NAME), "no parent appenders");
- assertNull(childLogger.getAppender(VERSION2_APPENDER_NAME), "no parent appenders");
- } finally {
- LogManager.resetConfiguration();
- }
- }
-
- /**
- * Derived category to check method signature of forcedLog.
- */
- private static class MockCategory extends Logger {
- /**
- * Create new instance of MockCategory.
- *
- * @param name category name
- */
- public MockCategory(final String name) {
- super(name);
- }
-
- /**
- * Request an info level message.
- *
- * @param msg message
- */
- public void info(final String msg) {
- final Priority info = Level.INFO;
- forcedLog(MockCategory.class.toString(), info, msg, null);
- }
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/ConsoleAppenderTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/ConsoleAppenderTest.java
deleted file mode 100644
index 9b55dd31f84..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/ConsoleAppenderTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-/**
- * Used to test Log4j 1 support.
- */
-public class ConsoleAppenderTest {
-
- private ConsoleAppender consoleAppender;
-
- @BeforeEach
- public void beforeEach() {
- consoleAppender = new ConsoleAppender();
- }
-
- @Test
- public void testFollow() {
- // Only really care that it compiles, behavior is secondary at this level.
- consoleAppender.setFollow(true);
- assertTrue(consoleAppender.getFollow());
- }
-
- @Test
- public void testTarget() {
- // Only really care that it compiles, behavior is secondary at this level.
- consoleAppender.setTarget(ConsoleAppender.SYSTEM_OUT);
- assertEquals(ConsoleAppender.SYSTEM_OUT, consoleAppender.getTarget());
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/CustomAppenderSkeleton.java b/log4j-1.2-api/src/test/java/org/apache/log4j/CustomAppenderSkeleton.java
deleted file mode 100644
index 53596ed7c38..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/CustomAppenderSkeleton.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-import org.apache.log4j.spi.ErrorHandler;
-import org.apache.log4j.spi.Filter;
-import org.apache.log4j.spi.LoggingEvent;
-
-/**
- * Used to test Log4j 1 support. All we are looking for here is that this code compiles.
- */
-public class CustomAppenderSkeleton extends AppenderSkeleton {
-
- @Override
- protected void append(final LoggingEvent event) {
- // NOOP @Override
- }
-
- @Override
- public void close() {
- // NOOP @Override
- }
-
- @SuppressWarnings({"cast", "unused"})
- public void compilerAccessToWriterAppenderSkeletonVariables() {
- if (closed) {
- // Yep, it compiles.
- final boolean compileMe = closed;
- }
- if (errorHandler instanceof ErrorHandler) {
- // Yep, it compiles.
- final ErrorHandler other = errorHandler;
- }
- if (headFilter instanceof Filter) {
- // Yep, it compiles.
- final Filter other = headFilter;
- }
- if (layout instanceof Layout) {
- // Yep, it compiles.
- final Layout other = layout;
- }
- if (name instanceof String) {
- // Yep, it compiles.
- final String other = name;
- }
- if (tailFilter instanceof Filter) {
- // Yep, it compiles.
- final Filter other = tailFilter;
- }
- if (threshold instanceof Priority) {
- // Yep, it compiles.
- final Priority other = threshold;
- }
- }
-
- @Override
- public boolean requiresLayout() {
- // NOOP @Override
- return false;
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/CustomConsoleAppender.java b/log4j-1.2-api/src/test/java/org/apache/log4j/CustomConsoleAppender.java
deleted file mode 100644
index b14c6114ff4..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/CustomConsoleAppender.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-import org.apache.log4j.helpers.QuietWriter;
-import org.apache.log4j.spi.ErrorHandler;
-import org.apache.log4j.spi.Filter;
-
-/**
- * Used to test Log4j 1 support. All we are looking for here is that this code compiles.
- */
-public class CustomConsoleAppender extends ConsoleAppender {
-
- public CustomConsoleAppender() {
- super();
- }
-
- public CustomConsoleAppender(final Layout layout) {
- super(layout);
- }
-
- public CustomConsoleAppender(final Layout layout, final String target) {
- super(layout, target);
- }
-
- @SuppressWarnings({"cast", "unused"})
- public void compilerAccessToConsoleAppenderInstanceVariables() {
- if (target instanceof String) {
- final String other = name;
- }
- }
-
- @SuppressWarnings({"cast", "unused"})
- public void compilerAccessToWriterAppenderInstanceVariables() {
- if (immediateFlush) {
- final boolean other = immediateFlush;
- }
- if (encoding instanceof String) {
- final String other = encoding;
- }
- if (qw instanceof QuietWriter) {
- final QuietWriter other = qw;
- }
- }
-
- @SuppressWarnings({"cast", "unused"})
- public void compilerAccessToWriterAppenderSkeletonVariables() {
- if (closed) {
- final boolean compileMe = closed;
- }
- if (errorHandler instanceof ErrorHandler) {
- final ErrorHandler other = errorHandler;
- }
- if (headFilter instanceof Filter) {
- final Filter other = headFilter;
- }
- if (layout instanceof Layout) {
- final Layout other = layout;
- }
- if (name instanceof String) {
- final String other = name;
- }
- if (tailFilter instanceof Filter) {
- final Filter other = tailFilter;
- }
- if (threshold instanceof Priority) {
- final Priority other = threshold;
- }
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/CustomFileAppender.java b/log4j-1.2-api/src/test/java/org/apache/log4j/CustomFileAppender.java
deleted file mode 100644
index 965287f9284..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/CustomFileAppender.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-public class CustomFileAppender extends FileAppender {
-
- private boolean booleanA;
- private int intA;
- private String stringA;
-
- public boolean getBooleanA() {
- return booleanA;
- }
-
- public int getIntA() {
- return intA;
- }
-
- public String getStringA() {
- return stringA;
- }
-
- public void setBooleanA(final boolean booleanA) {
- this.booleanA = booleanA;
- }
-
- public void setIntA(final int intA) {
- this.intA = intA;
- }
-
- public void setStringA(final String stringA) {
- this.stringA = stringA;
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/CustomNoopAppender.java b/log4j-1.2-api/src/test/java/org/apache/log4j/CustomNoopAppender.java
deleted file mode 100644
index 2c775960961..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/CustomNoopAppender.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-import org.apache.log4j.spi.LoggingEvent;
-
-public class CustomNoopAppender extends AppenderSkeleton {
-
- private boolean booleanA;
- private int intA;
- private String stringA;
-
- @Override
- protected void append(final LoggingEvent event) {
- // Noop
- }
-
- @Override
- public void close() {
- // Noop
- }
-
- public boolean getBooleanA() {
- return booleanA;
- }
-
- public int getIntA() {
- return intA;
- }
-
- public String getStringA() {
- return stringA;
- }
-
- @Override
- public boolean requiresLayout() {
- return false;
- }
-
- public void setBooleanA(final boolean booleanA) {
- this.booleanA = booleanA;
- }
-
- public void setIntA(final int intA) {
- this.intA = intA;
- }
-
- public void setStringA(final String stringA) {
- this.stringA = stringA;
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/CustomWriterAppender.java b/log4j-1.2-api/src/test/java/org/apache/log4j/CustomWriterAppender.java
deleted file mode 100644
index e4c5a4a14ee..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/CustomWriterAppender.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-import org.apache.log4j.helpers.QuietWriter;
-import org.apache.log4j.spi.ErrorHandler;
-import org.apache.log4j.spi.Filter;
-
-/**
- * Used to test Log4j 1 support. All we are looking for here is that this code compiles.
- */
-public class CustomWriterAppender extends WriterAppender {
-
- public void compilerAccessToWriterAppenderInstanceVariables() {
- if (immediateFlush) {
- // Yep, it compiles.
- final boolean other = immediateFlush;
- }
- if (encoding instanceof String) {
- // Yep, it compiles.
- final String other = encoding;
- }
- if (qw instanceof QuietWriter) {
- // Yep, it compiles.
- final QuietWriter other = qw;
- }
- }
-
- @SuppressWarnings({"cast", "unused"})
- public void compilerAccessToWriterAppenderSkeletonVariables() {
- if (closed) {
- // Yep, it compiles.
- final boolean compileMe = closed;
- }
- if (errorHandler instanceof ErrorHandler) {
- // Yep, it compiles.
- final ErrorHandler other = errorHandler;
- }
- if (headFilter instanceof Filter) {
- // Yep, it compiles.
- final Filter other = headFilter;
- }
- if (layout instanceof Layout) {
- // Yep, it compiles.
- final Layout other = layout;
- }
- if (name instanceof String) {
- // Yep, it compiles.
- final String other = name;
- }
- if (tailFilter instanceof Filter) {
- // Yep, it compiles.
- final Filter other = tailFilter;
- }
- if (threshold instanceof Priority) {
- // Yep, it compiles.
- final Priority other = threshold;
- }
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/LayoutTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/LayoutTest.java
deleted file mode 100644
index c85b7fe68a1..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/LayoutTest.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-import junit.framework.TestCase;
-import org.apache.log4j.spi.LoggingEvent;
-
-/**
- * Tests for Layout.
- *
- */
-public class LayoutTest extends TestCase {
-
- /**
- * Concrete Layout class for tests.
- */
- private static final class MockLayout extends Layout {
- /**
- * {@inheritDoc}
- */
- public void activateOptions() {}
-
- /**
- * {@inheritDoc}
- */
- public String format(final LoggingEvent event) {
- return "Mock";
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean ignoresThrowable() {
- return true;
- }
- }
-
- /**
- * Expected content type.
- */
- private final String contentType;
-
- /**
- * Expected value for ignoresThrowable.
- */
- private final boolean ignoresThrowable;
-
- /**
- * Expected value for header.
- */
- private final String header;
-
- /**
- * Expected value for footer.
- */
- private final String footer;
-
- /**
- * Construct a new instance of LayoutTest.
- *
- * @param testName test name.
- */
- public LayoutTest(final String testName) {
- super(testName);
- contentType = "text/plain";
- ignoresThrowable = true;
- header = null;
- footer = null;
- }
-
- /**
- * Constructor for use by derived tests.
- *
- * @param testName name of test.
- * @param expectedContentType expected value for getContentType().
- * @param expectedIgnoresThrowable expected value for ignoresThrowable().
- * @param expectedHeader expected value for getHeader().
- * @param expectedFooter expected value for getFooter().
- */
- protected LayoutTest(
- final String testName,
- final String expectedContentType,
- final boolean expectedIgnoresThrowable,
- final String expectedHeader,
- final String expectedFooter) {
- super(testName);
- contentType = expectedContentType;
- ignoresThrowable = expectedIgnoresThrowable;
- header = expectedHeader;
- footer = expectedFooter;
- }
-
- /**
- * Creates layout for test.
- *
- * @return new instance of Layout.
- */
- protected Layout createLayout() {
- return new MockLayout();
- }
-
- /**
- * Tests format.
- *
- * @throws Exception derived tests, particular XMLLayoutTest, may throw exceptions.
- */
- public void testFormat() throws Exception {
- final Logger logger = Logger.getLogger("org.apache.log4j.LayoutTest");
- final LoggingEvent event =
- new LoggingEvent("org.apache.log4j.Logger", logger, Level.INFO, "Hello, World", null);
- final String result = createLayout().format(event);
- assertEquals("Mock", result);
- }
-
- /**
- * Tests getContentType.
- */
- public void testGetContentType() {
- assertEquals(contentType, createLayout().getContentType());
- }
-
- /**
- * Tests getFooter.
- */
- public void testGetFooter() {
- assertEquals(footer, createLayout().getFooter());
- }
-
- /**
- * Tests getHeader.
- */
- public void testGetHeader() {
- assertEquals(header, createLayout().getHeader());
- }
-
- /**
- * Tests ignoresThrowable.
- */
- public void testIgnoresThrowable() {
- assertEquals(ignoresThrowable, createLayout().ignoresThrowable());
- }
-
- /**
- * Tests Layout.LINE_SEP.
- */
- public void testLineSep() {
- assertEquals(System.getProperty("line.separator"), Layout.LINE_SEP);
- }
-
- /**
- * Tests Layout.LINE_SEP.
- */
- public void testLineSepLen() {
- assertEquals(Layout.LINE_SEP.length(), Layout.LINE_SEP_LEN);
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/LevelTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/LevelTest.java
deleted file mode 100644
index dd8ef3f024a..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/LevelTest.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Locale;
-import org.apache.log4j.util.SerializationTestHelper;
-import org.junit.Test;
-
-/**
- * Tests of Level.
- *
- * @since 1.2.12
- */
-public class LevelTest {
-
- /**
- * Serialize Level.INFO and check against witness.
- *
- * @throws Exception if exception during test.
- */
- @Test
- public void testSerializeINFO() throws Exception {
- final int[] skip = new int[] {};
- SerializationTestHelper.assertSerializationEquals(
- "target/test-classes/witness/serialization/info.bin", Level.INFO, skip, Integer.MAX_VALUE);
- }
-
- /**
- * Deserialize witness and see if resolved to Level.INFO.
- *
- * @throws Exception if exception during test.
- */
- @Test
- public void testDeserializeINFO() throws Exception {
- final Object obj =
- SerializationTestHelper.deserializeStream("target/test-classes/witness/serialization/info.bin");
- assertTrue(obj instanceof Level);
- final Level info = (Level) obj;
- assertEquals("INFO", info.toString());
- //
- // JDK 1.1 doesn't support readResolve necessary for the assertion
- if (!System.getProperty("java.version").startsWith("1.1.")) {
- assertTrue(obj == Level.INFO);
- }
- }
-
- /**
- * Tests that a custom level can be serialized and deserialized
- * and is not resolved to a stock level.
- *
- * @throws Exception if exception during test.
- */
- @Test
- public void testCustomLevelSerialization() throws Exception {
- final CustomLevel custom = new CustomLevel();
- final Object obj = SerializationTestHelper.serializeClone(custom);
- assertTrue(obj instanceof CustomLevel);
-
- final CustomLevel clone = (CustomLevel) obj;
- assertEquals(Level.INFO.level, clone.level);
- assertEquals(Level.INFO.levelStr, clone.levelStr);
- assertEquals(Level.INFO.syslogEquivalent, clone.syslogEquivalent);
- }
-
- /**
- * Custom level to check that custom levels are
- * serializable, but not resolved to a plain Level.
- */
- private static class CustomLevel extends Level {
- /**
- * Generated serial version ID.
- */
- private static final long serialVersionUID = -6931920872225831135L;
-
- /**
- * Create an instance of CustomLevel.
- */
- public CustomLevel() {
- super(Level.INFO.level, Level.INFO.levelStr, Level.INFO.syslogEquivalent);
- }
- }
-
- /**
- * Tests Level.TRACE_INT.
- */
- @Test
- public void testTraceInt() {
- assertEquals(5000, Level.TRACE_INT);
- }
-
- /**
- * Tests Level.TRACE.
- */
- @Test
- public void testTrace() {
- assertEquals("TRACE", Level.TRACE.toString());
- assertEquals(5000, Level.TRACE.toInt());
- assertEquals(7, Level.TRACE.getSyslogEquivalent());
- }
-
- /**
- * Tests Level.toLevel(Level.TRACE_INT).
- */
- @Test
- public void testIntToTrace() {
- final Level trace = Level.toLevel(5000);
- assertEquals("TRACE", trace.toString());
- }
-
- /**
- * Tests Level.toLevel("TRACE");
- */
- @Test
- public void testStringToTrace() {
- final Level trace = Level.toLevel("TRACE");
- assertEquals("TRACE", trace.toString());
- }
-
- /**
- * Tests that Level extends Priority.
- */
- @Test
- public void testLevelExtendsPriority() {
- assertTrue(Priority.class.isAssignableFrom(Level.class));
- }
-
- /**
- * Tests Level.OFF.
- */
- @Test
- public void testOFF() {
- assertTrue(Level.OFF instanceof Level);
- }
-
- /**
- * Tests Level.FATAL.
- */
- @Test
- public void testFATAL() {
- assertTrue(Level.FATAL instanceof Level);
- }
-
- /**
- * Tests Level.ERROR.
- */
- @Test
- public void testERROR() {
- assertTrue(Level.ERROR instanceof Level);
- }
-
- /**
- * Tests Level.WARN.
- */
- @Test
- public void testWARN() {
- assertTrue(Level.WARN instanceof Level);
- }
-
- /**
- * Tests Level.INFO.
- */
- @Test
- public void testINFO() {
- assertTrue(Level.INFO instanceof Level);
- }
-
- /**
- * Tests Level.DEBUG.
- */
- @Test
- public void testDEBUG() {
- assertTrue(Level.DEBUG instanceof Level);
- }
-
- /**
- * Tests Level.TRACE.
- */
- @Test
- public void testTRACE() {
- assertTrue(Level.TRACE instanceof Level);
- }
-
- /**
- * Tests Level.ALL.
- */
- @Test
- public void testALL() {
- assertTrue(Level.ALL instanceof Level);
- }
-
- /**
- * Tests Level.toLevel(Level.All_INT).
- */
- @Test
- public void testIntToAll() {
- final Level level = Level.toLevel(Priority.ALL_INT);
- assertEquals("ALL", level.toString());
- }
-
- /**
- * Tests Level.toLevel(Level.FATAL_INT).
- */
- @Test
- public void testIntToFatal() {
- final Level level = Level.toLevel(Priority.FATAL_INT);
- assertEquals("FATAL", level.toString());
- }
-
- /**
- * Tests Level.toLevel(Level.OFF_INT).
- */
- @Test
- public void testIntToOff() {
- final Level level = Level.toLevel(Priority.OFF_INT);
- assertEquals("OFF", level.toString());
- }
-
- /**
- * Tests Level.toLevel(17, Level.FATAL).
- */
- @Test
- public void testToLevelUnrecognizedInt() {
- final Level level = Level.toLevel(17, Level.FATAL);
- assertEquals("FATAL", level.toString());
- }
-
- /**
- * Tests Level.toLevel(null, Level.FATAL).
- */
- @Test
- public void testToLevelNull() {
- final Level level = Level.toLevel(null, Level.FATAL);
- assertEquals("FATAL", level.toString());
- }
-
- /**
- * Test that dotless lower I + "nfo" is recognized as INFO.
- */
- @Test
- public void testDotlessLowerI() {
- final Level level = Level.toLevel("\u0131nfo");
- assertEquals("INFO", level.toString());
- }
-
- /**
- * Test that dotted lower I + "nfo" is recognized as INFO
- * even in Turkish locale.
- */
- @Test
- public void testDottedLowerI() {
- final Locale defaultLocale = Locale.getDefault();
- final Locale turkey = new Locale("tr", "TR");
- Locale.setDefault(turkey);
- final Level level = Level.toLevel("info");
- Locale.setDefault(defaultLocale);
- assertEquals("INFO", level.toString());
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/ListAppender.java b/log4j-1.2-api/src/test/java/org/apache/log4j/ListAppender.java
deleted file mode 100644
index cfc9fe49bcc..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/ListAppender.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-import static org.awaitility.Awaitility.waitAtMost;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-import org.apache.log4j.spi.LoggingEvent;
-
-/**
- * Used to test Log4j 1 support.
- */
-public class ListAppender extends AppenderSkeleton {
- // Use Collections.synchronizedList rather than CopyOnWriteArrayList because we expect
- // more frequent writes than reads.
- final List events = Collections.synchronizedList(new ArrayList<>());
-
- private final List messages = Collections.synchronizedList(new ArrayList<>());
-
- private static final String WINDOWS_LINE_SEP = "\r\n";
-
- @Override
- protected void append(final LoggingEvent event) {
- final Layout layout = getLayout();
- if (layout != null) {
- final String result = layout.format(event);
- if (result != null) {
- messages.add(result);
- }
- } else {
- events.add(event);
- }
- }
-
- @Override
- public void close() {}
-
- @Override
- public boolean requiresLayout() {
- return false;
- }
-
- /** Returns an immutable snapshot of captured log events */
- public List getEvents() {
- return Collections.unmodifiableList(new ArrayList<>(events));
- }
-
- /** Returns an immutable snapshot of captured messages */
- public List getMessages() {
- return Collections.unmodifiableList(new ArrayList<>(messages));
- }
-
- /**
- * Polls the messages list for it to grow to a given minimum size at most timeout timeUnits and return a copy of
- * what we have so far.
- */
- public List getMessages(final int minSize, final long timeout, final TimeUnit timeUnit)
- throws InterruptedException {
- waitAtMost(timeout, timeUnit).until(() -> messages.size() >= minSize);
- return getMessages();
- }
-
- public String toString() {
- return String.format("ListAppender[%s]", getName());
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/LogManagerTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/LogManagerTest.java
deleted file mode 100644
index 858a0c3e069..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/LogManagerTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-import static org.junit.Assert.assertTrue;
-
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.stream.Collectors;
-import org.junit.Test;
-
-/**
- * Tests {@link LogManager}.
- */
-public class LogManagerTest {
-
- private static final String SIMPLE_NAME = LogManagerTest.class.getSimpleName();
-
- List getCurrentLoggerNames() {
- return Collections.list((Enumeration) LogManager.getCurrentLoggers()).stream()
- .map(Logger::getName)
- .collect(Collectors.toList());
- }
-
- @Test
- public void testGetCurrentLoggers() {
- Logger.getLogger(SIMPLE_NAME);
- Logger.getLogger(SIMPLE_NAME + ".foo");
- Logger.getLogger(SIMPLE_NAME + ".foo.bar");
- final List names = getCurrentLoggerNames();
- assertTrue(names.contains(SIMPLE_NAME));
- assertTrue(names.contains(SIMPLE_NAME + ".foo"));
- assertTrue(names.contains(SIMPLE_NAME + ".foo.bar"));
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/LogWithMDCTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/LogWithMDCTest.java
deleted file mode 100644
index f5be16c8289..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/LogWithMDCTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.List;
-import org.apache.logging.log4j.core.test.appender.ListAppender;
-import org.apache.logging.log4j.core.test.junit.LoggerContextRule;
-import org.junit.ClassRule;
-import org.junit.Test;
-
-/**
- * Test logging with MDC values.
- */
-public class LogWithMDCTest {
-
- private static final String CONFIG = "logWithMDC.xml";
-
- @ClassRule
- public static final LoggerContextRule CTX = new LoggerContextRule(CONFIG);
-
- @Test
- public void testMDC() {
- MDC.put("Key1", "John");
- MDC.put("Key2", "Smith");
- try {
- final Logger logger = Logger.getLogger("org.apache.test.logging");
- logger.debug("This is a test");
- final ListAppender listApp = (ListAppender) CTX.getAppender("List");
- assertNotNull(listApp);
- final List msgs = listApp.getMessages();
- assertNotNull("No messages received", msgs);
- assertTrue(msgs.size() == 1);
- assertTrue("Key1 is missing", msgs.get(0).contains("Key1=John"));
- assertTrue("Key2 is missing", msgs.get(0).contains("Key2=Smith"));
- } finally {
- MDC.remove("Key1");
- MDC.remove("Key2");
- }
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/LogWithRouteTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/LogWithRouteTest.java
deleted file mode 100644
index 8419416590f..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/LogWithRouteTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import java.util.List;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.test.appender.ListAppender;
-import org.apache.logging.log4j.core.test.junit.LoggerContextSource;
-import org.apache.logging.log4j.test.junit.UsingThreadContextMap;
-import org.junit.jupiter.api.Test;
-
-/**
- * Test passing MDC values to the Routing appender.
- */
-@UsingThreadContextMap
-public class LogWithRouteTest {
-
- private static final String CONFIG = "log-RouteWithMDC.xml";
-
- @Test
- @LoggerContextSource(CONFIG)
- public void testMDC(final Configuration configuration) {
- MDC.put("Type", "Service");
- MDC.put("Name", "John Smith");
- try {
- final Logger logger = Logger.getLogger("org.apache.test.logging");
- logger.debug("This is a test");
- final ListAppender listApp = configuration.getAppender("List");
- assertNotNull(listApp);
- final List msgs = listApp.getMessages();
- assertNotNull(msgs, "No messages received");
- assertEquals(1, msgs.size());
- assertTrue(msgs.get(0).contains("Type=Service"), "Type is missing");
- assertTrue(msgs.get(0).contains("Name=John Smith"), "Name is missing");
- } finally {
- MDC.remove("Type");
- MDC.remove("Name");
- }
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/LoggerJira3410Test.java b/log4j-1.2-api/src/test/java/org/apache/log4j/LoggerJira3410Test.java
deleted file mode 100644
index d6dbe4f344e..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/LoggerJira3410Test.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.apache.log4j.bridge.AppenderAdapter;
-import org.apache.log4j.config.TestConfigurator;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.util.SortedArrayStringMap;
-import org.junit.Test;
-
-/**
- * Tests Jira3410.
- */
-public class LoggerJira3410Test {
-
- @Test
- public void test() throws Exception {
- try (final LoggerContext loggerContext =
- TestConfigurator.configure("target/test-classes/log4j1-list.properties")) {
- final Logger logger = LogManager.getLogger("test");
- //
- final Map map = new HashMap<>(1);
- map.put(Long.MAX_VALUE, 1);
- logger.debug(map);
- //
- map.put(null, null);
- logger.debug(map);
- //
- logger.debug(new SortedArrayStringMap((Map) map));
- //
- final Configuration configuration = loggerContext.getConfiguration();
- final Map appenders = configuration.getAppenders();
- ListAppender listAppender = null;
- for (final Map.Entry entry : appenders.entrySet()) {
- if (entry.getKey().equals("list")) {
- listAppender = (ListAppender) ((AppenderAdapter.Adapter) entry.getValue()).getAppender();
- }
- }
- assertNotNull("No Message Appender", listAppender);
- final List messages = listAppender.getMessages();
- assertTrue("No messages", messages != null && !messages.isEmpty());
- final String msg0 = messages.get(0);
- final String msg1 = messages.get(1);
- final String msg2 = messages.get(2);
- // TODO Should be 1, not "1".
- // TODO Where are the {} characters?
- assertTrue(msg0, msg0.trim().endsWith(Long.MAX_VALUE + "=\"1\""));
- //
- // TODO Should be 1, not "1".
- // TODO Should be null, not "null".
- // TODO Where are the {} characters?
- // TODO Where is the , characters?
- assertTrue(msg1, msg1.trim().endsWith("null=\"null\" " + Long.MAX_VALUE + "=\"1\""));
- //
- assertTrue(msg2, msg2.trim().endsWith("{null=null, " + Long.MAX_VALUE + "=1}"));
- }
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/LoggerTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/LoggerTest.java
deleted file mode 100644
index 6cb6c7ec55e..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/LoggerTest.java
+++ /dev/null
@@ -1,520 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertSame;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import java.util.List;
-import java.util.Locale;
-import java.util.ResourceBundle;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.appender.AbstractAppender;
-import org.apache.logging.log4j.core.config.Property;
-import org.apache.logging.log4j.core.layout.PatternLayout;
-import org.apache.logging.log4j.core.test.appender.ListAppender;
-import org.apache.logging.log4j.core.test.junit.ConfigurationFactoryType;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-
-/**
- * Used for internal unit testing the Logger class.
- */
-@ConfigurationFactoryType(BasicConfigurationFactory.class)
-public class LoggerTest {
-
- Appender a1;
- Appender a2;
-
- static ResourceBundle rbUS;
- static ResourceBundle rbFR;
- static ResourceBundle rbCH;
-
- // A short message.
- static String MSG = "M";
-
- @BeforeAll
- public static void setUpClass() {
- rbUS = ResourceBundle.getBundle("L7D", new Locale("en", "US"));
- assertNotNull(rbUS);
-
- rbFR = ResourceBundle.getBundle("L7D", new Locale("fr", "FR"));
- assertNotNull(rbFR, "Got a null resource bundle.");
-
- rbCH = ResourceBundle.getBundle("L7D", new Locale("fr", "CH"));
- assertNotNull(rbCH, "Got a null resource bundle.");
- }
-
- @AfterEach
- public void tearDown() {
- LoggerContext.getContext().reconfigure();
- a1 = null;
- a2 = null;
- }
-
- /**
- * Add an appender and see if it can be retrieved.
- * Skipping this test as the Appender interface isn't compatible with legacy Log4j.
- * public void testAppender1() {
- * logger = Logger.getLogger("test");
- * a1 = new ListAppender("testAppender1");
- * logger.addAppender(a1);
- *
- * Enumeration enumeration = logger.getAllAppenders();
- * Appender aHat = (Appender) enumeration.nextElement();
- * assertEquals(a1, aHat);
- * } */
-
- /**
- * Add an appender X, Y, remove X and check if Y is the only
- * remaining appender.
- * Skipping this test as the Appender interface isn't compatible with legacy Log4j.
- * public void testAppender2() {
- * a1 = new FileAppender();
- * a1.setName("testAppender2.1");
- * a2 = new FileAppender();
- * a2.setName("testAppender2.2");
- *
- * logger = Logger.getLogger("test");
- * logger.addAppender(a1);
- * logger.addAppender(a2);
- * logger.removeAppender("testAppender2.1");
- * Enumeration enumeration = logger.getAllAppenders();
- * Appender aHat = (Appender) enumeration.nextElement();
- * assertEquals(a2, aHat);
- * assertTrue(!enumeration.hasMoreElements());
- * } */
-
- /**
- * Test if logger a.b inherits its appender from a.
- */
- @Test
- public void testAdditivity1() {
- final Logger loggerA = Logger.getLogger("a");
- assertEquals(Level.DEBUG, loggerA.getLevel());
- final Logger loggerAB = Logger.getLogger("a.b");
- final CountingAppender countingAppender = new CountingAppender();
- countingAppender.start();
- try {
- ((org.apache.logging.log4j.core.Logger) loggerA.getLogger()).addAppender(countingAppender);
-
- assertEquals(0, countingAppender.counter);
- loggerAB.debug(MSG);
- assertEquals(1, countingAppender.counter);
- loggerAB.info(MSG);
- assertEquals(2, countingAppender.counter);
- loggerAB.warn(MSG);
- assertEquals(3, countingAppender.counter);
- loggerAB.error(MSG);
- assertEquals(4, countingAppender.counter);
- countingAppender.stop();
- } finally {
- ((org.apache.logging.log4j.core.Logger) loggerA.getLogger()).removeAppender(countingAppender);
- }
- }
-
- /**
- * Test multiple additivity.
- */
- @Test
- public void testAdditivity2() {
- final Logger a = Logger.getLogger("a");
- final Logger ab = Logger.getLogger("a.b");
- final Logger abc = Logger.getLogger("a.b.c");
- final Logger x = Logger.getLogger("x");
-
- final CountingAppender ca1 = new CountingAppender();
- ca1.start();
- final CountingAppender ca2 = new CountingAppender();
- ca2.start();
-
- try {
- ((org.apache.logging.log4j.core.Logger) a.getLogger()).addAppender(ca1);
- ((org.apache.logging.log4j.core.Logger) abc.getLogger()).addAppender(ca2);
-
- assertEquals(ca1.counter, 0);
- assertEquals(ca2.counter, 0);
-
- ab.debug(MSG);
- assertEquals(ca1.counter, 1);
- assertEquals(ca2.counter, 0);
-
- abc.debug(MSG);
- assertEquals(ca1.counter, 2);
- assertEquals(ca2.counter, 1);
-
- x.debug(MSG);
- assertEquals(ca1.counter, 2);
- assertEquals(ca2.counter, 1);
- ca1.stop();
- ca2.stop();
- } finally {
- ((org.apache.logging.log4j.core.Logger) a.getLogger()).removeAppender(ca1);
- ((org.apache.logging.log4j.core.Logger) abc.getLogger()).removeAppender(ca2);
- }
- }
-
- /**
- * Test additivity flag.
- */
- @Test
- public void testAdditivity3() {
- final Logger root = Logger.getRootLogger();
- final Logger a = Logger.getLogger("a");
- final Logger ab = Logger.getLogger("a.b");
- final Logger abc = Logger.getLogger("a.b.c");
- Logger.getLogger("x");
-
- final CountingAppender caRoot = new CountingAppender();
- caRoot.start();
- final CountingAppender caA = new CountingAppender();
- caA.start();
- final CountingAppender caABC = new CountingAppender();
- caABC.start();
- try {
- ((org.apache.logging.log4j.core.Logger) root.getLogger()).addAppender(caRoot);
- ((org.apache.logging.log4j.core.Logger) a.getLogger()).addAppender(caA);
- ((org.apache.logging.log4j.core.Logger) abc.getLogger()).addAppender(caABC);
-
- assertEquals(caRoot.counter, 0);
- assertEquals(caA.counter, 0);
- assertEquals(caABC.counter, 0);
-
- ab.setAdditivity(false);
-
- a.debug(MSG);
- assertEquals(caRoot.counter, 1);
- assertEquals(caA.counter, 1);
- assertEquals(caABC.counter, 0);
-
- ab.debug(MSG);
- assertEquals(caRoot.counter, 1);
- assertEquals(caA.counter, 1);
- assertEquals(caABC.counter, 0);
-
- abc.debug(MSG);
- assertEquals(caRoot.counter, 1);
- assertEquals(caA.counter, 1);
- assertEquals(caABC.counter, 1);
- caRoot.stop();
- caA.stop();
- caABC.stop();
- } finally {
- ((org.apache.logging.log4j.core.Logger) root.getLogger()).removeAppender(caRoot);
- ((org.apache.logging.log4j.core.Logger) a.getLogger()).removeAppender(caA);
- ((org.apache.logging.log4j.core.Logger) abc.getLogger()).removeAppender(caABC);
- }
- }
-
- /* Don't support getLoggerRepository
- public void testDisable1() {
- CountingAppender caRoot = new CountingAppender();
- Logger root = Logger.getRootLogger();
- root.getLogger().addAppender(caRoot);
-
- LoggerRepository h = LogManager.getLoggerRepository();
- //h.disableDebug();
- h.setThreshold((Level) Level.INFO);
- assertEquals(caRoot.counter, 0);
-
- root.debug(MSG);
- assertEquals(caRoot.counter, 0);
- root.info(MSG);
- assertEquals(caRoot.counter, 1);
- root.log(Level.WARN, MSG);
- assertEquals(caRoot.counter, 2);
- root.warn(MSG);
- assertEquals(caRoot.counter, 3);
-
- //h.disableInfo();
- h.setThreshold((Level) Level.WARN);
- root.debug(MSG);
- assertEquals(caRoot.counter, 3);
- root.info(MSG);
- assertEquals(caRoot.counter, 3);
- root.log(Level.WARN, MSG);
- assertEquals(caRoot.counter, 4);
- root.error(MSG);
- assertEquals(caRoot.counter, 5);
- root.log(Level.ERROR, MSG);
- assertEquals(caRoot.counter, 6);
-
- //h.disableAll();
- h.setThreshold(Level.OFF);
- root.debug(MSG);
- assertEquals(caRoot.counter, 6);
- root.info(MSG);
- assertEquals(caRoot.counter, 6);
- root.log(Level.WARN, MSG);
- assertEquals(caRoot.counter, 6);
- root.error(MSG);
- assertEquals(caRoot.counter, 6);
- root.log(Level.FATAL, MSG);
- assertEquals(caRoot.counter, 6);
- root.log(Level.FATAL, MSG);
- assertEquals(caRoot.counter, 6);
-
- //h.disable(Level.FATAL);
- h.setThreshold(Level.OFF);
- root.debug(MSG);
- assertEquals(caRoot.counter, 6);
- root.info(MSG);
- assertEquals(caRoot.counter, 6);
- root.log(Level.WARN, MSG);
- assertEquals(caRoot.counter, 6);
- root.error(MSG);
- assertEquals(caRoot.counter, 6);
- root.log(Level.ERROR, MSG);
- assertEquals(caRoot.counter, 6);
- root.log(Level.FATAL, MSG);
- assertEquals(caRoot.counter, 6);
- } */
-
- @Test
- public void testRB1() {
- final Logger root = Logger.getRootLogger();
- root.setResourceBundle(rbUS);
- ResourceBundle t = root.getResourceBundle();
- assertSame(t, rbUS);
-
- final Logger x = Logger.getLogger("x");
- final Logger x_y = Logger.getLogger("x.y");
- final Logger x_y_z = Logger.getLogger("x.y.z");
-
- t = x.getResourceBundle();
- assertSame(t, rbUS);
- t = x_y.getResourceBundle();
- assertSame(t, rbUS);
- t = x_y_z.getResourceBundle();
- assertSame(t, rbUS);
- }
-
- @Test
- public void testRB2() {
- final Logger root = Logger.getRootLogger();
- root.setResourceBundle(rbUS);
- ResourceBundle t = root.getResourceBundle();
- assertSame(t, rbUS);
-
- final Logger x = Logger.getLogger("x");
- final Logger x_y = Logger.getLogger("x.y");
- final Logger x_y_z = Logger.getLogger("x.y.z");
-
- x_y.setResourceBundle(rbFR);
- t = x.getResourceBundle();
- assertSame(t, rbUS);
- t = x_y.getResourceBundle();
- assertSame(t, rbFR);
- t = x_y_z.getResourceBundle();
- assertSame(t, rbFR);
- }
-
- @Test
- public void testRB3() {
- final Logger root = Logger.getRootLogger();
- root.setResourceBundle(rbUS);
- ResourceBundle t = root.getResourceBundle();
- assertSame(t, rbUS);
-
- final Logger x = Logger.getLogger("x");
- final Logger x_y = Logger.getLogger("x.y");
- final Logger x_y_z = Logger.getLogger("x.y.z");
-
- x_y.setResourceBundle(rbFR);
- x_y_z.setResourceBundle(rbCH);
- t = x.getResourceBundle();
- assertSame(t, rbUS);
- t = x_y.getResourceBundle();
- assertSame(t, rbFR);
- t = x_y_z.getResourceBundle();
- assertSame(t, rbCH);
- }
-
- @Test
- public void testExists() {
- final Logger a = Logger.getLogger("a");
- final Logger a_b = Logger.getLogger("a.b");
- final Logger a_b_c = Logger.getLogger("a.b.c");
-
- Logger t;
- t = LogManager.exists("xx");
- assertNull(t);
- t = LogManager.exists("a");
- assertSame(a, t);
- t = LogManager.exists("a.b");
- assertSame(a_b, t);
- t = LogManager.exists("a.b.c");
- assertSame(a_b_c, t);
- }
- /* Don't support hierarchy
- public void testHierarchy1() {
- Hierarchy h = new Hierarchy(new RootLogger((Level) Level.ERROR));
- Logger a0 = h.getLogger("a");
- assertEquals("a", a0.getName());
- assertNull(a0.getLevel());
- assertSame(Level.ERROR, a0.getEffectiveLevel());
-
- Logger a1 = h.getLogger("a");
- assertSame(a0, a1);
- } */
-
- /**
- * Tests logger.trace(Object).
- */
- @Test
- public void testTrace() {
- final ListAppender appender = new ListAppender("List");
- appender.start();
- final Logger root = Logger.getRootLogger();
- ((org.apache.logging.log4j.core.Logger) root.getLogger()).addAppender(appender);
- root.setLevel(Level.INFO);
-
- final Logger tracer = Logger.getLogger("com.example.Tracer");
- tracer.setLevel(Level.TRACE);
-
- tracer.trace("Message 1");
- root.trace("Discarded Message");
- root.trace("Discarded Message");
-
- final List msgs = appender.getEvents();
- assertEquals(1, msgs.size());
- final LogEvent event = msgs.get(0);
- assertEquals(org.apache.logging.log4j.Level.TRACE, event.getLevel());
- assertEquals("Message 1", event.getMessage().getFormat());
- appender.stop();
- ((org.apache.logging.log4j.core.Logger) root.getLogger()).removeAppender(appender);
- }
-
- /**
- * Tests logger.trace(Object, Exception).
- */
- @Test
- public void testTraceWithException() {
- final ListAppender appender = new ListAppender("List");
- appender.start();
- final Logger root = Logger.getRootLogger();
- try {
- ((org.apache.logging.log4j.core.Logger) root.getLogger()).addAppender(appender);
- root.setLevel(Level.INFO);
-
- final Logger tracer = Logger.getLogger("com.example.Tracer");
- tracer.setLevel(Level.TRACE);
- final NullPointerException ex = new NullPointerException();
-
- tracer.trace("Message 1", ex);
- root.trace("Discarded Message", ex);
- root.trace("Discarded Message", ex);
-
- final List msgs = appender.getEvents();
- assertEquals(1, msgs.size());
- final LogEvent event = msgs.get(0);
- assertEquals(org.apache.logging.log4j.Level.TRACE, event.getLevel());
- assertEquals("Message 1", event.getMessage().getFormattedMessage());
- appender.stop();
- } finally {
- ((org.apache.logging.log4j.core.Logger) root.getLogger()).removeAppender(appender);
- }
- }
-
- /**
- * Tests isTraceEnabled.
- */
- @Test
- public void testIsTraceEnabled() {
- final ListAppender appender = new ListAppender("List");
- appender.start();
- final Logger root = Logger.getRootLogger();
- try {
- ((org.apache.logging.log4j.core.Logger) root.getLogger()).addAppender(appender);
- root.setLevel(Level.INFO);
-
- final Logger tracer = Logger.getLogger("com.example.Tracer");
- tracer.setLevel(Level.TRACE);
-
- assertTrue(tracer.isTraceEnabled());
- assertFalse(root.isTraceEnabled());
- appender.stop();
- } finally {
- ((org.apache.logging.log4j.core.Logger) root.getLogger()).removeAppender(appender);
- }
- }
-
- @Test
- @SuppressWarnings("deprecation")
- public void testLog() {
- final PatternLayout layout =
- PatternLayout.newBuilder().setPattern("%d %C %L %m").build();
- final ListAppender appender = new ListAppender("List", null, layout, false, false);
- appender.start();
- final Logger root = Logger.getRootLogger();
- try {
- ((org.apache.logging.log4j.core.Logger) root.getLogger()).addAppender(appender);
- root.setLevel(Level.INFO);
- final MyLogger log = new MyLogger(root);
- log.logInfo("This is a test", null);
- root.log(Priority.INFO, "Test msg2", null);
- root.log(Priority.INFO, "Test msg3");
- final List msgs = appender.getMessages();
- assertEquals(3, msgs.size(), "Incorrect number of messages");
- final String msg = msgs.get(0);
- assertTrue(msg.contains(LoggerTest.class.getName()), "Message contains incorrect class name: " + msg);
- appender.stop();
- } finally {
- ((org.apache.logging.log4j.core.Logger) root.getLogger()).removeAppender(appender);
- }
- }
-
- private static class MyLogger {
-
- private final Logger logger;
-
- public MyLogger(final Logger logger) {
- this.logger = logger;
- }
-
- @SuppressWarnings("deprecation")
- public void logInfo(final String msg, final Throwable t) {
- logger.log(MyLogger.class.getName(), Priority.INFO, msg, t);
- }
- }
-
- private static class CountingAppender extends AbstractAppender {
-
- int counter;
-
- CountingAppender() {
- super("Counter", null, null, true, Property.EMPTY_ARRAY);
- counter = 0;
- }
-
- @Override
- public void append(final LogEvent event) {
- counter++;
- }
-
- public boolean requiresLayout() {
- return true;
- }
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/LoggingTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/LoggingTest.java
deleted file mode 100644
index a64a0aee6d8..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/LoggingTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import org.apache.logging.log4j.core.test.junit.LoggerContextSource;
-import org.junit.jupiter.api.Test;
-
-/**
- *
- */
-public class LoggingTest {
-
- private static final String CONFIG = "log4j2-config.xml";
-
- @Test
- @LoggerContextSource(CONFIG)
- public void testParent() {
- final Logger logger = Logger.getLogger("org.apache.test.logging.Test");
- final Category parent = logger.getParent();
- assertNotNull(parent, "No parent Logger");
- assertEquals("org.apache.test.logging", parent.getName(), "Incorrect parent logger");
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/MDCTestCase.java b/log4j-1.2-api/src/test/java/org/apache/log4j/MDCTestCase.java
deleted file mode 100644
index 1a52d92881f..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/MDCTestCase.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-public class MDCTestCase {
-
- @Before
- public void setUp() {
- MDC.clear();
- }
-
- @After
- public void tearDown() {
- MDC.clear();
- }
-
- @Test
- public void testPut() {
- MDC.put("key", "some value");
- Assert.assertEquals("some value", MDC.get("key"));
- Assert.assertEquals(1, MDC.getContext().size());
- }
-
- @Test
- public void testRemoveLastKey() {
- MDC.put("key", "some value");
- MDC.remove("key");
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/NDCTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/NDCTest.java
deleted file mode 100644
index 8a95b67d2f9..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/NDCTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-import java.util.Stack;
-import org.apache.logging.log4j.util.Strings;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class NDCTest {
-
- @Test
- public void testPopEmpty() {
- NDC.clear();
- Assert.assertEquals(Strings.EMPTY, NDC.pop());
- }
-
- @Test
- public void testPeekEmpty() {
- NDC.clear();
- Assert.assertEquals(Strings.EMPTY, NDC.peek());
- }
-
- @SuppressWarnings({"rawtypes"})
- @Test
- public void testCompileCloneToInherit() {
- NDC.inherit(NDC.cloneStack());
- final Stack stackRaw = NDC.cloneStack();
- NDC.inherit(stackRaw);
- final Stack> stackAny = NDC.cloneStack();
- NDC.inherit(stackAny);
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/PriorityTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/PriorityTest.java
deleted file mode 100644
index 5fa14c87dd5..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/PriorityTest.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Locale;
-import org.junit.Test;
-
-/**
- * Tests of Priority.
- *
- */
-public class PriorityTest {
-
- /**
- * Tests Priority.OFF_INT.
- */
- @Test
- public void testOffInt() {
- assertEquals(Integer.MAX_VALUE, Priority.OFF_INT);
- }
-
- /**
- * Tests Priority.FATAL_INT.
- */
- @Test
- public void testFatalInt() {
- assertEquals(50000, Priority.FATAL_INT);
- }
-
- /**
- * Tests Priority.ERROR_INT.
- */
- @Test
- public void testErrorInt() {
- assertEquals(40000, Priority.ERROR_INT);
- }
-
- /**
- * Tests Priority.WARN_INT.
- */
- @Test
- public void testWarnInt() {
- assertEquals(30000, Priority.WARN_INT);
- }
-
- /**
- * Tests Priority.INFO_INT.
- */
- @Test
- public void testInfoInt() {
- assertEquals(20000, Priority.INFO_INT);
- }
-
- /**
- * Tests Priority.DEBUG_INT.
- */
- @Test
- public void testDebugInt() {
- assertEquals(10000, Priority.DEBUG_INT);
- }
-
- /**
- * Tests Priority.ALL_INT.
- */
- @Test
- public void testAllInt() {
- assertEquals(Integer.MIN_VALUE, Priority.ALL_INT);
- }
-
- /**
- * Tests Priority.FATAL.
- */
- @Test
- @SuppressWarnings("deprecation")
- public void testFatal() {
- assertTrue(Priority.FATAL instanceof Level);
- }
-
- /**
- * Tests Priority.ERROR.
- */
- @Test
- @SuppressWarnings("deprecation")
- public void testERROR() {
- assertTrue(Priority.ERROR instanceof Level);
- }
-
- /**
- * Tests Priority.WARN.
- */
- @Test
- @SuppressWarnings("deprecation")
- public void testWARN() {
- assertTrue(Priority.WARN instanceof Level);
- }
-
- /**
- * Tests Priority.INFO.
- */
- @Test
- @SuppressWarnings("deprecation")
- public void testINFO() {
- assertTrue(Priority.INFO instanceof Level);
- }
-
- /**
- * Tests Priority.DEBUG.
- */
- @Test
- @SuppressWarnings("deprecation")
- public void testDEBUG() {
- assertTrue(Priority.DEBUG instanceof Level);
- }
-
- /**
- * Tests Priority.equals(null).
- */
- @Test
- @SuppressWarnings("deprecation")
- public void testEqualsNull() {
- assertFalse(Priority.DEBUG.equals(null));
- }
-
- /**
- * Tests Priority.equals(Level.DEBUG).
- */
- @Test
- @SuppressWarnings("deprecation")
- public void testEqualsLevel() {
- //
- // this behavior violates the equals contract.
- //
- assertTrue(Priority.DEBUG.equals(Level.DEBUG));
- }
-
- /**
- * Tests getAllPossiblePriorities().
- */
- @Test
- @SuppressWarnings("deprecation")
- public void testGetAllPossiblePriorities() {
- final Priority[] priorities = Priority.getAllPossiblePriorities();
- assertEquals(5, priorities.length);
- }
-
- /**
- * Tests toPriority(String).
- */
- @Test
- @SuppressWarnings("deprecation")
- public void testToPriorityString() {
- assertTrue(Priority.toPriority("DEBUG") == Level.DEBUG);
- }
-
- /**
- * Tests toPriority(int).
- */
- @Test
- @SuppressWarnings("deprecation")
- public void testToPriorityInt() {
- assertTrue(Priority.toPriority(Priority.DEBUG_INT) == Level.DEBUG);
- }
-
- /**
- * Tests toPriority(String, Priority).
- */
- @Test
- @SuppressWarnings("deprecation")
- public void testToPriorityStringPriority() {
- assertTrue(Priority.toPriority("foo", Priority.DEBUG) == Priority.DEBUG);
- }
-
- /**
- * Tests toPriority(int, Priority).
- */
- @Test
- @SuppressWarnings("deprecation")
- public void testToPriorityIntPriority() {
- assertTrue(Priority.toPriority(17, Priority.DEBUG) == Priority.DEBUG);
- }
-
- /**
- * Test that dotless lower I + "nfo" is recognized as INFO.
- */
- @Test
- @SuppressWarnings("deprecation")
- public void testDotlessLowerI() {
- final Priority level = Priority.toPriority("\u0131nfo");
- assertEquals("INFO", level.toString());
- }
-
- /**
- * Test that dotted lower I + "nfo" is recognized as INFO
- * even in Turkish locale.
- */
- @Test
- @SuppressWarnings("deprecation")
- public void testDottedLowerI() {
- final Locale defaultLocale = Locale.getDefault();
- final Locale turkey = new Locale("tr", "TR");
- Locale.setDefault(turkey);
- final Priority level = Priority.toPriority("info");
- Locale.setDefault(defaultLocale);
- assertEquals("INFO", level.toString());
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/PropertyConfiguratorTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/PropertyConfiguratorTest.java
deleted file mode 100644
index 832419c09ed..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/PropertyConfiguratorTest.java
+++ /dev/null
@@ -1,417 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Properties;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-import org.apache.log4j.spi.Filter;
-import org.apache.log4j.spi.LoggerRepository;
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.log4j.spi.OptionHandler;
-import org.apache.log4j.spi.RootLogger;
-import org.apache.log4j.spi.ThrowableRenderer;
-import org.apache.log4j.spi.ThrowableRendererSupport;
-import org.junit.jupiter.api.Test;
-
-/**
- * Tests {@link PropertyConfigurator}.
- */
-public class PropertyConfiguratorTest {
-
- /**
- * Mock definition of FilterBasedTriggeringPolicy from extras companion.
- */
- public static final class FilterBasedTriggeringPolicy extends TriggeringPolicy {
- private Filter filter;
-
- public FilterBasedTriggeringPolicy() {}
-
- public Filter getFilter() {
- return filter;
- }
-
- public void setFilter(final Filter val) {
- filter = val;
- }
- }
-
- /**
- * Mock definition of FixedWindowRollingPolicy from extras companion.
- */
- public static final class FixedWindowRollingPolicy extends RollingPolicy {
- private String activeFileName;
- private String fileNamePattern;
- private int minIndex;
-
- public FixedWindowRollingPolicy() {
- minIndex = -1;
- }
-
- public String getActiveFileName() {
- return activeFileName;
- }
-
- public String getFileNamePattern() {
- return fileNamePattern;
- }
-
- public int getMinIndex() {
- return minIndex;
- }
-
- public void setActiveFileName(final String val) {
- activeFileName = val;
- }
-
- public void setFileNamePattern(final String val) {
- fileNamePattern = val;
- }
-
- public void setMinIndex(final int val) {
- minIndex = val;
- }
- }
-
- /**
- * Mock ThrowableRenderer for testThrowableRenderer. See bug 45721.
- */
- public static class MockThrowableRenderer implements ThrowableRenderer, OptionHandler {
- private boolean activated = false;
- private boolean showVersion = true;
-
- public MockThrowableRenderer() {}
-
- @Override
- public void activateOptions() {
- activated = true;
- }
-
- @Override
- public String[] doRender(final Throwable t) {
- return new String[0];
- }
-
- public boolean getShowVersion() {
- return showVersion;
- }
-
- public boolean isActivated() {
- return activated;
- }
-
- public void setShowVersion(final boolean v) {
- showVersion = v;
- }
- }
-
- /**
- * Mock definition of org.apache.log4j.rolling.RollingFileAppender from extras companion.
- */
- public static final class RollingFileAppender extends AppenderSkeleton {
- private RollingPolicy rollingPolicy;
- private TriggeringPolicy triggeringPolicy;
- private boolean append;
-
- public RollingFileAppender() {}
-
- @Override
- public void append(final LoggingEvent event) {}
-
- @Override
- public void close() {}
-
- public boolean getAppend() {
- return append;
- }
-
- public RollingPolicy getRollingPolicy() {
- return rollingPolicy;
- }
-
- public TriggeringPolicy getTriggeringPolicy() {
- return triggeringPolicy;
- }
-
- @Override
- public boolean requiresLayout() {
- return true;
- }
-
- public void setAppend(final boolean val) {
- append = val;
- }
-
- public void setRollingPolicy(final RollingPolicy policy) {
- rollingPolicy = policy;
- }
-
- public void setTriggeringPolicy(final TriggeringPolicy policy) {
- triggeringPolicy = policy;
- }
- }
-
- /**
- * Mock definition of org.apache.log4j.rolling.RollingPolicy from extras companion.
- */
- public static class RollingPolicy implements OptionHandler {
- private boolean activated = false;
-
- public RollingPolicy() {}
-
- @Override
- public void activateOptions() {
- activated = true;
- }
-
- public final boolean isActivated() {
- return activated;
- }
- }
-
- /**
- * Mock definition of TriggeringPolicy from extras companion.
- */
- public static class TriggeringPolicy implements OptionHandler {
- private boolean activated = false;
-
- public TriggeringPolicy() {}
-
- @Override
- public void activateOptions() {
- activated = true;
- }
-
- public final boolean isActivated() {
- return activated;
- }
- }
-
- private static final String FILTER1_PROPERTIES = "target/test-classes/log4j1-1.2.17/input/filter1.properties";
-
- private static final String CAT_A_NAME = "categoryA";
-
- private static final String CAT_B_NAME = "categoryB";
-
- private static final String CAT_C_NAME = "categoryC";
-
- /**
- * Test for bug 40944. Did not catch IllegalArgumentException on Properties.load and close input stream.
- *
- * @throws IOException if IOException creating properties file.
- */
- @Test
- public void testBadUnicodeEscape() throws IOException {
- final String fileName = "target/badescape.properties";
- try (final FileWriter writer = new FileWriter(fileName)) {
- writer.write("log4j.rootLogger=\\uXX41");
- }
- PropertyConfigurator.configure(fileName);
- final File file = new File(fileName);
- assertTrue(file.delete());
- assertFalse(file.exists());
- }
-
- /**
- * Tests configuring Log4J from an InputStream.
- *
- * @since 1.2.17
- */
- @Test
- public void testInputStream() throws IOException {
- final Path file = Paths.get(FILTER1_PROPERTIES);
- assertTrue(Files.exists(file));
- try (final InputStream inputStream = Files.newInputStream(file)) {
- PropertyConfigurator.configure(inputStream);
- }
- this.validateNested();
- LogManager.resetConfiguration();
- }
-
- /**
- * Test for bug 47465. configure(URL) did not close opened JarURLConnection.
- *
- * @throws IOException if IOException creating properties jar.
- */
- @Test
- public void testJarURL() throws IOException {
- final File dir = new File("output");
- dir.mkdirs();
- final File file = new File("output/properties.jar");
- try (final ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(file))) {
- zos.putNextEntry(new ZipEntry(LogManager.DEFAULT_CONFIGURATION_FILE));
- zos.write("log4j.rootLogger=debug".getBytes());
- zos.closeEntry();
- }
- final URL url = new URL("jar:" + file.toURI().toURL() + "!/" + LogManager.DEFAULT_CONFIGURATION_FILE);
- PropertyConfigurator.configure(url);
- assertTrue(file.delete());
- assertFalse(file.exists());
- }
-
- @Test
- public void testLocalVsGlobal() {
- LoggerRepository repos1, repos2;
- final Logger catA = Logger.getLogger(CAT_A_NAME);
- final Logger catB = Logger.getLogger(CAT_B_NAME);
- final Logger catC = Logger.getLogger(CAT_C_NAME);
-
- final Properties globalSettings = new Properties();
- globalSettings.put("log4j.logger." + CAT_A_NAME, Level.WARN.toString());
- globalSettings.put("log4j.logger." + CAT_B_NAME, Level.WARN.toString());
- globalSettings.put("log4j.logger." + CAT_C_NAME, Level.DEBUG.toString());
- PropertyConfigurator.configure(globalSettings);
- assertEquals(Level.WARN, catA.getLevel());
- assertEquals(Level.WARN, catB.getLevel());
- assertEquals(Level.DEBUG, catC.getLevel());
-
- assertEquals(
- Level.WARN, catA.getLoggerRepository().getLogger(CAT_A_NAME).getLevel());
- assertEquals(
- Level.WARN, catB.getLoggerRepository().getLogger(CAT_B_NAME).getLevel());
- assertEquals(
- Level.DEBUG, catC.getLoggerRepository().getLogger(CAT_C_NAME).getLevel());
-
- final Properties repos1Settings = new Properties();
- repos1Settings.put("log4j.logger." + CAT_A_NAME, Level.DEBUG.toString());
- repos1Settings.put("log4j.logger." + CAT_B_NAME, Level.INFO.toString());
- repos1 = new Hierarchy(new RootLogger(Level.OFF));
- new PropertyConfigurator().doConfigure(repos1Settings, repos1);
- assertEquals(Level.DEBUG, repos1.getLogger(CAT_A_NAME).getLevel());
- assertEquals(Level.INFO, repos1.getLogger(CAT_B_NAME).getLevel());
-
- final Properties repos2Settings = new Properties();
- repos2Settings.put("log4j.logger." + CAT_A_NAME, Level.INFO.toString());
- repos2Settings.put("log4j.logger." + CAT_B_NAME, Level.DEBUG.toString());
- repos2 = new Hierarchy(new RootLogger(Level.OFF));
- new PropertyConfigurator().doConfigure(repos2Settings, repos2);
- assertEquals(Level.INFO, repos2.getLogger(CAT_A_NAME).getLevel());
- assertEquals(Level.DEBUG, repos2.getLogger(CAT_B_NAME).getLevel());
- }
-
- /**
- * Tests processing of nested objects, see bug 36384.
- */
- public void testNested() {
- try {
- PropertyConfigurator.configure(FILTER1_PROPERTIES);
- this.validateNested();
- } finally {
- LogManager.resetConfiguration();
- }
- }
-
- /**
- * Test processing of log4j.reset property, see bug 17531.
- */
- @Test
- public void testReset() {
- final VectorAppender appender = new VectorAppender();
- appender.setName("A1");
- Logger.getRootLogger().addAppender(appender);
- final Properties properties = new Properties();
- properties.put("log4j.reset", "true");
- PropertyConfigurator.configure(properties);
- assertNull(Logger.getRootLogger().getAppender("A1"));
- LogManager.resetConfiguration();
- }
-
- /**
- * Test of log4j.throwableRenderer support. See bug 45721.
- */
- public void testThrowableRenderer() {
- final Properties properties = new Properties();
- properties.put("log4j.throwableRenderer", "org.apache.log4j.PropertyConfiguratorTest$MockThrowableRenderer");
- properties.put("log4j.throwableRenderer.showVersion", "false");
- PropertyConfigurator.configure(properties);
- final ThrowableRendererSupport repo = (ThrowableRendererSupport) LogManager.getLoggerRepository();
- final MockThrowableRenderer renderer = (MockThrowableRenderer) repo.getThrowableRenderer();
- LogManager.resetConfiguration();
- // assertNotNull(renderer);
- // assertEquals(true, renderer.isActivated());
- // assertEquals(false, renderer.getShowVersion());
- }
-
- /**
- * Test for bug 40944. configure(URL) never closed opened stream.
- *
- * @throws IOException if IOException creating properties file.
- */
- @Test
- public void testURL() throws IOException {
- final File file = new File("target/unclosed.properties");
- try (final FileWriter writer = new FileWriter(file)) {
- writer.write("log4j.rootLogger=debug");
- }
- final URL url = file.toURI().toURL();
- PropertyConfigurator.configure(url);
- assertTrue(file.delete());
- assertFalse(file.exists());
- }
-
- /**
- * Test for bug 40944. configure(URL) did not catch IllegalArgumentException and did not close stream.
- *
- * @throws IOException if IOException creating properties file.
- */
- @Test
- public void testURLBadEscape() throws IOException {
- final File file = new File("target/urlbadescape.properties");
- try (final FileWriter writer = new FileWriter(file)) {
- writer.write("log4j.rootLogger=\\uXX41");
- }
- final URL url = file.toURI().toURL();
- PropertyConfigurator.configure(url);
- assertTrue(file.delete());
- assertFalse(file.exists());
- }
-
- public void validateNested() {
- final Logger logger = Logger.getLogger("org.apache.log4j.PropertyConfiguratorTest");
- final String appenderName = "ROLLING";
- // Appender OK
- final Appender appender = logger.getAppender(appenderName);
- assertNotNull(appender);
- // Down-cast?
- // final RollingFileAppender rfa = (RollingFileAppender) appender;
- // assertNotNull(appenderName, rfa);
- // final FixedWindowRollingPolicy rollingPolicy = (FixedWindowRollingPolicy) rfa.getRollingPolicy();
- // assertEquals("filterBase-test1.log", rollingPolicy.getActiveFileName());
- // assertEquals("filterBased-test1.%i", rollingPolicy.getFileNamePattern());
- // assertEquals(0, rollingPolicy.getMinIndex());
- // assertTrue(rollingPolicy.isActivated());
- // final FilterBasedTriggeringPolicy triggeringPolicy = (FilterBasedTriggeringPolicy)
- // rfa.getTriggeringPolicy();
- // final LevelRangeFilter filter = (LevelRangeFilter) triggeringPolicy.getFilter();
- // assertTrue(Level.INFO.equals(filter.getLevelMin()));
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/VelocityTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/VelocityTest.java
deleted file mode 100644
index 3da9fd66fd5..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/VelocityTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j;
-
-import java.io.StringWriter;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.Configurator;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.Velocity;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * Note that this test must clean up after itself or it may cause other tests to fail.
- */
-public class VelocityTest {
-
- private static LoggerContext context;
-
- @BeforeClass
- public static void setupClass() {
- context = LoggerContext.getContext(false);
- }
-
- @AfterClass
- public static void tearDownClass() {
- Configurator.shutdown(context);
- StatusLogger.getLogger().reset();
- }
-
- @Test
- public void testVelocity() {
- Velocity.init();
- final VelocityContext vContext = new VelocityContext();
- vContext.put("name", new String("Velocity"));
-
- final Template template = Velocity.getTemplate("target/test-classes/hello.vm");
-
- final StringWriter sw = new StringWriter();
-
- template.merge(vContext, sw);
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/bridge/LogEventWrapperTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/bridge/LogEventWrapperTest.java
deleted file mode 100644
index 47d29c73664..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/bridge/LogEventWrapperTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.bridge;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.logging.log4j.core.LogEvent;
-import org.junit.Test;
-
-public class LogEventWrapperTest {
-
- @Test
- public void testThread() {
- final Thread currentThread = Thread.currentThread();
- final String threadName = currentThread.getName();
- final LoggingEvent log4j1Event = new LoggingEvent() {
-
- @Override
- public String getThreadName() {
- return threadName;
- }
- };
- final LogEvent log4j2Event = new LogEventWrapper(log4j1Event);
- assertEquals(currentThread.getId(), log4j2Event.getThreadId());
- assertEquals(currentThread.getPriority(), log4j2Event.getThreadPriority());
- }
-
- @Test
- public void testToImmutable() {
- final LogEventWrapper wrapper = new LogEventWrapper(new LoggingEvent());
- assertSame(wrapper, wrapper.toImmutable());
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/builders/BuilderManagerTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/builders/BuilderManagerTest.java
deleted file mode 100644
index fa51d3456b6..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/builders/BuilderManagerTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import java.util.Properties;
-import org.apache.log4j.Appender;
-import org.apache.log4j.FileAppender;
-import org.apache.log4j.config.PropertiesConfiguration;
-import org.apache.log4j.spi.Filter;
-import org.apache.log4j.varia.StringMatchFilter;
-import org.apache.logging.log4j.plugins.di.ConfigurableInstanceFactory;
-import org.apache.logging.log4j.plugins.di.DI;
-import org.junit.jupiter.api.Test;
-
-public class BuilderManagerTest {
-
- /**
- * This test ensures that instantiation failures due to missing parameters
- * always return an empty wrapper instead of null, hence disabling the
- * "instantiate by classname" fallback mechanism for supported components.
- */
- @Test
- public void testReturnInvalidValueOnError() {
- final PropertiesConfiguration config = new PropertiesConfiguration(null, null);
- final ConfigurableInstanceFactory instanceFactory = DI.createInitializedFactory();
- final BuilderManager manager = instanceFactory.getInstance(BuilderManager.class);
- final Properties props = new Properties();
- props.setProperty("FILE", FileAppender.class.getName());
- props.setProperty("FILE.filter.1", StringMatchFilter.class.getName());
- // Parse an invalid StringMatchFilter
- final Filter filter = manager.parse(
- StringMatchFilter.class.getName(), "FILE.filter", props, config, BuilderManager.INVALID_FILTER);
- assertEquals(BuilderManager.INVALID_FILTER, filter);
- // Parse an invalid FileAppender
- final Appender appender = manager.parseAppender(
- "FILE", FileAppender.class.getName(), "FILE", "FILE.layout", "FILE.filter.", props, config);
- assertEquals(BuilderManager.INVALID_APPENDER, appender);
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/builders/Log4j2ListAppenderBuilder.java b/log4j-1.2-api/src/test/java/org/apache/log4j/builders/Log4j2ListAppenderBuilder.java
deleted file mode 100644
index a3396b23d3f..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/builders/Log4j2ListAppenderBuilder.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders;
-
-import static org.apache.log4j.builders.BuilderManager.NAMESPACE;
-import static org.apache.log4j.xml.XmlConfiguration.FILTER_TAG;
-import static org.apache.log4j.xml.XmlConfiguration.LAYOUT_TAG;
-import static org.apache.log4j.xml.XmlConfiguration.forEachElement;
-
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicReference;
-import org.apache.log4j.Appender;
-import org.apache.log4j.Layout;
-import org.apache.log4j.bridge.AppenderWrapper;
-import org.apache.log4j.bridge.LayoutAdapter;
-import org.apache.log4j.builders.appender.AppenderBuilder;
-import org.apache.log4j.config.PropertiesConfiguration;
-import org.apache.log4j.spi.Filter;
-import org.apache.log4j.xml.XmlConfiguration;
-import org.apache.logging.log4j.core.test.appender.ListAppender;
-import org.apache.logging.log4j.plugins.Namespace;
-import org.apache.logging.log4j.plugins.Plugin;
-import org.w3c.dom.Element;
-
-/**
- * Builder for the native Log4j 2.x list appender to be used in the tests.
- */
-@Namespace(NAMESPACE)
-@Plugin("org.apache.logging.log4j.test.appender.ListAppender")
-public class Log4j2ListAppenderBuilder extends AbstractBuilder implements AppenderBuilder {
-
- public Log4j2ListAppenderBuilder() {}
-
- public Log4j2ListAppenderBuilder(final String prefix, final Properties props) {
- super(prefix, props);
- }
-
- @Override
- public Appender parseAppender(final Element element, final XmlConfiguration configuration) {
- final String name = getNameAttribute(element);
- final AtomicReference layout = new AtomicReference<>();
- final AtomicReference filter = new AtomicReference<>();
- forEachElement(element.getChildNodes(), currentElement -> {
- switch (currentElement.getTagName()) {
- case LAYOUT_TAG:
- layout.set(configuration.parseLayout(currentElement));
- break;
- case FILTER_TAG:
- configuration.addFilter(filter, currentElement);
- break;
- default:
- }
- });
- return createAppender(name, layout.get(), filter.get());
- }
-
- @Override
- public Appender parseAppender(
- final String name,
- final String appenderPrefix,
- final String layoutPrefix,
- final String filterPrefix,
- final Properties props,
- final PropertiesConfiguration configuration) {
- final Layout layout = configuration.parseLayout(layoutPrefix, name, props);
- final Filter filter = configuration.parseAppenderFilters(props, filterPrefix, name);
- return createAppender(name, layout, filter);
- }
-
- private Appender createAppender(final String name, final Layout layout, final Filter filter) {
- final org.apache.logging.log4j.core.Layout log4j2Layout = LayoutAdapter.adapt(layout);
- return AppenderWrapper.adapt(ListAppender.newBuilder()
- .setName(name)
- .setLayout(log4j2Layout)
- .setFilter(AbstractBuilder.buildFilters(null, filter))
- .build());
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/builders/filter/LevelRangeFilterBuilderTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/builders/filter/LevelRangeFilterBuilderTest.java
deleted file mode 100644
index c26f3137be9..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/builders/filter/LevelRangeFilterBuilderTest.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders.filter;
-
-import static org.junit.jupiter.api.Assertions.assertSame;
-
-import java.io.StringReader;
-import java.util.Properties;
-import java.util.stream.Stream;
-import javax.xml.parsers.DocumentBuilderFactory;
-import org.apache.log4j.bridge.FilterWrapper;
-import org.apache.log4j.spi.Filter;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.Filter.Result;
-import org.apache.logging.log4j.core.filter.LevelRangeFilter;
-import org.junit.jupiter.api.extension.ExtensionContext;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.Arguments;
-import org.junit.jupiter.params.provider.ArgumentsProvider;
-import org.junit.jupiter.params.provider.ArgumentsSource;
-import org.w3c.dom.Element;
-import org.xml.sax.InputSource;
-
-public class LevelRangeFilterBuilderTest {
-
- @ParameterizedTest
- @ArgumentsSource(TestLevelRangeFilterBuilderProvider.class)
- public void testAcceptOnMatchTrue(TestLevelRangeFilterBuilder builder) throws Exception {
- LevelRangeFilter levelRangeFilter = builder.build(Level.INFO, Level.ERROR, true);
-
- assertResult(Result.DENY, levelRangeFilter, Level.ALL);
- assertResult(Result.DENY, levelRangeFilter, Level.DEBUG);
- assertResult(Result.ACCEPT, levelRangeFilter, Level.INFO);
- assertResult(Result.ACCEPT, levelRangeFilter, Level.WARN);
- assertResult(Result.ACCEPT, levelRangeFilter, Level.ERROR);
- assertResult(Result.DENY, levelRangeFilter, Level.FATAL);
- assertResult(Result.DENY, levelRangeFilter, Level.OFF);
- }
-
- @ParameterizedTest
- @ArgumentsSource(TestLevelRangeFilterBuilderProvider.class)
- public void testAcceptOnMatchFalse(TestLevelRangeFilterBuilder builder) throws Exception {
- LevelRangeFilter levelRangeFilter = builder.build(Level.INFO, Level.ERROR, false);
-
- assertResult(Result.DENY, levelRangeFilter, Level.ALL);
- assertResult(Result.DENY, levelRangeFilter, Level.DEBUG);
- assertResult(Result.NEUTRAL, levelRangeFilter, Level.INFO);
- assertResult(Result.NEUTRAL, levelRangeFilter, Level.WARN);
- assertResult(Result.NEUTRAL, levelRangeFilter, Level.ERROR);
- assertResult(Result.DENY, levelRangeFilter, Level.FATAL);
- assertResult(Result.DENY, levelRangeFilter, Level.OFF);
- }
-
- @ParameterizedTest
- @ArgumentsSource(TestLevelRangeFilterBuilderProvider.class)
- public void testAcceptOnMatchNull(TestLevelRangeFilterBuilder builder) throws Exception {
- LevelRangeFilter levelRangeFilter = builder.build(Level.INFO, Level.ERROR, null);
-
- assertResult(Result.DENY, levelRangeFilter, Level.ALL);
- assertResult(Result.DENY, levelRangeFilter, Level.DEBUG);
- assertResult(Result.NEUTRAL, levelRangeFilter, Level.INFO);
- assertResult(Result.NEUTRAL, levelRangeFilter, Level.WARN);
- assertResult(Result.NEUTRAL, levelRangeFilter, Level.ERROR);
- assertResult(Result.DENY, levelRangeFilter, Level.FATAL);
- assertResult(Result.DENY, levelRangeFilter, Level.OFF);
- }
-
- @ParameterizedTest
- @ArgumentsSource(TestLevelRangeFilterBuilderProvider.class)
- public void testMinLevelNull(TestLevelRangeFilterBuilder builder) throws Exception {
- LevelRangeFilter levelRangeFilter = builder.build(null, Level.ERROR, true);
-
- assertResult(Result.ACCEPT, levelRangeFilter, Level.ALL);
- assertResult(Result.ACCEPT, levelRangeFilter, Level.DEBUG);
- assertResult(Result.ACCEPT, levelRangeFilter, Level.INFO);
- assertResult(Result.ACCEPT, levelRangeFilter, Level.WARN);
- assertResult(Result.ACCEPT, levelRangeFilter, Level.ERROR);
- assertResult(Result.DENY, levelRangeFilter, Level.FATAL);
- assertResult(Result.DENY, levelRangeFilter, Level.OFF);
- }
-
- @ParameterizedTest
- @ArgumentsSource(TestLevelRangeFilterBuilderProvider.class)
- public void testMaxLevelNull(TestLevelRangeFilterBuilder builder) throws Exception {
- LevelRangeFilter levelRangeFilter = builder.build(Level.INFO, null, true);
-
- assertResult(Result.DENY, levelRangeFilter, Level.ALL);
- assertResult(Result.DENY, levelRangeFilter, Level.DEBUG);
- assertResult(Result.ACCEPT, levelRangeFilter, Level.INFO);
- assertResult(Result.ACCEPT, levelRangeFilter, Level.WARN);
- assertResult(Result.ACCEPT, levelRangeFilter, Level.ERROR);
- assertResult(Result.ACCEPT, levelRangeFilter, Level.FATAL);
- assertResult(Result.ACCEPT, levelRangeFilter, Level.OFF);
- }
-
- @ParameterizedTest
- @ArgumentsSource(TestLevelRangeFilterBuilderProvider.class)
- public void testMinMaxLevelSame(TestLevelRangeFilterBuilder builder) throws Exception {
- LevelRangeFilter levelRangeFilter = builder.build(Level.INFO, Level.INFO, true);
-
- assertResult(Result.DENY, levelRangeFilter, Level.ALL);
- assertResult(Result.DENY, levelRangeFilter, Level.DEBUG);
- assertResult(Result.ACCEPT, levelRangeFilter, Level.INFO);
- assertResult(Result.DENY, levelRangeFilter, Level.WARN);
- assertResult(Result.DENY, levelRangeFilter, Level.ERROR);
- assertResult(Result.DENY, levelRangeFilter, Level.FATAL);
- assertResult(Result.DENY, levelRangeFilter, Level.OFF);
- }
-
- @ParameterizedTest
- @ArgumentsSource(TestLevelRangeFilterBuilderProvider.class)
- public void testMinMaxLevelNull(TestLevelRangeFilterBuilder builder) throws Exception {
- LevelRangeFilter levelRangeFilter = builder.build(null, null, true);
-
- assertResult(Result.ACCEPT, levelRangeFilter, Level.ALL);
- assertResult(Result.ACCEPT, levelRangeFilter, Level.DEBUG);
- assertResult(Result.ACCEPT, levelRangeFilter, Level.INFO);
- assertResult(Result.ACCEPT, levelRangeFilter, Level.WARN);
- assertResult(Result.ACCEPT, levelRangeFilter, Level.ERROR);
- assertResult(Result.ACCEPT, levelRangeFilter, Level.FATAL);
- assertResult(Result.ACCEPT, levelRangeFilter, Level.OFF);
- }
-
- private static void assertResult(Result expected, LevelRangeFilter filter, Level level) {
- assertSame(expected, filter.filter(null, level, null, (Object) null, null));
- }
-
- private static class TestLevelRangeFilterBuilderProvider implements ArgumentsProvider {
-
- @Override
- public Stream extends Arguments> provideArguments(ExtensionContext extensionContext) {
- return Stream.of(
- Arguments.of(new TestLevelRangeFilterFromXmlBuilder()),
- Arguments.of(new TestLevelRangeFilterFromPropertyBuilder()));
- }
- }
-
- private interface TestLevelRangeFilterBuilder {
-
- LevelRangeFilter build(Level levelMin, Level levelMax, Boolean acceptOnMatch) throws Exception;
- }
-
- private static class TestLevelRangeFilterFromXmlBuilder implements TestLevelRangeFilterBuilder {
-
- @Override
- public LevelRangeFilter build(Level levelMin, Level levelMax, Boolean acceptOnMatch) throws Exception {
- LevelRangeFilterBuilder builder = new LevelRangeFilterBuilder();
- Filter filter = builder.parse(generateTestXml(levelMin, levelMax, acceptOnMatch), null);
- org.apache.logging.log4j.core.Filter wrappedFilter = ((FilterWrapper) filter).getFilter();
- return (LevelRangeFilter) wrappedFilter;
- }
-
- private static Element generateTestXml(Level levelMin, Level levelMax, Boolean acceptOnMatch) throws Exception {
-
- StringBuilder sb = new StringBuilder();
- sb.append("\n");
- if (levelMin != null) {
- sb.append(String.format(" \n", levelMin));
- }
- if (levelMax != null) {
- sb.append(String.format(" \n", levelMax));
- }
- if (acceptOnMatch != null) {
- sb.append(String.format(" \n", acceptOnMatch));
- }
- sb.append(" ");
-
- return DocumentBuilderFactory.newInstance()
- .newDocumentBuilder()
- .parse(new InputSource(new StringReader(sb.toString())))
- .getDocumentElement();
- }
- }
-
- private static class TestLevelRangeFilterFromPropertyBuilder implements TestLevelRangeFilterBuilder {
-
- @Override
- public LevelRangeFilter build(Level levelMin, Level levelMax, Boolean acceptOnMatch) {
- Properties properties = new Properties();
- if (levelMin != null) {
- properties.setProperty("foobar.levelMin", levelMin.name());
- }
- if (levelMax != null) {
- properties.setProperty("foobar.levelMax", levelMax.name());
- }
- if (acceptOnMatch != null) {
- properties.setProperty("foobar.acceptOnMatch", acceptOnMatch.toString());
- }
- LevelRangeFilterBuilder builder = new LevelRangeFilterBuilder("foobar", properties);
- Filter filter = builder.parse(null);
- org.apache.logging.log4j.core.Filter wrappedFilter = ((FilterWrapper) filter).getFilter();
- return (LevelRangeFilter) wrappedFilter;
- }
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/builders/layout/PatternLayoutBuilderTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/builders/layout/PatternLayoutBuilderTest.java
deleted file mode 100644
index 430b02a98cc..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/builders/layout/PatternLayoutBuilderTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.builders.layout;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import java.util.Arrays;
-import java.util.stream.Stream;
-import org.apache.log4j.bridge.LayoutAdapter;
-import org.apache.logging.log4j.core.layout.PatternLayout;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.Arguments;
-import org.junit.jupiter.params.provider.MethodSource;
-
-public class PatternLayoutBuilderTest {
-
- static Stream patterns() {
- return Arrays.asList(
- Arguments.of("%p", "%v1Level"),
- Arguments.of("%100p", "%100v1Level"),
- Arguments.of("%-100p", "%-100v1Level"),
- Arguments.of("%x", "%ndc"),
- Arguments.of("%X", "%properties"),
- Arguments.of("%.20x", "%.20ndc"),
- Arguments.of("%pid", "%pid"),
- Arguments.of("%xEx", "%xEx"),
- Arguments.of("%XX", "%XX"),
- Arguments.of("%p id", "%v1Level id"),
- Arguments.of("%x Ex", "%ndc Ex"),
- Arguments.of("%X X", "%properties X"))
- .stream();
- }
-
- @ParameterizedTest
- @MethodSource("patterns")
- public void testLevelPatternReplacement(final String v1Pattern, final String v2Pattern) {
- final PatternLayoutBuilder builder = new PatternLayoutBuilder();
- final PatternLayout layout = (PatternLayout) LayoutAdapter.adapt(builder.createLayout(v1Pattern, null));
- assertEquals(v2Pattern, layout.getConversionPattern());
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/AbstractLog4j1ConfigurationTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/AbstractLog4j1ConfigurationTest.java
deleted file mode 100644
index 946bd7b042a..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/AbstractLog4j1ConfigurationTest.java
+++ /dev/null
@@ -1,657 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.config;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.FileDescriptor;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.net.URISyntaxException;
-import java.nio.file.FileSystemException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.concurrent.TimeUnit;
-import org.apache.log4j.ListAppender;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.Logger;
-import org.apache.log4j.bridge.AppenderAdapter.Adapter;
-import org.apache.log4j.bridge.FilterAdapter;
-import org.apache.log4j.bridge.FilterWrapper;
-import org.apache.logging.log4j.Level;
-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.LoggerContext;
-import org.apache.logging.log4j.core.appender.ConsoleAppender;
-import org.apache.logging.log4j.core.appender.ConsoleAppender.Target;
-import org.apache.logging.log4j.core.appender.FileAppender;
-import org.apache.logging.log4j.core.appender.NullAppender;
-import org.apache.logging.log4j.core.appender.OutputStreamManager;
-import org.apache.logging.log4j.core.appender.RollingFileAppender;
-import org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy;
-import org.apache.logging.log4j.core.appender.rolling.DefaultRolloverStrategy;
-import org.apache.logging.log4j.core.appender.rolling.RolloverStrategy;
-import org.apache.logging.log4j.core.appender.rolling.SizeBasedTriggeringPolicy;
-import org.apache.logging.log4j.core.appender.rolling.TimeBasedTriggeringPolicy;
-import org.apache.logging.log4j.core.appender.rolling.TriggeringPolicy;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.Configurator;
-import org.apache.logging.log4j.core.config.LoggerConfig;
-import org.apache.logging.log4j.core.filter.CompositeFilter;
-import org.apache.logging.log4j.core.filter.Filterable;
-import org.apache.logging.log4j.core.filter.ThresholdFilter;
-import org.apache.logging.log4j.core.layout.HtmlLayout;
-import org.apache.logging.log4j.core.layout.PatternLayout;
-import org.apache.logging.log4j.core.util.CloseShieldOutputStream;
-
-public abstract class AbstractLog4j1ConfigurationTest {
-
- abstract Configuration getConfiguration(String configResourcePrefix) throws URISyntaxException, IOException;
-
- protected InputStream getResourceAsStream(final String configResource) throws IOException {
- final InputStream is = getClass().getClassLoader().getResourceAsStream(configResource);
- assertNotNull(is);
- return is;
- }
-
- protected LoggerContext configure(final String configResourcePrefix) throws URISyntaxException, IOException {
- Configurator.reconfigure(getConfiguration(configResourcePrefix));
- return (LoggerContext) org.apache.logging.log4j.LogManager.getContext(false);
- }
-
- public void testConsoleCapitalization() throws Exception {
- final Configuration config = getConfiguration("config-1.2/log4j-capitalization");
- final Appender capitalized = config.getAppender("ConsoleCapitalized");
- assertNotNull(capitalized);
- assertEquals(capitalized.getClass(), ConsoleAppender.class);
- final Appender javaStyle = config.getAppender("ConsoleJavaStyle");
- assertNotNull(javaStyle);
- assertEquals(javaStyle.getClass(), ConsoleAppender.class);
- testConsoleAppender((ConsoleAppender) capitalized, (ConsoleAppender) javaStyle);
- }
-
- private void testConsoleAppender(final ConsoleAppender expected, final ConsoleAppender actual) {
- assertEquals("immediateFlush", expected.getImmediateFlush(), actual.getImmediateFlush());
- assertEquals("target", expected.getTarget(), actual.getTarget());
- assertEquals(
- "layoutClass",
- expected.getLayout().getClass(),
- actual.getLayout().getClass());
- if (expected.getLayout() instanceof PatternLayout) {
- patternLayoutEquals((PatternLayout) expected.getLayout(), (PatternLayout) actual.getLayout());
- }
- }
-
- private void patternLayoutEquals(final PatternLayout expected, final PatternLayout actual) {
- assertEquals(expected.getCharset(), actual.getCharset());
- assertEquals(expected.getConversionPattern(), actual.getConversionPattern());
- }
-
- private Layout testConsole(final String configResource) throws Exception {
- final Configuration configuration = getConfiguration(configResource);
- final String name = "Console";
- final ConsoleAppender appender = configuration.getAppender(name);
- assertNotNull(
- "Missing appender '" + name + "' in configuration " + configResource + " → " + configuration, appender);
- assertEquals("follow", true, getFollowProperty(appender));
- assertEquals(Target.SYSTEM_ERR, appender.getTarget());
- //
- final LoggerConfig loggerConfig = configuration.getLoggerConfig("com.example.foo");
- assertNotNull(loggerConfig);
- assertEquals(Level.DEBUG, loggerConfig.getLevel());
- // immediateFlush is always true in Log4j 2.x
- configuration.start();
- configuration.stop();
- return appender.getLayout();
- }
-
- public void testConsoleTtccLayout() throws Exception {
- final PatternLayout layout = (PatternLayout) testConsole("config-1.2/log4j-console-TTCCLayout");
- assertEquals("%d{ISO8601}{CET} %p - %m%n", layout.getConversionPattern());
- }
-
- public void testRollingFileAppender() throws Exception {
- testRollingFileAppender("config-1.2/log4j-RollingFileAppender", "RFA", "target/hadoop.log.%i");
- }
-
- public void testDailyRollingFileAppender() throws Exception {
- testDailyRollingFileAppender(
- "config-1.2/log4j-DailyRollingFileAppender", "DRFA", "target/hadoop.log%d{.dd-MM-yyyy}");
- }
-
- public void testRollingFileAppenderWithProperties() throws Exception {
- testRollingFileAppender("config-1.2/log4j-RollingFileAppender-with-props", "RFA", "target/hadoop.log.%i");
- }
-
- public void testSystemProperties1() throws Exception {
- final String tempFileName = System.getProperty("java.io.tmpdir") + "/hadoop.log";
- final Path tempFilePath = new File(tempFileName).toPath();
- Files.deleteIfExists(tempFilePath);
- final Configuration configuration = getConfiguration("config-1.2/log4j-system-properties-1");
- try {
- final RollingFileAppender appender = configuration.getAppender("RFA");
- assertEquals("append", false, getAppendProperty(appender));
- assertEquals("bufferSize", 1000, appender.getManager().getBufferSize());
- assertEquals("immediateFlush", false, appender.getImmediateFlush());
- final DefaultRolloverStrategy rolloverStrategy =
- (DefaultRolloverStrategy) appender.getManager().getRolloverStrategy();
- assertEquals(16, rolloverStrategy.getMaxIndex());
- final CompositeTriggeringPolicy ctp = (CompositeTriggeringPolicy) appender.getTriggeringPolicy();
- final TriggeringPolicy[] triggeringPolicies = ctp.getTriggeringPolicies();
- assertEquals(1, triggeringPolicies.length);
- final TriggeringPolicy tp = triggeringPolicies[0];
- assertTrue(tp.getClass().getName(), tp instanceof SizeBasedTriggeringPolicy);
- final SizeBasedTriggeringPolicy sbtp = (SizeBasedTriggeringPolicy) tp;
- assertEquals(20 * 1024 * 1024, sbtp.getMaxFileSize());
- appender.stop(10, TimeUnit.SECONDS);
- // System.out.println("expected: " + tempFileName + " Actual: " +
- // appender.getFileName());
- assertEquals(tempFileName, appender.getFileName());
- } finally {
- configuration.start();
- configuration.stop();
- try {
- Files.deleteIfExists(tempFilePath);
- } catch (final FileSystemException e) {
- e.printStackTrace();
- }
- }
- }
-
- public void testSystemProperties2() throws Exception {
- final Configuration configuration = getConfiguration("config-1.2/log4j-system-properties-2");
- final RollingFileAppender appender = configuration.getAppender("RFA");
- final String tmpDir = System.getProperty("java.io.tmpdir");
- assertEquals(tmpDir + "/hadoop.log", appender.getFileName());
- appender.stop(10, TimeUnit.SECONDS);
- // Try to clean up
- try {
- Path path = new File(appender.getFileName()).toPath();
- Files.deleteIfExists(path);
- path = new File("${java.io.tmpdir}").toPath();
- Files.deleteIfExists(path);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- private void testRollingFileAppender(final String configResource, final String name, final String filePattern)
- throws Exception {
- final Configuration configuration = getConfiguration(configResource);
- final Appender appender = configuration.getAppender(name);
- assertNotNull(appender);
- assertEquals(name, appender.getName());
- assertTrue(appender.getClass().getName(), appender instanceof RollingFileAppender);
- final RollingFileAppender rfa = (RollingFileAppender) appender;
-
- assertTrue(
- "defaultRolloverStrategy", rfa.getManager().getRolloverStrategy() instanceof DefaultRolloverStrategy);
- assertFalse(
- "rolloverStrategy", ((DefaultRolloverStrategy) rfa.getManager().getRolloverStrategy()).isUseMax());
- assertEquals("append", false, getAppendProperty(rfa));
- assertEquals("bufferSize", 1000, rfa.getManager().getBufferSize());
- assertEquals("immediateFlush", false, rfa.getImmediateFlush());
- assertEquals("target/hadoop.log", rfa.getFileName());
- assertEquals(filePattern, rfa.getFilePattern());
- final TriggeringPolicy triggeringPolicy = rfa.getTriggeringPolicy();
- assertNotNull(triggeringPolicy);
- assertTrue(triggeringPolicy.getClass().getName(), triggeringPolicy instanceof CompositeTriggeringPolicy);
- final CompositeTriggeringPolicy ctp = (CompositeTriggeringPolicy) triggeringPolicy;
- final TriggeringPolicy[] triggeringPolicies = ctp.getTriggeringPolicies();
- assertEquals(1, triggeringPolicies.length);
- final TriggeringPolicy tp = triggeringPolicies[0];
- assertTrue(tp.getClass().getName(), tp instanceof SizeBasedTriggeringPolicy);
- final SizeBasedTriggeringPolicy sbtp = (SizeBasedTriggeringPolicy) tp;
- assertEquals(256 * 1024 * 1024, sbtp.getMaxFileSize());
- final RolloverStrategy rolloverStrategy = rfa.getManager().getRolloverStrategy();
- assertTrue(rolloverStrategy.getClass().getName(), rolloverStrategy instanceof DefaultRolloverStrategy);
- final DefaultRolloverStrategy drs = (DefaultRolloverStrategy) rolloverStrategy;
- assertEquals(20, drs.getMaxIndex());
- configuration.start();
- configuration.stop();
- }
-
- private void testDailyRollingFileAppender(final String configResource, final String name, final String filePattern)
- throws Exception {
- final Configuration configuration = getConfiguration(configResource);
- try {
- final Appender appender = configuration.getAppender(name);
- assertNotNull(appender);
- assertEquals(name, appender.getName());
- assertTrue(appender.getClass().getName(), appender instanceof RollingFileAppender);
- final RollingFileAppender rfa = (RollingFileAppender) appender;
- assertEquals("append", false, getAppendProperty(rfa));
- assertEquals("bufferSize", 1000, rfa.getManager().getBufferSize());
- assertEquals("immediateFlush", false, rfa.getImmediateFlush());
- assertEquals("target/hadoop.log", rfa.getFileName());
- assertEquals(filePattern, rfa.getFilePattern());
- final TriggeringPolicy triggeringPolicy = rfa.getTriggeringPolicy();
- assertNotNull(triggeringPolicy);
- assertTrue(triggeringPolicy.getClass().getName(), triggeringPolicy instanceof CompositeTriggeringPolicy);
- final CompositeTriggeringPolicy ctp = (CompositeTriggeringPolicy) triggeringPolicy;
- final TriggeringPolicy[] triggeringPolicies = ctp.getTriggeringPolicies();
- assertEquals(1, triggeringPolicies.length);
- final TriggeringPolicy tp = triggeringPolicies[0];
- assertTrue(tp.getClass().getName(), tp instanceof TimeBasedTriggeringPolicy);
- final TimeBasedTriggeringPolicy tbtp = (TimeBasedTriggeringPolicy) tp;
- assertEquals(1, tbtp.getInterval());
- final RolloverStrategy rolloverStrategy = rfa.getManager().getRolloverStrategy();
- assertTrue(rolloverStrategy.getClass().getName(), rolloverStrategy instanceof DefaultRolloverStrategy);
- final DefaultRolloverStrategy drs = (DefaultRolloverStrategy) rolloverStrategy;
- assertEquals(Integer.MAX_VALUE, drs.getMaxIndex());
- } finally {
- configuration.start();
- configuration.stop();
- }
- }
-
- private Layout testFile(final String configResource) throws Exception {
- final Configuration configuration = getConfiguration(configResource);
- final FileAppender appender = configuration.getAppender("File");
- assertNotNull(appender);
- assertEquals("target/mylog.txt", appender.getFileName());
- //
- final LoggerConfig loggerConfig = configuration.getLoggerConfig("com.example.foo");
- assertNotNull(loggerConfig);
- assertEquals(Level.DEBUG, loggerConfig.getLevel());
- assertEquals("append", false, getAppendProperty(appender));
- assertEquals("bufferSize", 1000, appender.getManager().getBufferSize());
- assertEquals("immediateFlush", false, appender.getImmediateFlush());
- configuration.start();
- configuration.stop();
- return appender.getLayout();
- }
-
- public void testConsoleEnhancedPatternLayout() throws Exception {
- final PatternLayout layout = (PatternLayout) testConsole("config-1.2/log4j-console-EnhancedPatternLayout");
- // %p, %X and %x converted to their Log4j 1.x bridge equivalent
- assertEquals("%d{ISO8601} [%t][%c] %-5v1Level %properties %ndc: %m%n", layout.getConversionPattern());
- }
-
- public void testConsoleHtmlLayout() throws Exception {
- final HtmlLayout layout = (HtmlLayout) testConsole("config-1.2/log4j-console-HtmlLayout");
- assertEquals("Headline", layout.getTitle());
- assertTrue(layout.isLocationInfo());
- }
-
- public void testConsolePatternLayout() throws Exception {
- final PatternLayout layout = (PatternLayout) testConsole("config-1.2/log4j-console-PatternLayout");
- // %p converted to its Log4j 1.x bridge equivalent
- assertEquals("%d{ISO8601} [%t][%c] %-5v1Level: %m%n", layout.getConversionPattern());
- }
-
- public void testConsoleSimpleLayout() throws Exception {
- final PatternLayout layout = (PatternLayout) testConsole("config-1.2/log4j-console-SimpleLayout");
- assertEquals("%v1Level - %m%n", layout.getConversionPattern());
- }
-
- public void testFileSimpleLayout() throws Exception {
- final PatternLayout layout = (PatternLayout) testFile("config-1.2/log4j-file-SimpleLayout");
- assertEquals("%v1Level - %m%n", layout.getConversionPattern());
- }
-
- public void testNullAppender() throws Exception {
- final Configuration configuration = getConfiguration("config-1.2/log4j-NullAppender");
- final Appender appender = configuration.getAppender("NullAppender");
- assertNotNull(appender);
- assertEquals("NullAppender", appender.getName());
- assertTrue(appender.getClass().getName(), appender instanceof NullAppender);
- }
-
- private boolean getFollowProperty(final ConsoleAppender consoleAppender)
- throws Exception, NoSuchFieldException, IllegalAccessException {
- final CloseShieldOutputStream wrapperStream =
- (CloseShieldOutputStream) getOutputStream(consoleAppender.getManager());
- final Field delegateField = CloseShieldOutputStream.class.getDeclaredField("delegate");
- delegateField.setAccessible(true);
- final boolean follow = !System.out.equals(delegateField.get(wrapperStream));
- return follow;
- }
-
- private boolean getAppendProperty(final RollingFileAppender appender) throws Exception {
- return getAppendProperty((FileOutputStream) getOutputStream(appender.getManager()));
- }
-
- private boolean getAppendProperty(final FileAppender appender) throws Exception {
- return getAppendProperty((FileOutputStream) getOutputStream(appender.getManager()));
- }
-
- private boolean getAppendProperty(final FileOutputStream os) throws Exception {
- // Java 11
- final Field appendField = FileDescriptor.class.getDeclaredField("append");
- appendField.setAccessible(true);
- return (Boolean) appendField.get(os.getFD());
- }
-
- private OutputStream getOutputStream(final OutputStreamManager manager) throws Exception {
- final Method getOutputStream = OutputStreamManager.class.getDeclaredMethod("getOutputStream");
- getOutputStream.setAccessible(true);
- return (OutputStream) getOutputStream.invoke(manager);
- }
-
- private Layout testLayout(final Configuration config, final String appenderName) {
- final ConsoleAppender appender = config.getAppender(appenderName);
- assertNotNull(
- "Missing appender '" + appenderName + "' in configuration " + config.getConfigurationSource(),
- appender);
- return appender.getLayout();
- }
-
- /**
- * Test if the default values from Log4j 1.x are respected.
- */
- public void testDefaultValues() throws Exception {
- final Configuration config = getConfiguration("config-1.2/log4j-defaultValues");
- // HtmlLayout
- final HtmlLayout htmlLayout = (HtmlLayout) testLayout(config, "HTMLLayout");
- assertNotNull(htmlLayout);
- assertEquals("title", "Log4J Log Messages", htmlLayout.getTitle());
- assertEquals("locationInfo", false, htmlLayout.isLocationInfo());
- // PatternLayout
- final PatternLayout patternLayout = (PatternLayout) testLayout(config, "PatternLayout");
- assertNotNull(patternLayout);
- assertEquals("conversionPattern", "%m%n", patternLayout.getConversionPattern());
- // TTCCLayout
- final PatternLayout ttccLayout = (PatternLayout) testLayout(config, "TTCCLayout");
- assertNotNull(ttccLayout);
- assertEquals(
- "equivalent conversion pattern",
- "%r [%t] %p %c %notEmpty{%ndc }- %m%n",
- ttccLayout.getConversionPattern());
- // TODO: XMLLayout
- // final XmlLayout xmlLayout = (XmlLayout) testLayout(config, "XMLLayout");
- // assertNotNull(xmlLayout);
- // ConsoleAppender
- final ConsoleAppender consoleAppender = config.getAppender("ConsoleAppender");
- assertNotNull(consoleAppender);
- assertEquals("target", Target.SYSTEM_OUT, consoleAppender.getTarget());
- final boolean follow = getFollowProperty(consoleAppender);
- assertEquals("follow", false, follow);
- // DailyRollingFileAppender
- final RollingFileAppender dailyRollingFileAppender = config.getAppender("DailyRollingFileAppender");
- assertNotNull(dailyRollingFileAppender);
- assertEquals(
- "equivalent file pattern",
- "target/dailyRollingFileAppender%d{.yyyy-MM-dd}",
- dailyRollingFileAppender.getFilePattern());
- assertEquals("append", true, getAppendProperty(dailyRollingFileAppender));
- assertEquals("bufferSize", 8192, dailyRollingFileAppender.getManager().getBufferSize());
- assertEquals("immediateFlush", true, dailyRollingFileAppender.getImmediateFlush());
- // FileAppender
- final FileAppender fileAppender = config.getAppender("FileAppender");
- assertNotNull(fileAppender);
- assertEquals("append", true, getAppendProperty(fileAppender));
- assertEquals("bufferSize", 8192, fileAppender.getManager().getBufferSize());
- assertEquals("immediateFlush", true, fileAppender.getImmediateFlush());
- // RollingFileAppender
- final RollingFileAppender rollingFileAppender = config.getAppender("RollingFileAppender");
- assertNotNull(rollingFileAppender);
- assertEquals("equivalent file pattern", "target/rollingFileAppender.%i", rollingFileAppender.getFilePattern());
- final CompositeTriggeringPolicy compositePolicy =
- rollingFileAppender.getManager().getTriggeringPolicy();
- assertEquals(1, compositePolicy.getTriggeringPolicies().length);
- final SizeBasedTriggeringPolicy sizePolicy =
- (SizeBasedTriggeringPolicy) compositePolicy.getTriggeringPolicies()[0];
- assertEquals("maxFileSize", 10 * 1024 * 1024L, sizePolicy.getMaxFileSize());
- final DefaultRolloverStrategy strategy =
- (DefaultRolloverStrategy) rollingFileAppender.getManager().getRolloverStrategy();
- assertEquals("maxBackupIndex", 1, strategy.getMaxIndex());
- assertEquals("append", true, getAppendProperty(rollingFileAppender));
- assertEquals("bufferSize", 8192, rollingFileAppender.getManager().getBufferSize());
- assertEquals("immediateFlush", true, rollingFileAppender.getImmediateFlush());
- config.start();
- config.stop();
- }
-
- /**
- * Checks a hierarchy of filters.
- *
- * @param filter
- * @return the number of filters
- */
- private int checkFilters(final org.apache.logging.log4j.core.Filter filter) {
- int count = 0;
- if (filter instanceof CompositeFilter) {
- for (final org.apache.logging.log4j.core.Filter part : ((CompositeFilter) filter).getFiltersArray()) {
- count += checkFilters(part);
- }
- } else if (filter instanceof FilterAdapter) {
- // Don't create adapters from wrappers
- assertFalse(
- "found FilterAdapter of a FilterWrapper",
- ((FilterAdapter) filter).getFilter() instanceof FilterWrapper);
- count += checkFilters(((FilterAdapter) filter).getFilter());
- } else {
- count++;
- }
- return count;
- }
-
- /**
- * Checks a hierarchy of filters.
- *
- * @param filter
- * @return the number of filters
- */
- private int checkFilters(final org.apache.log4j.spi.Filter filter) {
- int count = 0;
- if (filter instanceof FilterWrapper) {
- // Don't create wrappers from adapters
- assertFalse(
- "found FilterWrapper of a FilterAdapter",
- ((FilterWrapper) filter).getFilter() instanceof FilterAdapter);
- count += checkFilters(((FilterWrapper) filter).getFilter());
- } else {
- count++;
- }
- // We prefer a:
- // CompositeFilter of native Log4j 2.x filters
- // over a:
- // FilterAdapter of a chain of FilterWrappers.
- assertNull("found chain of Log4j 1.x filters", filter.getNext());
- return count;
- }
-
- public void testMultipleFilters(final Path folder) throws Exception {
- System.setProperty("test.tmpDir", folder.toString());
- try (final LoggerContext loggerContext = configure("log4j-multipleFilters")) {
- final Configuration configuration = loggerContext.getConfiguration();
- assertNotNull(configuration);
- // Check only number of filters.
- final Filterable console = configuration.getAppender("CONSOLE");
- assertNotNull(console);
- assertEquals(4, checkFilters(console.getFilter()));
- final Filterable file = configuration.getAppender("FILE");
- assertNotNull(file);
- assertEquals(4, checkFilters(file.getFilter()));
- final Filterable rfa = configuration.getAppender("RFA");
- assertNotNull(rfa);
- assertEquals(4, checkFilters(rfa.getFilter()));
- final Filterable drfa = configuration.getAppender("DRFA");
- assertNotNull(drfa);
- assertEquals(4, checkFilters(drfa.getFilter()));
- // List appenders
- final Appender appender = configuration.getAppender("LIST");
- assertNotNull(appender);
- assertEquals(3, checkFilters(((Filterable) appender).getFilter()));
- final ListAppender legacyAppender = (ListAppender) ((Adapter) appender).getAppender();
- final org.apache.logging.log4j.core.test.appender.ListAppender nativeAppender =
- configuration.getAppender("LIST2");
- assertEquals(3, checkFilters(((Filterable) nativeAppender).getFilter()));
- final Logger logger = LogManager.getLogger(PropertiesConfigurationTest.class);
- int expected = 0;
- // message blocked by Threshold
- logger.trace("NEUTRAL message");
- assertEquals(expected, legacyAppender.getEvents().size());
- assertEquals(expected, nativeAppender.getEvents().size());
- // message blocked by DenyAll filter
- logger.warn("NEUTRAL message");
- assertEquals(expected, legacyAppender.getEvents().size());
- assertEquals(expected, nativeAppender.getEvents().size());
- // message accepted by level filter
- logger.info("NEUTRAL message");
- expected++;
- assertEquals(expected, legacyAppender.getEvents().size());
- assertEquals(expected, nativeAppender.getEvents().size());
- // message accepted by "StartsWith" filter
- logger.warn("ACCEPT message");
- expected++;
- assertEquals(expected, legacyAppender.getEvents().size());
- assertEquals(expected, nativeAppender.getEvents().size());
- // message blocked by "StartsWith" filter
- logger.info("DENY message");
- assertEquals(expected, legacyAppender.getEvents().size());
- assertEquals(expected, nativeAppender.getEvents().size());
- } finally {
- System.clearProperty("test.tmpDir");
- }
- }
-
- public void testGlobalThreshold() throws Exception {
- try (final LoggerContext ctx = configure("config-1.2/log4j-global-threshold")) {
- final Configuration config = ctx.getConfiguration();
- final Filter filter = config.getFilter();
- assertTrue(filter instanceof ThresholdFilter);
- final ThresholdFilter thresholdFilter = (ThresholdFilter) filter;
- assertEquals(Level.INFO, thresholdFilter.getLevel());
- assertEquals(Filter.Result.NEUTRAL, thresholdFilter.getOnMatch());
- assertEquals(Filter.Result.DENY, thresholdFilter.getOnMismatch());
-
- final Logger logger = LogManager.getLogger(PropertiesConfigurationTest.class);
- // List appender
- final Appender appender = config.getAppender("LIST");
- assertNotNull(appender);
- final ListAppender legacyAppender = (ListAppender) ((Adapter) appender).getAppender();
- // Stopped by root logger level
- logger.trace("TRACE");
- assertEquals(0, legacyAppender.getEvents().size());
- // Stopped by global threshold
- logger.debug("DEBUG");
- assertEquals(0, legacyAppender.getEvents().size());
- // Accepted
- logger.info("INFO");
- assertEquals(1, legacyAppender.getEvents().size());
- }
- }
-
- protected void testEnhancedRollingFileAppender(final Configuration configuration) {
- Appender appender;
- TriggeringPolicy policy;
- RolloverStrategy strategy;
- DefaultRolloverStrategy defaultRolloverStrategy;
- // Time policy with default attributes
- appender = configuration.getAppender("DEFAULT_TIME");
- assertTrue("is RollingFileAppender", appender instanceof RollingFileAppender);
- final RollingFileAppender defaultTime = (RollingFileAppender) appender;
- assertEquals("append", true, defaultTime.getManager().isAppend());
- assertEquals("bufferSize", 8192, defaultTime.getManager().getBufferSize());
- assertEquals("immediateFlush", true, defaultTime.getImmediateFlush());
- assertEquals("fileName", "target/EnhancedRollingFileAppender/defaultTime.log", defaultTime.getFileName());
- assertEquals(
- "filePattern",
- "target/EnhancedRollingFileAppender/defaultTime.%d{yyyy-MM-dd}.log",
- defaultTime.getFilePattern());
- policy = defaultTime.getTriggeringPolicy();
- assertTrue("is TimeBasedTriggeringPolicy", policy instanceof TimeBasedTriggeringPolicy);
- // Size policy with default attributes
- appender = configuration.getAppender("DEFAULT_SIZE");
- assertTrue("is RollingFileAppender", appender instanceof RollingFileAppender);
- final RollingFileAppender defaultSize = (RollingFileAppender) appender;
- assertEquals("append", true, defaultSize.getManager().isAppend());
- assertEquals("bufferSize", 8192, defaultSize.getManager().getBufferSize());
- assertEquals("immediateFlush", true, defaultSize.getImmediateFlush());
- assertEquals("fileName", "target/EnhancedRollingFileAppender/defaultSize.log", defaultSize.getFileName());
- assertEquals(
- "filePattern", "target/EnhancedRollingFileAppender/defaultSize.%i.log", defaultSize.getFilePattern());
- policy = defaultSize.getTriggeringPolicy();
- assertTrue("is SizeBasedTriggeringPolicy", policy instanceof SizeBasedTriggeringPolicy);
- assertEquals(10 * 1024 * 1024L, ((SizeBasedTriggeringPolicy) policy).getMaxFileSize());
- strategy = defaultSize.getManager().getRolloverStrategy();
- assertTrue("is DefaultRolloverStrategy", strategy instanceof DefaultRolloverStrategy);
- defaultRolloverStrategy = (DefaultRolloverStrategy) strategy;
- assertEquals(1, defaultRolloverStrategy.getMinIndex());
- assertEquals(7, defaultRolloverStrategy.getMaxIndex());
- // Time policy with custom attributes
- appender = configuration.getAppender("TIME");
- assertTrue("is RollingFileAppender", appender instanceof RollingFileAppender);
- final RollingFileAppender time = (RollingFileAppender) appender;
- assertEquals("append", false, time.getManager().isAppend());
- assertEquals("bufferSize", 1000, time.getManager().getBufferSize());
- assertEquals("immediateFlush", false, time.getImmediateFlush());
- assertEquals("fileName", "target/EnhancedRollingFileAppender/time.log", time.getFileName());
- assertEquals(
- "filePattern", "target/EnhancedRollingFileAppender/time.%d{yyyy-MM-dd}.log", time.getFilePattern());
- policy = time.getTriggeringPolicy();
- assertTrue("is TimeBasedTriggeringPolicy", policy instanceof TimeBasedTriggeringPolicy);
- // Size policy with custom attributes
- appender = configuration.getAppender("SIZE");
- assertTrue("is RollingFileAppender", appender instanceof RollingFileAppender);
- final RollingFileAppender size = (RollingFileAppender) appender;
- assertEquals("append", false, size.getManager().isAppend());
- assertEquals("bufferSize", 1000, size.getManager().getBufferSize());
- assertEquals("immediateFlush", false, size.getImmediateFlush());
- assertEquals("fileName", "target/EnhancedRollingFileAppender/size.log", size.getFileName());
- assertEquals("filePattern", "target/EnhancedRollingFileAppender/size.%i.log", size.getFilePattern());
- policy = size.getTriggeringPolicy();
- assertTrue("is SizeBasedTriggeringPolicy", policy instanceof SizeBasedTriggeringPolicy);
- assertEquals(10_000_000L, ((SizeBasedTriggeringPolicy) policy).getMaxFileSize());
- strategy = size.getManager().getRolloverStrategy();
- assertTrue("is DefaultRolloverStrategy", strategy instanceof DefaultRolloverStrategy);
- defaultRolloverStrategy = (DefaultRolloverStrategy) strategy;
- assertEquals(11, defaultRolloverStrategy.getMinIndex());
- assertEquals(20, defaultRolloverStrategy.getMaxIndex());
- }
-
- protected void testLevelRangeFilter() throws Exception {
- try (final LoggerContext ctx = configure("config-1.2/log4j-LevelRangeFilter")) {
- final Configuration config = ctx.getConfiguration();
- final Logger logger = LogManager.getLogger(PropertiesConfigurationTest.class);
- // List appender
- final Appender appender = config.getAppender("LIST");
- assertNotNull(appender);
- final ListAppender legacyAppender = (ListAppender) ((Adapter) appender).getAppender();
- // deny
- logger.trace("TRACE");
- assertEquals(0, legacyAppender.getEvents().size());
- // deny
- logger.debug("DEBUG");
- assertEquals(0, legacyAppender.getEvents().size());
- // accept
- logger.info("INFO");
- assertEquals(1, legacyAppender.getEvents().size());
- // accept
- logger.warn("WARN");
- assertEquals(2, legacyAppender.getEvents().size());
- // accept
- logger.error("ERROR");
- assertEquals(3, legacyAppender.getEvents().size());
- // deny
- logger.fatal("FATAL");
- assertEquals(3, legacyAppender.getEvents().size());
- }
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/AsyncAppenderTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/AsyncAppenderTest.java
deleted file mode 100644
index 2dbf15664a5..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/AsyncAppenderTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.config;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
-
-import java.net.URI;
-import java.nio.file.Paths;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-import java.util.stream.Stream;
-import org.apache.log4j.ListAppender;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.Logger;
-import org.apache.log4j.bridge.AppenderAdapter;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.test.junit.UsingStatusListener;
-import org.junit.jupiter.api.Tag;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.MethodSource;
-
-/**
- * Test configuration from XML.
- */
-@Tag("sleepy")
-@UsingStatusListener
-public class AsyncAppenderTest {
-
- private static long DEFAULT_TIMEOUT_MS = 500;
-
- static Stream testAsyncAppender() {
- return Stream.of("/log4j1-async.xml", "/log4j1-async.properties")
- .map(config -> assertDoesNotThrow(() -> {
- final URI uri = AsyncAppenderTest.class.getResource(config).toURI();
- return Paths.get(uri).toString();
- }));
- }
-
- @ParameterizedTest
- @MethodSource
- public void testAsyncAppender(final String configLocation) throws Exception {
- try (final LoggerContext loggerContext = TestConfigurator.configure(configLocation)) {
- final Logger logger = LogManager.getLogger("test");
- logger.debug("This is a test of the root logger");
- final AppenderAdapter.Adapter adapter =
- loggerContext.getConfiguration().getAppender("list");
- assertThat(adapter).isNotNull();
- final ListAppender appender = (ListAppender) adapter.getAppender();
- final List messages = appender.getMessages(1, DEFAULT_TIMEOUT_MS, TimeUnit.MILLISECONDS);
- assertThat(messages).hasSize(1);
- }
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/AutoConfigTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/AutoConfigTest.java
deleted file mode 100644
index 2820722d882..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/AutoConfigTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.config;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import java.util.List;
-import java.util.Map;
-import org.apache.log4j.ListAppender;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.Logger;
-import org.apache.log4j.bridge.AppenderAdapter;
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.test.TestConstants;
-import org.junit.jupiter.api.Test;
-import org.junitpioneer.jupiter.SetSystemProperty;
-
-/**
- * Test configuration from XML.
- */
-public class AutoConfigTest {
-
- @Test
- @SetSystemProperty(key = TestConstants.VERSION1_CONFIGURATION, value = "log4j.xml")
- public void testListAppender() {
- final Logger logger = LogManager.getLogger("test");
- final LoggerContext context = LoggerContext.getContext(false);
- logger.debug("This is a test of the root logger");
- final Configuration configuration = context.getConfiguration();
- final Map appenders = configuration.getAppenders();
- ListAppender eventAppender = null;
- ListAppender messageAppender = null;
- for (Map.Entry entry : appenders.entrySet()) {
- if (entry.getKey().equals("list")) {
- messageAppender = (ListAppender) ((AppenderAdapter.Adapter) entry.getValue()).getAppender();
- } else if (entry.getKey().equals("events")) {
- eventAppender = (ListAppender) ((AppenderAdapter.Adapter) entry.getValue()).getAppender();
- }
- }
- assertNotNull(eventAppender, "No Event Appender");
- assertNotNull(messageAppender, "No Message Appender");
- final List events = eventAppender.getEvents();
- assertTrue(events != null && events.size() > 0, "No events");
- final List messages = messageAppender.getMessages();
- assertTrue(messages != null && messages.size() > 0, "No messages");
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/MapRewriteAppenderTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/MapRewriteAppenderTest.java
deleted file mode 100644
index 826413e3542..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/MapRewriteAppenderTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.config;
-
-import static org.assertj.core.api.Assertions.as;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.InstanceOfAssertFactories.MAP;
-import static org.assertj.core.api.InstanceOfAssertFactories.STRING;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.apache.log4j.ListAppender;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.Logger;
-import org.apache.log4j.bridge.AppenderAdapter;
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.test.TestConstants;
-import org.apache.logging.log4j.test.junit.UsingThreadContextMap;
-import org.junit.jupiter.api.Test;
-import org.junitpioneer.jupiter.SetSystemProperty;
-
-/**
- * Test RewriteAppender
- */
-@UsingThreadContextMap
-public class MapRewriteAppenderTest {
-
- @Test
- @SetSystemProperty(key = TestConstants.VERSION1_CONFIGURATION, value = "log4j1-mapRewrite.xml")
- public void testRewrite() {
- final Logger logger = LogManager.getLogger("test");
- final Map map = new HashMap<>();
- map.put("message", "This is a test");
- map.put("hello", "world");
- logger.debug(map);
- final LoggerContext context = LoggerContext.getContext(false);
- final Configuration configuration = context.getConfiguration();
- final Map appenders = configuration.getAppenders();
- ListAppender eventAppender = null;
- for (Map.Entry entry : appenders.entrySet()) {
- if (entry.getKey().equals("events")) {
- eventAppender = (ListAppender) ((AppenderAdapter.Adapter) entry.getValue()).getAppender();
- }
- }
- assertNotNull(eventAppender, "No Event Appender");
- final List events = eventAppender.getEvents();
- assertThat(events)
- .isNotNull()
- .isNotEmpty()
- .first()
- .extracting(LoggingEvent::getProperties, as(MAP))
- .containsKey("hello")
- .extractingByKey("hello", as(STRING))
- .isEqualTo("world");
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/NeutralFilterFixture.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/NeutralFilterFixture.java
deleted file mode 100644
index d787acd1983..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/NeutralFilterFixture.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.config;
-
-import org.apache.log4j.spi.Filter;
-import org.apache.log4j.spi.LoggingEvent;
-
-/**
- * A test fixture used by {@code src/test/resources/LOG4J2-3247.properties}.
- */
-public class NeutralFilterFixture extends Filter {
-
- @Override
- public int decide(final LoggingEvent event) {
- return NEUTRAL;
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesConfigurationFactoryTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesConfigurationFactoryTest.java
deleted file mode 100644
index 7c2f89a9745..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesConfigurationFactoryTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.config;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.Logger;
-import org.apache.logging.log4j.core.test.TestConstants;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * Test configuration from Properties.
- */
-public class PropertiesConfigurationFactoryTest {
-
- @BeforeClass
- public static void beforeClass() {
- System.setProperty(TestConstants.VERSION1_CONFIGURATION, "target/test-classes/log4j1-file-1.properties");
- }
-
- @Test
- public void testProperties() {
- final Logger logger = LogManager.getLogger("test");
- logger.debug("This is a test of the root logger");
- File file = new File("target/temp.A1");
- assertTrue("File A1 was not created", file.exists());
- assertTrue("File A1 is empty", file.length() > 0);
- file = new File("target/temp.A2");
- assertTrue("File A2 was not created", file.exists());
- assertTrue("File A2 is empty", file.length() > 0);
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesConfigurationTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesConfigurationTest.java
deleted file mode 100644
index 4ba9c2c8ae0..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesConfigurationTest.java
+++ /dev/null
@@ -1,367 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.config;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URISyntaxException;
-import java.nio.file.Path;
-import java.util.List;
-import java.util.Map;
-import org.apache.log4j.ListAppender;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.Logger;
-import org.apache.log4j.bridge.AppenderAdapter;
-import org.apache.log4j.bridge.FilterAdapter;
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.logging.log4j.Level;
-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.LoggerContext;
-import org.apache.logging.log4j.core.appender.ConsoleAppender;
-import org.apache.logging.log4j.core.appender.FileAppender;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.ConfigurationSource;
-import org.apache.logging.log4j.core.config.LoggerConfig;
-import org.apache.logging.log4j.core.filter.CompositeFilter;
-import org.apache.logging.log4j.core.filter.DenyAllFilter;
-import org.apache.logging.log4j.core.filter.Filterable;
-import org.apache.logging.log4j.core.filter.LevelRangeFilter;
-import org.apache.logging.log4j.core.layout.PatternLayout;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.io.TempDir;
-
-/**
- * Test configuration from Properties.
- */
-public class PropertiesConfigurationTest extends AbstractLog4j1ConfigurationTest {
-
- private static final String TEST_KEY = "log4j.test.tmpdir";
- private static final String SUFFIX = ".properties";
-
- @Override
- Configuration getConfiguration(final String configResourcePrefix) throws URISyntaxException, IOException {
- final String configResource = configResourcePrefix + SUFFIX;
- final InputStream inputStream = getResourceAsStream(configResource);
- final ConfigurationSource source = new ConfigurationSource(inputStream);
- final LoggerContext context = LoggerContext.getContext(false);
- final Configuration configuration = new PropertiesConfigurationFactory().getConfiguration(context, source);
- assertNotNull(configuration, "No configuration created");
- configuration.initialize();
- return configuration;
- }
-
- @Test
- public void testConfigureNullPointerException() throws Exception {
- try (final LoggerContext loggerContext =
- TestConfigurator.configure("target/test-classes/LOG4J2-3247.properties")) {
- // [LOG4J2-3247] configure() should not throw an NPE.
- final Configuration configuration = loggerContext.getConfiguration();
- assertNotNull(configuration);
- final Appender appender = configuration.getAppender("CONSOLE");
- assertNotNull(appender);
- }
- }
-
- @Test
- public void testConsoleAppenderFilter() throws Exception {
- try (final LoggerContext loggerContext =
- TestConfigurator.configure("target/test-classes/LOG4J2-3247.properties")) {
- // LOG4J2-3281 PropertiesConfiguration.buildAppender not adding filters to appender
- final Configuration configuration = loggerContext.getConfiguration();
- assertNotNull(configuration);
- final Appender appender = configuration.getAppender("CONSOLE");
- assertNotNull(appender);
- final Filterable filterable = (Filterable) appender;
- final FilterAdapter filter = (FilterAdapter) filterable.getFilter();
- assertNotNull(filter);
- assertTrue(filter.getFilter() instanceof NeutralFilterFixture);
- }
- }
-
- @Test
- public void testCustomAppenderFilter() throws Exception {
- try (final LoggerContext loggerContext =
- TestConfigurator.configure("target/test-classes/LOG4J2-3281.properties")) {
- // LOG4J2-3281 PropertiesConfiguration.buildAppender not adding filters to appender
- final Configuration configuration = loggerContext.getConfiguration();
- assertNotNull(configuration);
- final Appender appender = configuration.getAppender("CUSTOM");
- assertNotNull(appender);
- final Filterable filterable = (Filterable) appender;
- final FilterAdapter filter = (FilterAdapter) filterable.getFilter();
- assertNotNull(filter);
- assertTrue(filter.getFilter() instanceof NeutralFilterFixture);
- }
- }
-
- @Test
- public void testConsoleAppenderLevelRangeFilter() throws Exception {
- try (final LoggerContext loggerContext =
- TestConfigurator.configure("target/test-classes/LOG4J2-3326.properties")) {
- final Configuration configuration = loggerContext.getConfiguration();
- assertNotNull(configuration);
- final Appender appender = configuration.getAppender("CUSTOM");
- assertNotNull(appender);
- final Filterable filterable = (Filterable) appender;
- final CompositeFilter filter = (CompositeFilter) filterable.getFilter();
- final org.apache.logging.log4j.core.Filter[] filters = filter.getFiltersArray();
- final LevelRangeFilter filter1 = (LevelRangeFilter) filters[0];
- // XXX: LOG4J2-2315
- assertEquals(Level.OFF, filter1.getMinLevel());
- assertEquals(Level.ALL, filter1.getMaxLevel());
- final LevelRangeFilter filter2 = (LevelRangeFilter) filters[1];
- assertEquals(Level.ERROR, filter2.getMinLevel());
- assertEquals(Level.INFO, filter2.getMaxLevel());
- final LevelRangeFilter filter3 = (LevelRangeFilter) filters[2];
- assertEquals(Level.OFF, filter3.getMinLevel());
- assertEquals(Level.ALL, filter3.getMaxLevel());
-
- final ListAppender legacyAppender = (ListAppender) ((AppenderAdapter.Adapter) appender).getAppender();
- final Logger logger = LogManager.getLogger(PropertiesConfigurationTest.class);
-
- // deny
- logger.trace("TRACE");
- assertEquals(0, legacyAppender.getEvents().size());
- // deny
- logger.debug("DEBUG");
- assertEquals(0, legacyAppender.getEvents().size());
- // accept
- logger.info("INFO");
- assertEquals(1, legacyAppender.getEvents().size());
- // accept
- logger.warn("WARN");
- assertEquals(2, legacyAppender.getEvents().size());
- // accept
- logger.error("ERROR");
- assertEquals(3, legacyAppender.getEvents().size());
- // deny
- logger.fatal("FATAL");
- assertEquals(3, legacyAppender.getEvents().size());
- }
- }
-
- @Test
- public void testConfigureAppenderDoesNotExist() throws Exception {
- // Verify that we tolerate a logger which specifies an appender that does not exist.
- try (final LoggerContext loggerContext =
- TestConfigurator.configure("target/test-classes/LOG4J2-3407.properties")) {
- final Configuration configuration = loggerContext.getConfiguration();
- assertNotNull(configuration);
- }
- }
-
- @Test
- public void testListAppender() throws Exception {
- try (final LoggerContext loggerContext =
- TestConfigurator.configure("target/test-classes/log4j1-list.properties")) {
- final Logger logger = LogManager.getLogger("test");
- logger.debug("This is a test of the root logger");
- final Configuration configuration = loggerContext.getConfiguration();
- final Map appenders = configuration.getAppenders();
- ListAppender eventAppender = null;
- ListAppender messageAppender = null;
- for (final Map.Entry entry : appenders.entrySet()) {
- if (entry.getKey().equals("list")) {
- messageAppender = (ListAppender) ((AppenderAdapter.Adapter) entry.getValue()).getAppender();
- } else if (entry.getKey().equals("events")) {
- eventAppender = (ListAppender) ((AppenderAdapter.Adapter) entry.getValue()).getAppender();
- }
- }
- assertNotNull(eventAppender, "No Event Appender");
- assertNotNull(messageAppender, "No Message Appender");
- final List events = eventAppender.getEvents();
- assertTrue(events != null && events.size() > 0, "No events");
- final List messages = messageAppender.getMessages();
- assertTrue(messages != null && messages.size() > 0, "No messages");
- }
- }
-
- @Test
- public void testProperties() throws Exception {
- try (final LoggerContext loggerContext =
- TestConfigurator.configure("target/test-classes/log4j1-file-1.properties")) {
- final Logger logger = LogManager.getLogger("test");
- logger.debug("This is a test of the root logger");
- File file = new File("target/temp.A1");
- assertTrue(file.exists(), "File A1 was not created");
- assertTrue(file.length() > 0, "File A1 is empty");
- file = new File("target/temp.A2");
- assertTrue(file.exists(), "File A2 was not created");
- assertTrue(file.length() > 0, "File A2 is empty");
- }
- }
-
- @Test
- public void testSystemProperties() throws Exception {
- final String testPathLocation = "target";
- System.setProperty(TEST_KEY, testPathLocation);
- try (final LoggerContext loggerContext =
- TestConfigurator.configure("target/test-classes/config-1.2/log4j-FileAppender-with-props.properties")) {
- // [LOG4J2-3312] Bridge does not convert properties.
- final Configuration configuration = loggerContext.getConfiguration();
- assertNotNull(configuration);
- final String name = "FILE_APPENDER";
- final Appender appender = configuration.getAppender(name);
- assertNotNull(appender, name);
- assertTrue(appender instanceof FileAppender, appender.getClass().getName());
- final FileAppender fileAppender = (FileAppender) appender;
- // Two slashes because that's how the config file is setup.
- assertEquals(testPathLocation + "/hadoop.log", fileAppender.getFileName());
- } finally {
- System.clearProperty(TEST_KEY);
- }
- }
-
- @Override
- @Test
- public void testConsoleEnhancedPatternLayout() throws Exception {
- super.testConsoleEnhancedPatternLayout();
- }
-
- @Override
- @Test
- public void testConsoleHtmlLayout() throws Exception {
- super.testConsoleHtmlLayout();
- }
-
- @Override
- @Test
- public void testConsolePatternLayout() throws Exception {
- super.testConsolePatternLayout();
- }
-
- @Override
- @Test
- public void testConsoleSimpleLayout() throws Exception {
- super.testConsoleSimpleLayout();
- }
-
- @Override
- @Test
- public void testFileSimpleLayout() throws Exception {
- super.testFileSimpleLayout();
- }
-
- @Override
- @Test
- public void testNullAppender() throws Exception {
- super.testNullAppender();
- }
-
- @Override
- @Test
- public void testConsoleCapitalization() throws Exception {
- super.testConsoleCapitalization();
- }
-
- @Override
- @Test
- public void testConsoleTtccLayout() throws Exception {
- super.testConsoleTtccLayout();
- }
-
- @Override
- @Test
- public void testRollingFileAppender() throws Exception {
- super.testRollingFileAppender();
- }
-
- @Override
- @Test
- public void testDailyRollingFileAppender() throws Exception {
- super.testDailyRollingFileAppender();
- }
-
- @Override
- @Test
- public void testRollingFileAppenderWithProperties() throws Exception {
- super.testRollingFileAppenderWithProperties();
- }
-
- @Override
- @Test
- public void testSystemProperties1() throws Exception {
- super.testSystemProperties1();
- }
-
- @Override
- @Test
- public void testSystemProperties2() throws Exception {
- super.testSystemProperties2();
- }
-
- @Override
- @Test
- public void testDefaultValues() throws Exception {
- super.testDefaultValues();
- }
-
- @Override
- @Test
- public void testMultipleFilters(final @TempDir Path tmpFolder) throws Exception {
- super.testMultipleFilters(tmpFolder);
- }
-
- @Test
- public void testUntrimmedValues() throws Exception {
- try {
- final Configuration config = getConfiguration("config-1.2/log4j-untrimmed");
- final LoggerConfig rootLogger = config.getRootLogger();
- assertEquals(Level.DEBUG, rootLogger.getLevel());
- final Appender appender = config.getAppender("Console");
- assertTrue(appender instanceof ConsoleAppender);
- final Layout layout = appender.getLayout();
- assertTrue(layout instanceof PatternLayout);
- assertEquals("%v1Level - %m%n", ((PatternLayout) layout).getConversionPattern());
- final Filter filter = ((Filterable) appender).getFilter();
- assertTrue(filter instanceof DenyAllFilter);
- config.start();
- config.stop();
- } catch (NoClassDefFoundError e) {
- fail(e.getMessage());
- }
- }
-
- @Override
- @Test
- public void testGlobalThreshold() throws Exception {
- super.testGlobalThreshold();
- }
-
- @Test
- public void testEnhancedRollingFileAppender() throws Exception {
- try (final LoggerContext ctx = configure("config-1.2/log4j-EnhancedRollingFileAppender")) {
- final Configuration configuration = ctx.getConfiguration();
- assertNotNull(configuration);
- testEnhancedRollingFileAppender(configuration);
- }
- }
-
- @Override
- @Test
- public void testLevelRangeFilter() throws Exception {
- super.testLevelRangeFilter();
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesReconfigurationTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesReconfigurationTest.java
deleted file mode 100644
index 0662df2e4a8..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesReconfigurationTest.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.config;
-
-import static org.apache.logging.log4j.core.test.TestConstants.VERSION1_MONITOR_INTERVAL;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNotSame;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
-
-import java.io.File;
-import java.io.IOException;
-import java.time.Duration;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import org.apache.commons.lang3.function.FailableConsumer;
-import org.apache.log4j.CustomFileAppender;
-import org.apache.log4j.CustomNoopAppender;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.Logger;
-import org.apache.log4j.PropertyConfigurator;
-import org.apache.log4j.bridge.AppenderAdapter;
-import org.apache.log4j.bridge.AppenderWrapper;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.appender.FileAppender;
-import org.apache.logging.log4j.core.appender.FileManager;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.LoggerConfig;
-import org.junit.jupiter.api.Tag;
-import org.junit.jupiter.api.Test;
-
-/**
- * Test reconfiguring with an XML configuration.
- */
-public class PropertiesReconfigurationTest {
-
- private static final String CONFIG_CUSTOM_APPENDERS_1 = "target/test-classes/log4j1-appenders-custom-1.properties";
- private static final String CONFIG_CUSTOM_APPENDERS_2 = "target/test-classes/log4j1-appenders-custom-2.properties";
-
- private static final String CONFIG_FILE_APPENDER_1 = "target/test-classes/log4j1-file-1.properties";
- private static final String CONFIG_FILE_APPENDER_2 = "target/test-classes/log4j1-file-2.properties";
-
- private static final Duration FIVE_MINUTES = Duration.ofMinutes(5);
-
- private final CountDownLatch toggle = new CountDownLatch(1);
-
- private void assertCustomFileAppender(
- final org.apache.log4j.Appender appender,
- final boolean expectBoolean,
- final int expectInt,
- final String expectString) {
- final CustomFileAppender customAppender = (CustomFileAppender) appender;
- assertEquals(expectBoolean, customAppender.getBooleanA());
- assertEquals(expectInt, customAppender.getIntA());
- assertEquals(expectString, customAppender.getStringA());
- }
-
- private void assertCustomNoopAppender(
- final org.apache.log4j.Appender appender,
- final boolean expectBoolean,
- final int expectInt,
- final String expectString) {
- final CustomNoopAppender customAppender = (CustomNoopAppender) appender;
- assertEquals(expectBoolean, customAppender.getBooleanA());
- assertEquals(expectInt, customAppender.getIntA());
- assertEquals(expectString, customAppender.getStringA());
- }
-
- private void checkConfigureCustomAppenders(
- final String configPath,
- final boolean expectAppend,
- final int expectInt,
- final String expectString,
- final FailableConsumer configurator)
- throws IOException {
- final File file = new File(configPath);
- assertTrue(file.exists(), "No Config file");
- try (final LoggerContext context = TestConfigurator.configure(file.toString())) {
- final Logger logger = LogManager.getLogger("test");
- logger.info("Hello");
- // V1
- checkCustomAppender("A1", expectAppend, expectInt, expectString);
- checkCustomFileAppender("A2", expectAppend, expectInt, expectString);
- }
- }
-
- private void checkConfigureFileAppender(final String configPath, final boolean expectAppend) throws IOException {
- final File file = new File(configPath);
- assertTrue(file.exists(), "No Config file");
- try (final LoggerContext context = TestConfigurator.configure(file.toString())) {
- final Logger logger = LogManager.getLogger("test");
- logger.info("Hello");
- final Configuration configuration = context.getConfiguration();
- // Core
- checkCoreFileAppender(expectAppend, configuration, "A1");
- checkCoreFileAppender(expectAppend, configuration, "A2");
- // V1
- checkFileAppender(expectAppend, "A1");
- checkFileAppender(expectAppend, "A2");
- }
- }
-
- private void checkCoreFileAppender(final boolean expectAppend, final Appender appender) {
- assertNotNull(appender);
- final FileAppender fileAppender = (FileAppender) appender;
- @SuppressWarnings("resource")
- final FileManager manager = fileAppender.getManager();
- assertNotNull(manager);
- assertEquals(expectAppend, manager.isAppend());
- }
-
- private void checkCoreFileAppender(
- final boolean expectAppend, final Configuration configuration, final String appenderName) {
- checkCoreFileAppender(expectAppend, configuration.getAppender(appenderName));
- }
-
- private void checkCustomAppender(
- final String appenderName, final boolean expectBoolean, final int expectInt, final String expectString) {
- final Logger logger = LogManager.getRootLogger();
- final org.apache.log4j.Appender appender = logger.getAppender(appenderName);
- assertNotNull(appender);
- assertCustomNoopAppender(appender, expectBoolean, expectInt, expectString);
- assertCustomNoopAppender(getAppenderFromContext(appenderName), expectBoolean, expectInt, expectString);
- }
-
- private void checkCustomFileAppender(
- final String appenderName, final boolean expectBoolean, final int expectInt, final String expectString) {
- final Logger logger = LogManager.getRootLogger();
- final org.apache.log4j.Appender appender = logger.getAppender(appenderName);
- assertNotNull(appender);
- assertCustomFileAppender(appender, expectBoolean, expectInt, expectString);
- assertCustomFileAppender(getAppenderFromContext(appenderName), expectBoolean, expectInt, expectString);
- }
-
- private void checkFileAppender(final boolean expectAppend, final String appenderName) {
- final Logger logger = LogManager.getRootLogger();
- final org.apache.log4j.Appender appender = logger.getAppender(appenderName);
- assertNotNull(appender);
- final AppenderWrapper appenderWrapper = (AppenderWrapper) appender;
- checkCoreFileAppender(expectAppend, appenderWrapper.getAppender());
- }
-
- @SuppressWarnings("unchecked")
- private T getAppenderFromContext(final String appenderName) {
- final LoggerContext context = (LoggerContext) org.apache.logging.log4j.LogManager.getContext(false);
- final LoggerConfig loggerConfig = context.getConfiguration().getRootLogger();
- final AppenderAdapter.Adapter adapter =
- (AppenderAdapter.Adapter) loggerConfig.getAppenders().get(appenderName);
- return adapter != null ? (T) adapter.getAppender() : null;
- }
-
- /**
- * Tests that configuring and reconfiguring CUSTOM appenders properly pick up different settings.
- */
- @Test
- public void testCustomAppenders_TestConfigurator() throws IOException {
- checkConfigureCustomAppenders(CONFIG_CUSTOM_APPENDERS_1, true, 1, "A", TestConfigurator::configure);
- checkConfigureCustomAppenders(CONFIG_CUSTOM_APPENDERS_2, false, 2, "B", TestConfigurator::configure);
- checkConfigureCustomAppenders(CONFIG_CUSTOM_APPENDERS_1, true, 1, "A", TestConfigurator::configure);
- checkConfigureCustomAppenders(CONFIG_CUSTOM_APPENDERS_2, false, 2, "B", TestConfigurator::configure);
- }
-
- /**
- * Tests that configuring and reconfiguring CUSTOM appenders properly pick up different settings.
- */
- @Test
- public void testCustomAppenders_PropertyConfigurator() throws IOException {
- checkConfigureCustomAppenders(CONFIG_CUSTOM_APPENDERS_1, true, 1, "A", PropertyConfigurator::configure);
- checkConfigureCustomAppenders(CONFIG_CUSTOM_APPENDERS_2, false, 2, "B", PropertyConfigurator::configure);
- checkConfigureCustomAppenders(CONFIG_CUSTOM_APPENDERS_1, true, 1, "A", PropertyConfigurator::configure);
- checkConfigureCustomAppenders(CONFIG_CUSTOM_APPENDERS_2, false, 2, "B", PropertyConfigurator::configure);
- }
-
- /**
- * Tests that configuring and reconfiguring STOCK file appenders properly pick up different settings.
- */
- @Test
- public void testFileAppenders() throws Exception {
- checkConfigureFileAppender(CONFIG_FILE_APPENDER_1, false);
- checkConfigureFileAppender(CONFIG_FILE_APPENDER_2, true);
- checkConfigureFileAppender(CONFIG_FILE_APPENDER_1, false);
- checkConfigureFileAppender(CONFIG_FILE_APPENDER_2, true);
- }
-
- @Test
- @Tag("sleepy")
- public void testTestListener() throws Exception {
- System.setProperty(VERSION1_MONITOR_INTERVAL, "1");
- final File file = new File(CONFIG_FILE_APPENDER_1);
- assertTrue(file.exists(), "No Config file");
- final long configMillis = file.lastModified();
- assertTrue(file.setLastModified(configMillis - FIVE_MINUTES.toMillis()), "Unable to modified file time");
- try (final LoggerContext context = TestConfigurator.configure(file.toString())) {
- final Logger logger = LogManager.getLogger("test");
- logger.info("Hello");
- final Configuration original = context.getConfiguration();
- original.addListener(ignored -> toggle.countDown());
- file.setLastModified(System.currentTimeMillis());
- try {
- if (!toggle.await(3, TimeUnit.SECONDS)) {
- fail("Reconfiguration timed out");
- }
- // Allow reconfiguration to complete.
- Thread.sleep(500);
- } catch (final InterruptedException ie) {
- fail("Reconfiguration interupted");
- }
- final Configuration updated = context.getConfiguration();
- assertNotSame(original, updated, "Configurations are the same");
- }
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesRollingWithPropertiesTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesRollingWithPropertiesTest.java
deleted file mode 100644
index 66b3ac96bdf..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/PropertiesRollingWithPropertiesTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.config;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.nio.file.Path;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.test.TestConstants;
-import org.apache.logging.log4j.test.junit.TempLoggingDir;
-import org.junit.jupiter.api.Test;
-import org.junitpioneer.jupiter.RestoreSystemProperties;
-
-/**
- * Test configuration from Properties.
- */
-class PropertiesRollingWithPropertiesTest {
-
- @TempLoggingDir
- private static Path loggingPath;
-
- @Test
- @RestoreSystemProperties
- void testProperties() {
- System.setProperty("test.directory", loggingPath.toString());
- System.setProperty(TestConstants.VERSION1_CONFIGURATION, "log4j1-rolling-properties.properties");
-
- try (final LoggerContext context = LoggerContext.getContext(false)) {
- final Logger logger = context.getLogger("test");
- logger.debug("This is a test of the root logger");
- assertThat(loggingPath.resolve("somefile.log")).exists().isNotEmptyFile();
- }
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/RewriteAppenderTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/RewriteAppenderTest.java
deleted file mode 100644
index e264263c872..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/RewriteAppenderTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.config;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import java.util.List;
-import java.util.Map;
-import org.apache.log4j.ListAppender;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.Logger;
-import org.apache.log4j.bridge.AppenderAdapter;
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.test.TestConstants;
-import org.apache.logging.log4j.test.junit.UsingThreadContextMap;
-import org.junit.jupiter.api.Test;
-import org.junitpioneer.jupiter.SetSystemProperty;
-
-/**
- * Test RewriteAppender
- */
-@UsingThreadContextMap
-public class RewriteAppenderTest {
-
- @Test
- @SetSystemProperty(key = TestConstants.VERSION1_CONFIGURATION, value = "log4j1-rewrite.xml")
- public void testRewrite() {
- final Logger logger = LogManager.getLogger("test");
- final LoggerContext context = LoggerContext.getContext(false);
- ThreadContext.put("key1", "This is a test");
- ThreadContext.put("hello", "world");
- final long logTime = System.currentTimeMillis();
- logger.debug("Say hello");
- final Configuration configuration = context.getConfiguration();
- final Map appenders = configuration.getAppenders();
- ListAppender eventAppender = null;
- for (Map.Entry entry : appenders.entrySet()) {
- if (entry.getKey().equals("events")) {
- eventAppender = (ListAppender) ((AppenderAdapter.Adapter) entry.getValue()).getAppender();
- }
- }
- assertNotNull(eventAppender, "No Event Appender");
- final List events = eventAppender.getEvents();
- assertTrue(events != null && events.size() > 0, "No events");
- assertNotNull(events.get(0).getProperties(), "No properties in the event");
- assertTrue(events.get(0).getProperties().containsKey("key2"), "Key was not inserted");
- assertEquals("Log4j", events.get(0).getProperties().get("key2"), "Key value is incorrect");
- assertTrue(events.get(0).getTimeStamp() >= logTime, "Timestamp is before point of logging");
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/SocketAppenderConfigurationTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/SocketAppenderConfigurationTest.java
deleted file mode 100644
index 3aac71cc7de..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/SocketAppenderConfigurationTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.config;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import java.io.IOException;
-import java.util.Map;
-import org.apache.log4j.layout.Log4j1XmlLayout;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.appender.SocketAppender;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.filter.ThresholdFilter;
-import org.apache.logging.log4j.core.net.Protocol;
-import org.apache.logging.log4j.core.net.TcpSocketManager;
-import org.junit.Test;
-
-/**
- * Tests configuring a Syslog appender.
- */
-public class SocketAppenderConfigurationTest {
-
- private SocketAppender check(final Protocol expected, final Configuration configuration) {
- final Map appenders = configuration.getAppenders();
- assertNotNull(appenders);
- final String appenderName = "socket";
- final Appender appender = appenders.get(appenderName);
- assertNotNull(appender, "Missing appender " + appenderName);
- final SocketAppender socketAppender = (SocketAppender) appender;
- @SuppressWarnings("resource")
- final TcpSocketManager manager = (TcpSocketManager) socketAppender.getManager();
- final String prefix = expected + ":";
- assertTrue(
- manager.getName().startsWith(prefix),
- () -> String.format("'%s' does not start with '%s'", manager.getName(), prefix));
- // Threshold
- final ThresholdFilter filter = (ThresholdFilter) socketAppender.getFilter();
- assertEquals(Level.DEBUG, filter.getLevel());
- // Host
- assertEquals("localhost", manager.getHost());
- // Port
- assertEquals(9999, manager.getPort());
- // Port
- assertEquals(100, manager.getReconnectionDelayMillis());
- return socketAppender;
- }
-
- private void checkProtocolPropertiesConfig(final Protocol expected, final String xmlPath) throws IOException {
- check(expected, TestConfigurator.configure(xmlPath).getConfiguration());
- }
-
- private SocketAppender checkProtocolXmlConfig(final Protocol expected, final String xmlPath) throws IOException {
- return check(expected, TestConfigurator.configure(xmlPath).getConfiguration());
- }
-
- @Test
- public void testProperties() throws Exception {
- checkProtocolXmlConfig(Protocol.TCP, "target/test-classes/log4j1-socket.properties");
- }
-
- @Test
- public void testPropertiesXmlLayout() throws Exception {
- final SocketAppender socketAppender =
- checkProtocolXmlConfig(Protocol.TCP, "target/test-classes/log4j1-socket-xml-layout.properties");
- assertTrue(socketAppender.getLayout() instanceof Log4j1XmlLayout);
- }
-
- @Test
- public void testXml() throws Exception {
- checkProtocolXmlConfig(Protocol.TCP, "target/test-classes/log4j1-socket.xml");
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/StartsWithFilter.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/StartsWithFilter.java
deleted file mode 100644
index 7ad3774deab..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/StartsWithFilter.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.config;
-
-import org.apache.log4j.spi.Filter;
-import org.apache.log4j.spi.LoggingEvent;
-
-/**
- * A Filter used in tests.
- */
-public class StartsWithFilter extends Filter {
-
- @Override
- public int decide(final LoggingEvent event) {
- final String message = String.valueOf(event.getMessage());
- if (message.startsWith("DENY")) {
- return DENY;
- } else if (message.startsWith("ACCEPT")) {
- return ACCEPT;
- }
- return NEUTRAL;
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/SyslogAppenderConfigurationTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/SyslogAppenderConfigurationTest.java
deleted file mode 100644
index c6a0063de1a..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/SyslogAppenderConfigurationTest.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.config;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import java.io.IOException;
-import java.net.ServerSocket;
-import java.util.Map;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.appender.SyslogAppender;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.filter.ThresholdFilter;
-import org.apache.logging.log4j.core.net.AbstractSocketManager;
-import org.apache.logging.log4j.core.net.Protocol;
-import org.apache.logging.log4j.test.junit.UsingStatusListener;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-import org.junitpioneer.jupiter.WritesSystemProperty;
-
-/**
- * Tests configuring a Syslog appender.
- */
-@UsingStatusListener
-@WritesSystemProperty
-public class SyslogAppenderConfigurationTest {
-
- private static ServerSocket tcpSocket;
-
- @BeforeAll
- static void setup() throws IOException {
- // TCP appenders log an error if there is no server socket
- tcpSocket = new ServerSocket(0);
- System.setProperty("syslog.port", Integer.toString(tcpSocket.getLocalPort()));
- }
-
- @AfterAll
- static void cleanup() throws IOException {
- System.clearProperty("syslog.port");
- tcpSocket.close();
- }
-
- private void check(final Protocol expected, final Configuration configuration) {
- final Map appenders = configuration.getAppenders();
- assertNotNull(appenders);
- final String appenderName = "syslog";
- final Appender appender = appenders.get(appenderName);
- assertNotNull(appender, "Missing appender " + appenderName);
- final SyslogAppender syslogAppender = (SyslogAppender) appender;
- @SuppressWarnings("resource")
- final AbstractSocketManager manager = syslogAppender.getManager();
- final String prefix = expected + ":";
- assertTrue(
- manager.getName().startsWith(prefix),
- () -> String.format("'%s' does not start with '%s'", manager.getName(), prefix));
- // Threshold
- final ThresholdFilter filter = (ThresholdFilter) syslogAppender.getFilter();
- assertEquals(Level.DEBUG, filter.getLevel());
- // Host
- assertEquals("localhost", manager.getHost());
- // Port
- assertEquals(tcpSocket.getLocalPort(), manager.getPort());
- }
-
- private void checkProtocolPropertiesConfig(final Protocol expected, final String xmlPath) throws IOException {
- check(expected, TestConfigurator.configure(xmlPath).getConfiguration());
- }
-
- private void checkProtocolXmlConfig(final Protocol expected, final String xmlPath) throws IOException {
- check(expected, TestConfigurator.configure(xmlPath).getConfiguration());
- }
-
- @Test
- public void testPropertiesProtocolDefault() throws Exception {
- checkProtocolPropertiesConfig(Protocol.TCP, "target/test-classes/log4j1-syslog-protocol-default.properties");
- }
-
- @Test
- public void testPropertiesProtocolTcp() throws Exception {
- checkProtocolPropertiesConfig(Protocol.TCP, "target/test-classes/log4j1-syslog-protocol-tcp.properties");
- }
-
- @Test
- public void testPropertiesProtocolUdp() throws Exception {
- checkProtocolPropertiesConfig(Protocol.UDP, "target/test-classes/log4j1-syslog-protocol-udp.properties");
- }
-
- @Test
- public void testXmlProtocolDefault() throws Exception {
- checkProtocolXmlConfig(Protocol.TCP, "target/test-classes/log4j1-syslog.xml");
- }
-
- @Test
- public void testXmlProtocolTcp() throws Exception {
- checkProtocolXmlConfig(Protocol.TCP, "target/test-classes/log4j1-syslog-protocol-tcp.xml");
- }
-
- @Test
- public void testXmlProtocolUdp() throws Exception {
- checkProtocolXmlConfig(Protocol.UDP, "target/test-classes/log4j1-syslog-protocol-udp.xml");
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/SyslogAppenderTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/SyslogAppenderTest.java
deleted file mode 100644
index 987514e6f7d..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/SyslogAppenderTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.config;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.io.IOException;
-import java.util.List;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.test.TestConstants;
-import org.apache.logging.log4j.core.test.net.mock.MockSyslogServer;
-import org.apache.logging.log4j.core.test.net.mock.MockSyslogServerFactory;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Tag;
-import org.junit.jupiter.api.Test;
-
-/**
- * Class Description goes here.
- */
-@Tag("sleepy")
-public class SyslogAppenderTest {
-
- private static MockSyslogServer syslogServer;
-
- @BeforeAll
- public static void beforeClass() throws IOException {
- initTCPTestEnvironment();
- System.setProperty("syslog.port", Integer.toString(syslogServer.getLocalPort()));
- System.setProperty(TestConstants.VERSION1_CONFIGURATION, "target/test-classes/log4j1-syslog.xml");
- }
-
- @AfterAll
- public static void cleanup() {
- System.clearProperty(TestConstants.VERSION1_CONFIGURATION);
- syslogServer.shutdown();
- }
-
- @Test
- public void sendMessage() throws Exception {
- final Logger logger = LogManager.getLogger(SyslogAppenderTest.class);
- logger.info("This is a test");
- List messages = null;
- for (int i = 0; i < 5; ++i) {
- Thread.sleep(250);
- messages = syslogServer.getMessageList();
- if (messages != null && messages.size() > 0) {
- break;
- }
- }
- assertThat(messages).hasSize(1);
- }
-
- protected static void initTCPTestEnvironment() throws IOException {
- syslogServer = MockSyslogServerFactory.createTCPSyslogServer();
- syslogServer.start();
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/TestConfigurator.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/TestConfigurator.java
deleted file mode 100644
index f80677ec9ce..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/TestConfigurator.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.config;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.jupiter.api.Assertions.fail;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import org.apache.log4j.xml.XmlConfigurationFactory;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.ConfigurationSource;
-import org.apache.logging.log4j.core.config.Configurator;
-
-public class TestConfigurator {
-
- public static LoggerContext configure(final String configLocation) throws IOException {
- final Path path = Paths.get(configLocation);
- try (final InputStream inputStream = Files.newInputStream(path)) {
- final ConfigurationSource source = new ConfigurationSource(inputStream, path);
- final LoggerContext context = (LoggerContext) org.apache.logging.log4j.LogManager.getContext(false);
- Configuration configuration = null;
- if (configLocation.endsWith(PropertiesConfigurationFactory.FILE_EXTENSION)) {
- configuration = new PropertiesConfigurationFactory().getConfiguration(context, source);
- } else if (configLocation.endsWith(XmlConfigurationFactory.FILE_EXTENSION)) {
- configuration = new XmlConfigurationFactory().getConfiguration(context, source);
- } else {
- fail("Test infra does not support " + configLocation);
- }
- assertNotNull("No configuration created", configuration);
- Configurator.reconfigure(configuration);
- return context;
- }
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlConfigurationFactoryTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlConfigurationFactoryTest.java
deleted file mode 100644
index c6f058a80f3..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlConfigurationFactoryTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.config;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.Logger;
-import org.apache.logging.log4j.core.test.TestConstants;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * Test configuration from XML.
- */
-public class XmlConfigurationFactoryTest {
-
- @BeforeClass
- public static void beforeClass() {
- System.setProperty(TestConstants.VERSION1_CONFIGURATION, "target/test-classes/log4j1-file.xml");
- }
-
- @Test
- public void testXML() {
- final Logger logger = LogManager.getLogger("test");
- logger.debug("This is a test of the root logger");
- File file = new File("target/temp.A1");
- assertTrue("File A1 was not created", file.exists());
- assertTrue("File A1 is empty", file.length() > 0);
- file = new File("target/temp.A2");
- assertTrue("File A2 was not created", file.exists());
- assertTrue("File A2 is empty", file.length() > 0);
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlConfigurationTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlConfigurationTest.java
deleted file mode 100644
index eb934c085e6..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlConfigurationTest.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.config;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URISyntaxException;
-import java.nio.file.Path;
-import java.util.List;
-import java.util.Map;
-import org.apache.log4j.ListAppender;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.Logger;
-import org.apache.log4j.bridge.AppenderAdapter;
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.log4j.xml.XmlConfigurationFactory;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.appender.RollingFileAppender;
-import org.apache.logging.log4j.core.appender.rolling.CompositeTriggeringPolicy;
-import org.apache.logging.log4j.core.appender.rolling.SizeBasedTriggeringPolicy;
-import org.apache.logging.log4j.core.appender.rolling.TimeBasedTriggeringPolicy;
-import org.apache.logging.log4j.core.appender.rolling.TriggeringPolicy;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.ConfigurationSource;
-import org.apache.logging.log4j.core.test.junit.ConfigurationFactoryType;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.io.TempDir;
-
-/**
- * Test configuration from XML.
- */
-@ConfigurationFactoryType(XmlConfigurationFactory.class)
-public class XmlConfigurationTest extends AbstractLog4j1ConfigurationTest {
-
- private static final String SUFFIX = ".xml";
-
- @Override
- Configuration getConfiguration(final String configResourcePrefix) throws URISyntaxException, IOException {
- final String configResource = configResourcePrefix + SUFFIX;
- final InputStream inputStream = getResourceAsStream(configResource);
- final ConfigurationSource source = new ConfigurationSource(inputStream);
- final LoggerContext context = LoggerContext.getContext(false);
- final Configuration configuration = context.getConfiguration(source);
- assertNotNull(configuration, "No configuration created");
- configuration.initialize();
- return configuration;
- }
-
- @Test
- public void testXML() throws Exception {
- configure("log4j1-file");
- final Logger logger = LogManager.getLogger("test");
- logger.debug("This is a test of the root logger");
- File file = new File("target/temp.A1");
- assertTrue(file.exists(), "File A1 was not created");
- assertTrue(file.length() > 0, "File A1 is empty");
- file = new File("target/temp.A2");
- assertTrue(file.exists(), "File A2 was not created");
- assertTrue(file.length() > 0, "File A2 is empty");
- }
-
- @Test
- public void testListAppender() throws Exception {
- final LoggerContext loggerContext = configure("log4j1-list");
- final Logger logger = LogManager.getLogger("test");
- logger.debug("This is a test of the root logger");
- final Configuration configuration = loggerContext.getConfiguration();
- final Map appenders = configuration.getAppenders();
- ListAppender eventAppender = null;
- ListAppender messageAppender = null;
- for (Map.Entry entry : appenders.entrySet()) {
- if (entry.getKey().equals("list")) {
- messageAppender = (ListAppender) ((AppenderAdapter.Adapter) entry.getValue()).getAppender();
- } else if (entry.getKey().equals("events")) {
- eventAppender = (ListAppender) ((AppenderAdapter.Adapter) entry.getValue()).getAppender();
- }
- }
- assertNotNull(eventAppender, "No Event Appender");
- assertNotNull(messageAppender, "No Message Appender");
- final List events = eventAppender.getEvents();
- assertTrue(events != null && events.size() > 0, "No events");
- final List messages = messageAppender.getMessages();
- assertTrue(messages != null && messages.size() > 0, "No messages");
- }
-
- @Override
- @Test
- public void testConsoleEnhancedPatternLayout() throws Exception {
- super.testConsoleEnhancedPatternLayout();
- }
-
- @Override
- @Test
- public void testConsoleHtmlLayout() throws Exception {
- super.testConsoleHtmlLayout();
- }
-
- @Override
- @Test
- public void testConsolePatternLayout() throws Exception {
- super.testConsolePatternLayout();
- }
-
- @Override
- @Test
- public void testConsoleSimpleLayout() throws Exception {
- super.testConsoleSimpleLayout();
- }
-
- @Override
- @Test
- public void testFileSimpleLayout() throws Exception {
- super.testFileSimpleLayout();
- }
-
- @Override
- @Test
- public void testNullAppender() throws Exception {
- super.testNullAppender();
- }
-
- @Override
- @Test
- public void testConsoleCapitalization() throws Exception {
- super.testConsoleCapitalization();
- }
-
- @Override
- @Test
- public void testConsoleTtccLayout() throws Exception {
- super.testConsoleTtccLayout();
- }
-
- @Override
- @Test
- public void testRollingFileAppender() throws Exception {
- super.testRollingFileAppender();
- }
-
- @Override
- @Test
- public void testDailyRollingFileAppender() throws Exception {
- super.testDailyRollingFileAppender();
- }
-
- @Override
- @Test
- public void testSystemProperties1() throws Exception {
- super.testSystemProperties1();
- }
-
- @Override
- @Test
- public void testDefaultValues() throws Exception {
- super.testDefaultValues();
- }
-
- @Override
- @Test
- public void testMultipleFilters(final @TempDir Path tmpFolder) throws Exception {
- super.testMultipleFilters(tmpFolder);
- }
-
- @Override
- @Test
- public void testGlobalThreshold() throws Exception {
- super.testGlobalThreshold();
- }
-
- @Test
- public void testEnhancedRollingFileAppender() throws Exception {
- try (final LoggerContext ctx = configure("config-1.2/log4j-EnhancedRollingFileAppender")) {
- final Configuration configuration = ctx.getConfiguration();
- assertNotNull(configuration);
- testEnhancedRollingFileAppender(configuration);
- // Only supported through XML configuration
- final Appender appender = configuration.getAppender("MIXED");
- assertTrue(appender instanceof RollingFileAppender, "is RollingFileAppender");
- final TriggeringPolicy policy = ((RollingFileAppender) appender).getTriggeringPolicy();
- assertTrue(policy instanceof CompositeTriggeringPolicy, "is CompositeTriggeringPolicy");
- final TriggeringPolicy[] policies = ((CompositeTriggeringPolicy) policy).getTriggeringPolicies();
- assertEquals(2, policies.length);
- assertTrue(policies[0] instanceof TimeBasedTriggeringPolicy, "is TimeBasedTriggeringPolicy");
- assertTrue(policies[1] instanceof SizeBasedTriggeringPolicy, "is SizeBasedTriggeringPolicy");
- }
- }
-
- @Override
- @Test
- public void testLevelRangeFilter() throws Exception {
- super.testLevelRangeFilter();
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlReconfigurationTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlReconfigurationTest.java
deleted file mode 100644
index 2ecc85e56bf..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlReconfigurationTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.config;
-
-import static org.apache.logging.log4j.core.test.TestConstants.VERSION1_MONITOR_INTERVAL;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNotSame;
-import static org.junit.jupiter.api.Assertions.fail;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.Logger;
-import org.apache.log4j.xml.XmlConfigurationFactory;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.ConfigurationSource;
-import org.apache.logging.log4j.core.config.Configurator;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Tag;
-import org.junit.jupiter.api.Test;
-
-/**
- * Test reconfiguring with an XML configuration.
- */
-@Tag("sleepy")
-public class XmlReconfigurationTest {
-
- private static final String CONFIG = "target/test-classes/log4j1-file.xml";
- private static final long FIVE_MINUTES = 5 * 60 * 1000;
-
- private final CountDownLatch toggle = new CountDownLatch(1);
-
- @Test
- public void testReconfiguration() throws Exception {
- System.setProperty(VERSION1_MONITOR_INTERVAL, "1");
- final File file = new File(CONFIG);
- assertNotNull(file, "No Config file");
- final long configMillis = file.lastModified();
- Assertions.assertTrue(file.setLastModified(configMillis - FIVE_MINUTES), "Unable to modified file time");
- final LoggerContext context = configure(file);
- final Logger logger = LogManager.getLogger("test");
- logger.info("Hello");
- final Configuration original = context.getConfiguration();
- original.addListener(ignored -> toggle.countDown());
- file.setLastModified(System.currentTimeMillis());
- try {
- if (!toggle.await(3, TimeUnit.SECONDS)) {
- fail("Reconfiguration timed out");
- }
- // Allow reconfiguration to complete.
- Thread.sleep(500);
- } catch (InterruptedException ie) {
- fail("Reconfiguration interupted");
- }
- final Configuration updated = context.getConfiguration();
- assertNotSame(original, updated, "Configurations are the same");
- }
-
- private LoggerContext configure(final File configFile) throws Exception {
- final InputStream is = new FileInputStream(configFile);
- final ConfigurationSource source = new ConfigurationSource(is, configFile);
- final LoggerContext context = (LoggerContext) org.apache.logging.log4j.LogManager.getContext(false);
- final Configuration configuration = new XmlConfigurationFactory().getConfiguration(context, source);
- assertNotNull(configuration, "No configuration created");
- Configurator.reconfigure(configuration);
- return context;
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlRollingWithPropertiesTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlRollingWithPropertiesTest.java
deleted file mode 100644
index 7841ee53c68..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/config/XmlRollingWithPropertiesTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.config;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.nio.file.Path;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.core.test.TestConstants;
-import org.apache.logging.log4j.test.junit.TempLoggingDir;
-import org.junit.jupiter.api.Test;
-import org.junitpioneer.jupiter.RestoreSystemProperties;
-
-/**
- * Test configuration from XML.
- */
-class XmlRollingWithPropertiesTest {
-
- @TempLoggingDir
- private static Path loggingPath;
-
- @Test
- @RestoreSystemProperties
- void testProperties() {
- System.setProperty("test.directory", loggingPath.toString());
- System.setProperty(TestConstants.VERSION1_CONFIGURATION, "log4j1-rolling-properties.xml");
-
- try (final LoggerContext context = LoggerContext.getContext(false)) {
- final Logger logger = context.getLogger("test");
- logger.debug("This is a test of the root logger");
- assertThat(loggingPath.resolve("logs/etl.log")).exists().isNotEmptyFile();
- }
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/BoundedFIFOTestCase.java b/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/BoundedFIFOTestCase.java
deleted file mode 100644
index 38dc4573afc..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/BoundedFIFOTestCase.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.helpers;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.spi.LoggingEvent;
-
-/**
- * Test {@link BoundedFIFO}.
- *
- * @since 0.9.1
- */
-public class BoundedFIFOTestCase extends TestCase {
- static Logger cat = Logger.getLogger("x");
-
- static int MAX = 1000;
-
- static LoggingEvent[] e = new LoggingEvent[MAX];
-
- public static Test suite() {
- final TestSuite suite = new TestSuite();
- suite.addTest(new BoundedFIFOTestCase("test1"));
- suite.addTest(new BoundedFIFOTestCase("test2"));
- suite.addTest(new BoundedFIFOTestCase("testResize1"));
- suite.addTest(new BoundedFIFOTestCase("testResize2"));
- suite.addTest(new BoundedFIFOTestCase("testResize3"));
- return suite;
- }
-
- {
- for (int i = 0; i < MAX; i++) {
- e[i] = new LoggingEvent("", cat, Level.DEBUG, "e" + i, null);
- }
- }
-
- public BoundedFIFOTestCase(final String name) {
- super(name);
- }
-
- int min(final int a, final int b) {
- return a < b ? a : b;
- }
-
- @Override
- public void setUp() {}
-
- /**
- * Pattern: +++++..-----..
- */
- public void test1() {
- for (int size = 1; size <= 128; size *= 2) {
- final BoundedFIFO bf = new BoundedFIFO(size);
-
- assertEquals(bf.getMaxSize(), size);
- assertNull(bf.get());
-
- int i;
- int j;
- int k;
-
- for (i = 1; i < 2 * size; i++) {
- for (j = 0; j < i; j++) {
- // System.out.println("Putting "+e[j]);
- bf.put(e[j]);
- assertEquals(bf.length(), j < size ? j + 1 : size);
- }
- final int max = size < j ? size : j;
- j--;
- for (k = 0; k <= j; k++) {
- // System.out.println("max="+max+", j="+j+", k="+k);
- assertEquals(bf.length(), max - k > 0 ? max - k : 0);
- final Object r = bf.get();
- // System.out.println("Got "+r);
- if (k >= size) {
- assertNull(r);
- } else {
- assertEquals(r, e[k]);
- }
- }
- }
- // System.out.println("Passed size="+size);
- }
- }
-
- /**
- * Pattern: ++++--++--++
- */
- public void test2() {
- final int size = 3;
- final BoundedFIFO bf = new BoundedFIFO(size);
-
- bf.put(e[0]);
- assertEquals(bf.get(), e[0]);
- assertNull(bf.get());
-
- bf.put(e[1]);
- assertEquals(bf.length(), 1);
- bf.put(e[2]);
- assertEquals(bf.length(), 2);
- bf.put(e[3]);
- assertEquals(bf.length(), 3);
- assertEquals(bf.get(), e[1]);
- assertEquals(bf.length(), 2);
- assertEquals(bf.get(), e[2]);
- assertEquals(bf.length(), 1);
- assertEquals(bf.get(), e[3]);
- assertEquals(bf.length(), 0);
- assertNull(bf.get());
- assertEquals(bf.length(), 0);
- }
-
- /**
- * Pattern ++++++++++++++++++++ (insert only);
- */
- public void testResize1() {
- final int size = 10;
-
- for (int n = 1; n < size * 2; n++) {
- for (int i = 0; i < size * 2; i++) {
-
- final BoundedFIFO bf = new BoundedFIFO(size);
- for (int f = 0; f < i; f++) {
- bf.put(e[f]);
- }
-
- bf.resize(n);
- final int expectedSize = min(n, min(i, size));
- assertEquals(bf.length(), expectedSize);
- for (int c = 0; c < expectedSize; c++) {
- assertEquals(bf.get(), e[c]);
- }
- }
- }
- }
-
- /**
- * Pattern ++...+ --...-
- */
- public void testResize2() {
- final int size = 10;
-
- for (int n = 1; n < size * 2; n++) {
- for (int i = 0; i < size * 2; i++) {
- for (int d = 0; d < min(i, size); d++) {
-
- final BoundedFIFO bf = new BoundedFIFO(size);
- for (int p = 0; p < i; p++) {
- bf.put(e[p]);
- }
-
- for (int g = 0; g < d; g++) {
- bf.get();
- }
-
- // x = the number of elems in
- final int x = bf.length();
-
- bf.resize(n);
-
- final int expectedSize = min(n, x);
- assertEquals(bf.length(), expectedSize);
-
- for (int c = 0; c < expectedSize; c++) {
- assertEquals(bf.get(), e[c + d]);
- }
- assertNull(bf.get());
- }
- }
- }
- }
-
- /**
- * Pattern: i inserts, d deletes, r inserts
- */
- public void testResize3() {
- final int size = 10;
-
- for (int n = 1; n < size * 2; n++) {
- for (int i = 0; i < size; i++) {
- for (int d = 0; d < i; d++) {
- for (int r = 0; r < d; r++) {
-
- final BoundedFIFO bf = new BoundedFIFO(size);
- for (int p0 = 0; p0 < i; p0++) {
- bf.put(e[p0]);
- }
-
- for (int g = 0; g < d; g++) {
- bf.get();
- }
- for (int p1 = 0; p1 < r; p1++) {
- bf.put(e[i + p1]);
- }
-
- final int x = bf.length();
-
- bf.resize(n);
-
- final int expectedSize = min(n, x);
- assertEquals(bf.length(), expectedSize);
-
- for (int c = 0; c < expectedSize; c++) {
- assertEquals(bf.get(), e[c + d]);
- }
- // assertNull(bf.get());
- }
- }
- }
- }
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/CyclicBufferTestCase.java b/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/CyclicBufferTestCase.java
deleted file mode 100644
index 2c965ba861d..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/CyclicBufferTestCase.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.helpers;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.spi.LoggingEvent;
-
-/**
- * Tests {@link CyclicBuffer}.
- */
-public class CyclicBufferTestCase extends TestCase {
-
- static Logger cat = Logger.getLogger("x");
-
- static int MAX = 1000;
-
- static LoggingEvent[] e = new LoggingEvent[MAX];
-
- public static Test suite() {
- final TestSuite suite = new TestSuite();
- suite.addTest(new CyclicBufferTestCase("test0"));
- suite.addTest(new CyclicBufferTestCase("test1"));
- suite.addTest(new CyclicBufferTestCase("testResize"));
- return suite;
- }
-
- {
- for (int i = 0; i < MAX; i++) {
- e[i] = new LoggingEvent("", cat, Level.DEBUG, "e" + i, null);
- }
- }
-
- public CyclicBufferTestCase(final String name) {
- super(name);
- }
-
- void doTest1(final int size) {
- // System.out.println("Doing test with size = "+size);
- final CyclicBuffer cb = new CyclicBuffer(size);
-
- assertEquals(cb.getMaxSize(), size);
-
- for (int i = -(size + 10); i < (size + 10); i++) {
- assertNull(cb.get(i));
- }
-
- for (int i = 0; i < MAX; i++) {
- cb.add(e[i]);
- final int limit = i < size - 1 ? i : size - 1;
-
- // System.out.println("\nLimit is " + limit + ", i="+i);
-
- for (int j = limit; j >= 0; j--) {
- // System.out.println("i= "+i+", j="+j);
- assertEquals(cb.get(j), e[i - (limit - j)]);
- }
- assertNull(cb.get(-1));
- assertNull(cb.get(limit + 1));
- }
- }
-
- void doTestResize(final int initialSize, final int numberOfAdds, final int newSize) {
- // System.out.println("initialSize = "+initialSize+", numberOfAdds="
- // +numberOfAdds+", newSize="+newSize);
- final CyclicBuffer cb = new CyclicBuffer(initialSize);
- for (int i = 0; i < numberOfAdds; i++) {
- cb.add(e[i]);
- }
- cb.resize(newSize);
-
- int offset = numberOfAdds - initialSize;
- if (offset < 0) {
- offset = 0;
- }
-
- int len = newSize < numberOfAdds ? newSize : numberOfAdds;
- len = len < initialSize ? len : initialSize;
- // System.out.println("Len = "+len+", offset="+offset);
- for (int j = 0; j < len; j++) {
- assertEquals(cb.get(j), e[offset + j]);
- }
- }
-
- @Override
- public void setUp() {}
-
- public void test0() {
- final int size = 2;
-
- CyclicBuffer cb = new CyclicBuffer(size);
- assertEquals(cb.getMaxSize(), size);
-
- cb.add(e[0]);
- assertEquals(cb.length(), 1);
- assertEquals(cb.get(), e[0]);
- assertEquals(cb.length(), 0);
- assertNull(cb.get());
- assertEquals(cb.length(), 0);
-
- cb = new CyclicBuffer(size);
- cb.add(e[0]);
- cb.add(e[1]);
- assertEquals(cb.length(), 2);
- assertEquals(cb.get(), e[0]);
- assertEquals(cb.length(), 1);
- assertEquals(cb.get(), e[1]);
- assertEquals(cb.length(), 0);
- assertNull(cb.get());
- assertEquals(cb.length(), 0);
- }
-
- /**
- * Test a buffer of size 1,2,4,8,..,128
- */
- public void test1() {
- for (int bufSize = 1; bufSize <= 128; bufSize *= 2) {
- doTest1(bufSize);
- }
- }
-
- public void testResize() {
- for (int isize = 1; isize <= 128; isize *= 2) {
- doTestResize(isize, isize / 2 + 1, isize / 2 + 1);
- doTestResize(isize, isize / 2 + 1, isize + 10);
- doTestResize(isize, isize + 10, isize / 2 + 1);
- doTestResize(isize, isize + 10, isize + 10);
- }
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/DateLayoutTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/DateLayoutTest.java
deleted file mode 100644
index 8ec4d21d7a4..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/DateLayoutTest.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.helpers;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.TimeZone;
-import org.apache.log4j.Layout;
-import org.apache.log4j.LayoutTest;
-import org.apache.log4j.spi.LoggingEvent;
-
-/**
- * Tests {@link DateLayout}.
- */
-public class DateLayoutTest extends LayoutTest {
-
- /**
- * Construct a new instance of LayoutTest.
- *
- * @param testName test name.
- */
- public DateLayoutTest(final String testName) {
- super(testName);
- }
-
- /**
- * Constructor for use by derived tests.
- *
- * @param testName name of test.
- * @param expectedContentType expected value for getContentType().
- * @param expectedIgnoresThrowable expected value for ignoresThrowable().
- * @param expectedHeader expected value for getHeader().
- * @param expectedFooter expected value for getFooter().
- */
- protected DateLayoutTest(
- final String testName,
- final String expectedContentType,
- final boolean expectedIgnoresThrowable,
- final String expectedHeader,
- final String expectedFooter) {
- super(testName, expectedContentType, expectedIgnoresThrowable, expectedHeader, expectedFooter);
- }
-
- /**
- * {@inheritDoc}
- */
- protected Layout createLayout() {
- return new MockLayout();
- }
-
- /**
- * Tests DateLayout.NULL_DATE_FORMAT constant.
- */
- public void testNullDateFormat() {
- assertEquals("NULL", DateLayout.NULL_DATE_FORMAT);
- }
-
- /**
- * Tests DateLayout.RELATIVE constant.
- */
- public void testRelativeTimeDateFormat() {
- assertEquals("RELATIVE", DateLayout.RELATIVE_TIME_DATE_FORMAT);
- }
-
- /**
- * Tests DateLayout.DATE_FORMAT_OPTION constant.
- *
- * @deprecated since constant is deprecated
- */
- public void testDateFormatOption() {
- assertEquals("DateFormat", DateLayout.DATE_FORMAT_OPTION);
- }
-
- /**
- * Tests DateLayout.TIMEZONE_OPTION constant.
- *
- * @deprecated since constant is deprecated
- */
- public void testTimeZoneOption() {
- assertEquals("TimeZone", DateLayout.TIMEZONE_OPTION);
- }
-
- /**
- * Tests getOptionStrings().
- *
- * @deprecated since getOptionStrings is deprecated.
- *
- */
- public void testGetOptionStrings() {
- final String[] options = ((DateLayout) createLayout()).getOptionStrings();
- assertEquals(2, options.length);
- }
-
- /**
- * Tests setting DateFormat through setOption method.
- *
- * @deprecated since setOption is deprecated.
- */
- public void testSetOptionDateFormat() {
- final DateLayout layout = (DateLayout) createLayout();
- layout.setOption("dAtefOrmat", "foobar");
- assertEquals("FOOBAR", layout.getDateFormat());
- }
-
- /**
- * Tests setting TimeZone through setOption method.
- *
- * @deprecated since setOption is deprecated.
- */
- public void testSetOptionTimeZone() {
- final DateLayout layout = (DateLayout) createLayout();
- layout.setOption("tImezOne", "+05:00");
- assertEquals("+05:00", layout.getTimeZone());
- }
-
- /**
- * Tests setDateFormat.
- */
- public void testSetDateFormat() {
- final DateLayout layout = (DateLayout) createLayout();
- layout.setDateFormat("ABSOLUTE");
- assertEquals("ABSOLUTE", layout.getDateFormat());
- }
-
- /**
- * Tests setTimeZone.
- */
- public void testSetTimeZone() {
- final DateLayout layout = (DateLayout) createLayout();
- layout.setTimeZone("+05:00");
- assertEquals("+05:00", layout.getTimeZone());
- }
-
- /**
- * Tests 2 parameter setDateFormat with null.
- */
- public void testSetDateFormatNull() {
- final DateLayout layout = (DateLayout) createLayout();
- layout.setDateFormat((String) null, null);
- }
-
- /**
- * Tests 2 parameter setDateFormat with "NULL".
- */
- public void testSetDateFormatNullString() {
- final DateLayout layout = (DateLayout) createLayout();
- layout.setDateFormat("NuLL", null);
- }
-
- /**
- * Tests 2 parameter setDateFormat with "RELATIVE".
- */
- public void testSetDateFormatRelative() {
- final DateLayout layout = (DateLayout) createLayout();
- layout.setDateFormat("rElatIve", TimeZone.getDefault());
- }
-
- /**
- * Tests 2 parameter setDateFormat with "ABSOLUTE".
- */
- public void testSetDateFormatAbsolute() {
- final DateLayout layout = (DateLayout) createLayout();
- layout.setDateFormat("aBsolUte", TimeZone.getDefault());
- }
-
- /**
- * Tests 2 parameter setDateFormat with "DATETIME".
- */
- public void testSetDateFormatDateTime() {
- final DateLayout layout = (DateLayout) createLayout();
- layout.setDateFormat("dAte", TimeZone.getDefault());
- }
-
- /**
- * Tests 2 parameter setDateFormat with "ISO8601".
- */
- public void testSetDateFormatISO8601() {
- final DateLayout layout = (DateLayout) createLayout();
- layout.setDateFormat("iSo8601", TimeZone.getDefault());
- }
-
- /**
- * Tests 2 parameter setDateFormat with "HH:mm:ss".
- */
- public void testSetDateFormatSimple() {
- final DateLayout layout = (DateLayout) createLayout();
- layout.setDateFormat("HH:mm:ss", TimeZone.getDefault());
- }
-
- /**
- * Tests activateOptions.
- */
- public void testActivateOptions() {
- final DateLayout layout = (DateLayout) createLayout();
- layout.setDateFormat("HH:mm:ss");
- layout.setTimeZone("+05:00");
- layout.activateOptions();
- }
-
- /**
- * Tests setDateFormat(DateFormat, TimeZone).
- */
- public void testSetDateFormatWithFormat() {
- final DateFormat format = new SimpleDateFormat("HH:mm");
- final DateLayout layout = (DateLayout) createLayout();
- layout.setDateFormat(format, TimeZone.getDefault());
- }
-
- /**
- * Tests IS08601DateFormat class.
- *
- * @deprecated since ISO8601DateFormat is deprecated
- */
- public void testISO8601Format() {
- final DateFormat format = new ISO8601DateFormat();
- final Calendar calendar = Calendar.getInstance();
- calendar.clear();
- calendar.set(1970, 0, 1, 0, 0, 0);
- final String actual = format.format(calendar.getTime());
- assertEquals("1970-01-01 00:00:00,000", actual);
- }
-
- /**
- * Tests DateTimeDateFormat class.
- *
- * @deprecated since DateTimeDateFormat is deprecated
- */
- public void testDateTimeFormat() {
- final DateFormat format = new DateTimeDateFormat();
- final Calendar calendar = Calendar.getInstance();
- calendar.clear();
- calendar.set(1970, 0, 1, 0, 0, 0);
- final String actual = format.format(calendar.getTime());
- final SimpleDateFormat df = new SimpleDateFormat("dd MMM yyyy HH:mm:ss,SSS");
- final String expected = df.format(calendar.getTime());
- assertEquals(expected, actual);
- }
-
- /**
- * Concrete Layout class for tests.
- */
- private static final class MockLayout extends DateLayout {
- /**
- * Create new instance of MockLayout.
- */
- public MockLayout() {
- //
- // checks that protected fields are properly initialized
- assertNotNull(pos);
- assertNotNull(date);
- assertNull(dateFormat);
- }
-
- /**
- * {@inheritDoc}
- */
- public String format(final LoggingEvent event) {
- return "Mock";
- }
-
- /**
- * {@inheritDoc}
- */
- public void activateOptions() {}
-
- /**
- * {@inheritDoc}
- */
- public boolean ignoresThrowable() {
- return true;
- }
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/LogLogTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/LogLogTest.java
deleted file mode 100644
index f852023fe59..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/LogLogTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.helpers;
-
-import junit.framework.TestCase;
-
-/**
- * Tests {@link LogLog}.
- */
-public class LogLogTest extends TestCase {
-
- /**
- * Create new instance of LogLogTest.
- *
- * @param testName test name
- */
- public LogLogTest(final String testName) {
- super(testName);
- }
-
- /**
- * Check value of CONFIG_DEBUG_KEY.
- *
- * @deprecated since constant is deprecated
- */
- @Deprecated
- public void testConfigDebugKey() {
- assertEquals("log4j.configDebug", LogLog.CONFIG_DEBUG_KEY);
- }
-
- /**
- * Check value of DEBUG_KEY.
- */
- public void testDebugKey() {
- assertEquals("log4j.debug", LogLog.DEBUG_KEY);
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/OptionConverterLevelTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/OptionConverterLevelTest.java
deleted file mode 100644
index 70375621260..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/OptionConverterLevelTest.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.helpers;
-
-import static org.apache.log4j.helpers.OptionConverter.toLog4j1Level;
-import static org.apache.log4j.helpers.OptionConverter.toLog4j2Level;
-import static org.junit.Assert.assertNull;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-import java.util.Arrays;
-import java.util.stream.Stream;
-import org.apache.log4j.Level;
-import org.apache.log4j.Priority;
-import org.apache.log4j.bridge.LogEventAdapter;
-import org.apache.logging.log4j.spi.StandardLevel;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.Arguments;
-import org.junit.jupiter.params.provider.MethodSource;
-
-public class OptionConverterLevelTest {
-
- static Stream standardLevels() {
- return Arrays.stream(StandardLevel.values())
- .map(Enum::name)
- .map(name -> Arguments.of(Level.toLevel(name), org.apache.logging.log4j.Level.toLevel(name)));
- }
-
- /**
- * Test if the standard levels are transformed correctly.
- *
- * @param log4j1Level
- * @param log4j2Level
- */
- @ParameterizedTest
- @MethodSource("standardLevels")
- public void testStandardLevelConversion(final Level log4j1Level, final org.apache.logging.log4j.Level log4j2Level) {
- assertEquals(log4j2Level, OptionConverter.convertLevel(log4j1Level));
- assertEquals(log4j1Level, OptionConverter.convertLevel(log4j2Level));
- }
-
- /**
- * Test if the conversion works at an integer level.
- *
- * @param log4j1Level
- * @param log4j2Level
- */
- @ParameterizedTest
- @MethodSource("standardLevels")
- public void testStandardIntLevelConversion(
- final Level log4j1Level, final org.apache.logging.log4j.Level log4j2Level) {
- assertEquals(log4j2Level.intLevel(), toLog4j2Level(log4j1Level.toInt()));
- assertEquals(log4j1Level.toInt(), toLog4j1Level(log4j2Level.intLevel()));
- }
-
- @Test
- public void testMaxMinCutoff() {
- // The cutoff values are transformed into ALL and OFF
- assertEquals(StandardLevel.ALL.intLevel(), toLog4j2Level(OptionConverter.MIN_CUTOFF_LEVEL));
- assertEquals(StandardLevel.OFF.intLevel(), toLog4j2Level(OptionConverter.MAX_CUTOFF_LEVEL));
- // Maximal and minimal Log4j 1.x values different from ALL or OFF
- int minTransformed = toLog4j1Level(toLog4j2Level(OptionConverter.MIN_CUTOFF_LEVEL + 1));
- assertEquals(OptionConverter.MIN_CUTOFF_LEVEL + 1, minTransformed);
- int maxTransformed = toLog4j1Level(toLog4j2Level(OptionConverter.MAX_CUTOFF_LEVEL - 1));
- assertEquals(OptionConverter.MAX_CUTOFF_LEVEL - 1, maxTransformed);
- // Maximal and minimal Log4j 2.x value different from ALL or OFF
- minTransformed = toLog4j2Level(toLog4j1Level(StandardLevel.OFF.intLevel() + 1));
- assertEquals(StandardLevel.OFF.intLevel() + 1, minTransformed);
- maxTransformed = toLog4j2Level(toLog4j1Level(StandardLevel.ALL.intLevel() - 1));
- assertEquals(StandardLevel.ALL.intLevel() - 1, maxTransformed);
- }
-
- /**
- * Test if the values in at least the TRACE to FATAL range are transformed
- * correctly.
- */
- @Test
- public void testUsefulRange() {
- for (int intLevel = StandardLevel.OFF.intLevel(); intLevel <= StandardLevel.TRACE.intLevel(); intLevel++) {
- assertEquals(intLevel, toLog4j2Level(toLog4j1Level(intLevel)));
- }
- for (int intLevel = Level.TRACE_INT; intLevel < OptionConverter.MAX_CUTOFF_LEVEL; intLevel = intLevel + 100) {
- assertEquals(intLevel, toLog4j1Level(toLog4j2Level(intLevel)));
- }
- }
-
- /**
- * Levels defined in Log4j 2.x should have an equivalent in Log4j 1.x. Those are
- * used in {@link LogEventAdapter}.
- */
- @Test
- public void testCustomLog4j2Levels() {
- final int infoDebug = (StandardLevel.INFO.intLevel() + StandardLevel.DEBUG.intLevel()) / 2;
- final org.apache.logging.log4j.Level v2Level = org.apache.logging.log4j.Level.forName("INFO_DEBUG", infoDebug);
- final Level v1Level =
- OptionConverter.toLevel("INFO_DEBUG#" + org.apache.logging.log4j.Level.class.getName(), null);
- assertNotNull(v1Level);
- assertEquals(v2Level, v1Level.getVersion2Level());
- final int expectedLevel = (Priority.INFO_INT + Priority.DEBUG_INT) / 2;
- assertEquals(expectedLevel, v1Level.toInt());
- // convertLevel
- assertEquals(v1Level, OptionConverter.convertLevel(v2Level));
- // Non-existent level
- assertNull(OptionConverter.toLevel("WARN_INFO#" + org.apache.logging.log4j.Level.class.getName(), null));
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/UtilLoggingLevelTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/UtilLoggingLevelTest.java
deleted file mode 100644
index a21ed6278b5..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/helpers/UtilLoggingLevelTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.helpers;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import java.util.stream.Stream;
-import org.apache.log4j.Level;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.Arguments;
-import org.junit.jupiter.params.provider.MethodSource;
-
-/**
- * Unit tests for UtilLoggingLevel.
- */
-public class UtilLoggingLevelTest {
-
- /**
- * Test toLevel("fiNeSt").
- */
- public void testToLevelFINEST() {
- assertEquals(UtilLoggingLevel.FINEST, UtilLoggingLevel.toLevel("fiNeSt"));
- }
-
- static Stream namesAndLevels() {
- return UtilLoggingLevel.getAllPossibleLevels().stream()
- .map(level -> Arguments.of(level.toString() + "#" + UtilLoggingLevel.class.getName(), level));
- }
-
- @ParameterizedTest
- @MethodSource("namesAndLevels")
- public void testOptionConverterToLevel(final String name, final UtilLoggingLevel level) {
- assertTrue(level == OptionConverter.toLevel(name, Level.ALL), "get v1 level by name");
- // Comparison of Log4j 2.x levels
- assertTrue(level.getVersion2Level() == org.apache.logging.log4j.Level.getLevel(name), "get v2 level by name");
- // Test convertLevel
- assertTrue(level == OptionConverter.convertLevel(level.getVersion2Level()), "convert level v2 -> v1");
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/layout/Log4j1SyslogLayoutTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/layout/Log4j1SyslogLayoutTest.java
deleted file mode 100644
index ce3689f9dd1..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/layout/Log4j1SyslogLayoutTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.layout;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.util.stream.Stream;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.StringLayout;
-import org.apache.logging.log4j.core.config.DefaultConfiguration;
-import org.apache.logging.log4j.core.layout.PatternLayout;
-import org.apache.logging.log4j.core.net.Facility;
-import org.apache.logging.log4j.core.time.MutableInstant;
-import org.apache.logging.log4j.core.util.NetUtils;
-import org.apache.logging.log4j.message.SimpleMessage;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.Arguments;
-import org.junit.jupiter.params.provider.MethodSource;
-
-public class Log4j1SyslogLayoutTest {
-
- private static final SimpleMessage MESSAGE = new SimpleMessage("Hello world!");
- private static final long TIMESTAMP = LocalDateTime.of(2022, 4, 5, 12, 34, 56)
- .atZone(ZoneId.systemDefault())
- .toEpochSecond();
- private static final String localhostName = NetUtils.getLocalHostname();
-
- private static LogEvent createLogEvent() {
- final MutableInstant instant = new MutableInstant();
- instant.initFromEpochSecond(TIMESTAMP, 0);
- final LogEvent event = mock(LogEvent.class);
- when(event.getInstant()).thenReturn(instant);
- when(event.getMessage()).thenReturn(MESSAGE);
- when(event.getLevel()).thenReturn(Level.INFO);
- return event;
- }
-
- static Stream configurations() {
- return Stream.of(
- Arguments.of("<30>Hello world!", Facility.DAEMON, false, false),
- Arguments.of("<30>Apr 5 12:34:56 %s Hello world!", Facility.DAEMON, true, false),
- Arguments.of("<30>daemon:Hello world!", Facility.DAEMON, false, true),
- Arguments.of("<30>Apr 5 12:34:56 %s daemon:Hello world!", Facility.DAEMON, true, true))
- .map(args -> {
- final Object[] objs = args.get();
- objs[0] = String.format((String) objs[0], localhostName);
- return Arguments.of(objs);
- });
- }
-
- @ParameterizedTest
- @MethodSource("configurations")
- public void testSimpleLayout(
- final String expected, final Facility facility, final boolean header, final boolean facilityPrinting) {
- final LogEvent logEvent = createLogEvent();
- StringLayout appenderLayout = Log4j1SyslogLayout.newBuilder()
- .setConfiguration(new DefaultConfiguration())
- .setFacility(facility)
- .setHeader(header)
- .setFacilityPrinting(facilityPrinting)
- .build();
- assertEquals(expected, appenderLayout.toSerializable(logEvent));
- final StringLayout messageLayout = PatternLayout.newBuilder()
- .setConfiguration(new DefaultConfiguration())
- .setPattern("%m")
- .build();
- appenderLayout = Log4j1SyslogLayout.newBuilder()
- .setConfiguration(new DefaultConfiguration())
- .setFacility(facility)
- .setHeader(header)
- .setFacilityPrinting(facilityPrinting)
- .setMessageLayout(messageLayout)
- .build();
- assertEquals(expected, appenderLayout.toSerializable(logEvent));
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/layout/Log4j1XmlLayoutTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/layout/Log4j1XmlLayoutTest.java
deleted file mode 100644
index 159331bbbcd..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/layout/Log4j1XmlLayoutTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.layout;
-
-import static org.junit.Assert.assertEquals;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.config.DefaultConfiguration;
-import org.apache.logging.log4j.core.impl.ContextDataFactory;
-import org.apache.logging.log4j.core.impl.Log4jLogEvent;
-import org.apache.logging.log4j.message.SimpleMessage;
-import org.apache.logging.log4j.test.junit.ThreadContextRule;
-import org.apache.logging.log4j.util.StringMap;
-import org.junit.Rule;
-import org.junit.Test;
-
-public class Log4j1XmlLayoutTest {
-
- @Rule
- public ThreadContextRule threadContextRule = new ThreadContextRule();
-
- @Test
- public void testWithoutThrown() {
- final Log4j1XmlLayout layout = Log4j1XmlLayout.createLayout(new DefaultConfiguration(), false, true);
-
- final Log4jLogEvent event = Log4jLogEvent.newBuilder()
- .setLoggerName("a.B")
- .setLevel(Level.INFO)
- .setMessage(new SimpleMessage("Hello, World"))
- .setTimeMillis(System.currentTimeMillis() + 17)
- .build();
-
- final String result = layout.toSerializable(event);
-
- final String expected = "\r\n"
- + " \r\n"
- + " \r\n\r\n";
-
- assertEquals(expected, result);
- }
-
- @Test
- public void testWithPropertiesAndLocationInfo() {
- final Log4j1XmlLayout layout = Log4j1XmlLayout.createLayout(new DefaultConfiguration(), true, true);
-
- final StringMap contextMap = ContextDataFactory.createContextData(2);
- contextMap.putValue("key1", "value1");
- contextMap.putValue("key2", "value2");
- final Log4jLogEvent event = Log4jLogEvent.newBuilder()
- .setLoggerName("a.B")
- .setLevel(Level.INFO)
- .setMessage(new SimpleMessage("Hello, World"))
- .setTimeMillis(System.currentTimeMillis() + 17)
- .setIncludeLocation(true)
- .setSource(new StackTraceElement("pack.MyClass", "myMethod", "MyClass.java", 17))
- .setContextData(contextMap)
- .build();
-
- final String result = layout.toSerializable(event);
-
- final String expected = "\r\n"
- + " \r\n"
- + "\r\n"
- + "\r\n"
- + "\r\n"
- + "\r\n"
- + " \r\n"
- + " \r\n\r\n";
-
- assertEquals(expected, result);
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/FormattingInfoTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/FormattingInfoTest.java
deleted file mode 100644
index 529220966e3..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/FormattingInfoTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.pattern;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for FormattingInfo.
- *
- * @author Curt Arnold
- *
- */
-public class FormattingInfoTest extends TestCase {
- /**
- * Create a new instance.
- *
- * @param name test name
- */
- public FormattingInfoTest(final String name) {
- super(name);
- }
-
- /**
- * Check constructor
- *
- */
- public void testConstructor() {
- final FormattingInfo field = new FormattingInfo(true, 3, 6);
- assertNotNull(field);
- assertEquals(3, field.getMinLength());
- assertEquals(6, field.getMaxLength());
- assertEquals(true, field.isLeftAligned());
- }
-
- /**
- * Check that getDefault does not return null.
- *
- */
- public void testGetDefault() {
- final FormattingInfo field = FormattingInfo.getDefault();
- assertNotNull(field);
- assertEquals(0, field.getMinLength());
- assertEquals(Integer.MAX_VALUE, field.getMaxLength());
- assertEquals(false, field.isLeftAligned());
- }
-
- /**
- * Add padding to left since field is not minimum width.
- */
- public void testPadLeft() {
- final StringBuffer buf = new StringBuffer("foobar");
- final FormattingInfo field = new FormattingInfo(false, 5, 10);
- field.format(2, buf);
- assertEquals("fo obar", buf.toString());
- }
-
- /**
- * Add padding to right since field is not minimum width.
- */
- public void testPadRight() {
- final StringBuffer buf = new StringBuffer("foobar");
- final FormattingInfo field = new FormattingInfo(true, 5, 10);
- field.format(2, buf);
- assertEquals("foobar ", buf.toString());
- }
-
- /**
- * Field exceeds maximum width
- */
- public void testTruncate() {
- final StringBuffer buf = new StringBuffer("foobar");
- final FormattingInfo field = new FormattingInfo(true, 0, 3);
- field.format(2, buf);
- assertEquals("fobar", buf.toString());
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/Log4j1LevelPatternConverterTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/Log4j1LevelPatternConverterTest.java
deleted file mode 100644
index 4170859d7fb..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/Log4j1LevelPatternConverterTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.pattern;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import org.apache.log4j.Level;
-import org.apache.logging.log4j.core.LogEvent;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.MethodSource;
-
-public class Log4j1LevelPatternConverterTest {
-
- /**
- * Tests if the converter returns the Log4j 1.x {@code toString()} value of
- * custom Log4j 1.x levels.
- *
- * @param level a Log4j 1.x level
- */
- @ParameterizedTest
- @MethodSource("org.apache.log4j.helpers.UtilLoggingLevel#getAllPossibleLevels")
- public void testUtilLoggingLevels(final Level level) {
- final Log4j1LevelPatternConverter converter = Log4j1LevelPatternConverter.newInstance(null);
- final LogEvent logEvent = mock(LogEvent.class);
- when(logEvent.getLevel()).thenReturn(level.getVersion2Level());
- final StringBuilder result = new StringBuilder();
- converter.format(logEvent, result);
- assertEquals(level.toString(), result.toString());
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/Log4j1MdcPatternConverterTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/Log4j1MdcPatternConverterTest.java
deleted file mode 100644
index 54da237b3f9..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/Log4j1MdcPatternConverterTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.pattern;
-
-import static org.junit.Assert.assertEquals;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.impl.ContextDataFactory;
-import org.apache.logging.log4j.core.impl.Log4jLogEvent;
-import org.apache.logging.log4j.message.SimpleMessage;
-import org.apache.logging.log4j.util.StringMap;
-import org.junit.Test;
-
-public class Log4j1MdcPatternConverterTest {
-
- @Test
- public void testConverter0() {
- final StringMap contextMap = ContextDataFactory.createContextData(0);
- final String expected = "{}";
- test(contextMap, expected, null);
- }
-
- @Test
- public void testConverter1() {
- final StringMap contextMap = ContextDataFactory.createContextData(1);
- contextMap.putValue("key1", "value1");
- final String expected = "{{key1,value1}}";
- test(contextMap, expected, null);
- }
-
- @Test
- public void testConverter2() {
- final StringMap contextMap = ContextDataFactory.createContextData(2);
- contextMap.putValue("key1", "value1");
- contextMap.putValue("key2", "value2");
- final String expected = "{{key1,value1}{key2,value2}}";
- test(contextMap, expected, null);
- }
-
- @Test
- public void testConverterWithKey() {
- final StringMap contextMap = ContextDataFactory.createContextData(2);
- contextMap.putValue("key1", "value1");
- contextMap.putValue("key2", "value2");
- final String expected = "value1";
- test(contextMap, expected, new String[] {"key1"});
- }
-
- private void test(final StringMap contextMap, final String expected, final String[] options) {
- final LogEvent event = Log4jLogEvent.newBuilder()
- .setLoggerName("MyLogger")
- .setLevel(Level.DEBUG)
- .setMessage(new SimpleMessage("Hello"))
- .setContextData(contextMap)
- .build();
- final StringBuilder sb = new StringBuilder();
- final Log4j1MdcPatternConverter converter = Log4j1MdcPatternConverter.newInstance(options);
- converter.format(event, sb);
- assertEquals(expected, sb.toString());
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/Log4j1NdcPatternConverterTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/Log4j1NdcPatternConverterTest.java
deleted file mode 100644
index ca76974e16f..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/Log4j1NdcPatternConverterTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.pattern;
-
-import static org.junit.Assert.assertEquals;
-
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.ThreadContext;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.impl.Log4jLogEvent;
-import org.apache.logging.log4j.message.SimpleMessage;
-import org.apache.logging.log4j.test.junit.ThreadContextStackRule;
-import org.junit.Rule;
-import org.junit.Test;
-
-public class Log4j1NdcPatternConverterTest {
-
- @Rule
- public final ThreadContextStackRule threadContextRule = new ThreadContextStackRule();
-
- @Test
- public void testEmpty() {
- testConverter("");
- }
-
- @Test
- public void test1() {
- ThreadContext.push("foo");
- testConverter("foo");
- }
-
- @Test
- public void test2() {
- ThreadContext.push("foo");
- ThreadContext.push("bar");
- testConverter("foo bar");
- }
-
- @Test
- public void test3() {
- ThreadContext.push("foo");
- ThreadContext.push("bar");
- ThreadContext.push("baz");
- testConverter("foo bar baz");
- }
-
- private void testConverter(final String expected) {
- final Log4j1NdcPatternConverter converter = Log4j1NdcPatternConverter.newInstance(null);
- final LogEvent event = Log4jLogEvent.newBuilder()
- .setLoggerName("MyLogger")
- .setLevel(Level.DEBUG)
- .setMessage(new SimpleMessage("Hello"))
- .build();
- final StringBuilder sb = new StringBuilder();
- converter.format(event, sb);
- assertEquals(expected, sb.toString());
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/NameAbbreviatorTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/NameAbbreviatorTest.java
deleted file mode 100644
index d051581f38c..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/pattern/NameAbbreviatorTest.java
+++ /dev/null
@@ -1,326 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.pattern;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for NameAbbrevator.
- *
- */
-public class NameAbbreviatorTest extends TestCase {
- /**
- * Create a new instance.
- *
- * @param name test name
- */
- public NameAbbreviatorTest(final String name) {
- super(name);
- }
-
- /**
- * Check that getAbbreviator(" ") returns default abbreviator.
- *
- */
- public void testBlank() {
- final NameAbbreviator abbrev = NameAbbreviator.getAbbreviator(" ");
- final NameAbbreviator defaultAbbrev = NameAbbreviator.getDefaultAbbreviator();
- assertTrue(abbrev == defaultAbbrev);
- }
-
- /**
- * Check that blanks are trimmed in evaluating abbreviation pattern.
- */
- public void testBlankOne() {
- final NameAbbreviator abbrev = NameAbbreviator.getAbbreviator(" 1 ");
- final StringBuffer buf = new StringBuffer("DEBUG - ");
- int fieldStart = buf.length();
- buf.append("org.example.foo.bar");
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - bar", buf.toString());
-
- buf.setLength(0);
- buf.append("DEBUG - ");
- fieldStart = buf.length();
- buf.append("bar");
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - bar", buf.toString());
-
- buf.setLength(0);
- buf.append("DEBUG - ");
- fieldStart = buf.length();
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - ", buf.toString());
- }
-
- /**
- * Check that getDefaultAbbreviator does not return null.
- *
- */
- public void testGetDefault() {
- final NameAbbreviator abbrev = NameAbbreviator.getDefaultAbbreviator();
- assertNotNull(abbrev);
- }
-
- /**
- * Check that getAbbreviator("-1").abbreviate() drops first name element.
- *
- */
- public void testMinusOne() {
- final NameAbbreviator abbrev = NameAbbreviator.getAbbreviator("-1");
- final StringBuffer buf = new StringBuffer("DEBUG - ");
- int fieldStart = buf.length();
- buf.append("org.example.foo.bar");
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - example.foo.bar", buf.toString());
-
- buf.setLength(0);
- buf.append("DEBUG - ");
- fieldStart = buf.length();
- buf.append("bar");
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - bar", buf.toString());
-
- buf.setLength(0);
- buf.append("DEBUG - ");
- fieldStart = buf.length();
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - ", buf.toString());
-
- buf.setLength(0);
- buf.append("DEBUG - ");
- fieldStart = buf.length();
- buf.append(".");
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - ", buf.toString());
- }
-
- /**
- * Check that getAbbreviator("1.*.2").abbreviate drops all but the first character from the first element, uses all of
- * the second element and drops all but the first two characters of the rest of the non-final elements.
- *
- */
- public void testMulti() {
- final NameAbbreviator abbrev = NameAbbreviator.getAbbreviator("1.*.2");
- final StringBuffer buf = new StringBuffer("DEBUG - ");
- int fieldStart = buf.length();
- buf.append("org.example.foo.bar");
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - o.example.fo.bar", buf.toString());
-
- buf.setLength(0);
- buf.append("DEBUG - ");
- fieldStart = buf.length();
- buf.append("org.example.foo.");
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - o.example.fo.", buf.toString());
-
- buf.setLength(0);
- buf.append("DEBUG - ");
- fieldStart = buf.length();
- buf.append("foo.bar");
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - f.bar", buf.toString());
-
- buf.setLength(0);
- buf.append("DEBUG - ");
- fieldStart = buf.length();
- buf.append("bar");
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - bar", buf.toString());
-
- buf.setLength(0);
- buf.append("DEBUG - ");
- fieldStart = buf.length();
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - ", buf.toString());
-
- buf.setLength(0);
- buf.append("DEBUG - ");
- fieldStart = buf.length();
- buf.append(".");
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - .", buf.toString());
- }
-
- /**
- * Check that getAbbreviator("1").abbreviate() drops all but the final name element.
- *
- */
- public void testOne() {
- final NameAbbreviator abbrev = NameAbbreviator.getAbbreviator("1");
- final StringBuffer buf = new StringBuffer("DEBUG - ");
- int fieldStart = buf.length();
- buf.append("org.example.foo.bar");
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - bar", buf.toString());
-
- buf.setLength(0);
- buf.append("DEBUG - ");
- fieldStart = buf.length();
- buf.append("bar");
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - bar", buf.toString());
-
- buf.setLength(0);
- buf.append("DEBUG - ");
- fieldStart = buf.length();
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - ", buf.toString());
- }
-
- /**
- * Check that getAbbreviator("1.").abbreviate abbreviates non-final elements to one character.
- *
- */
- public void testOneDot() {
- final NameAbbreviator abbrev = NameAbbreviator.getAbbreviator("1.");
- final StringBuffer buf = new StringBuffer("DEBUG - ");
- int fieldStart = buf.length();
- buf.append("org.example.foo.bar");
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - o.e.f.bar", buf.toString());
-
- buf.setLength(0);
- buf.append("DEBUG - ");
- fieldStart = buf.length();
- buf.append("org.example.foo.");
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - o.e.f.", buf.toString());
-
- buf.setLength(0);
- buf.append("DEBUG - ");
- fieldStart = buf.length();
- buf.append("foo.bar");
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - f.bar", buf.toString());
-
- buf.setLength(0);
- buf.append("DEBUG - ");
- fieldStart = buf.length();
- buf.append("bar");
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - bar", buf.toString());
-
- buf.setLength(0);
- buf.append("DEBUG - ");
- fieldStart = buf.length();
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - ", buf.toString());
-
- buf.setLength(0);
- buf.append("DEBUG - ");
- fieldStart = buf.length();
- buf.append(".");
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - .", buf.toString());
- }
-
- /**
- * Check that getAbbreviator("1~.").abbreviate abbreviates non-final elements to one character and a tilde.
- *
- */
- public void testOneTildeDot() {
- final NameAbbreviator abbrev = NameAbbreviator.getAbbreviator("1~.");
- final StringBuffer buf = new StringBuffer("DEBUG - ");
- int fieldStart = buf.length();
- buf.append("org.example.foo.bar");
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - o~.e~.f~.bar", buf.toString());
-
- buf.setLength(0);
- buf.append("DEBUG - ");
- fieldStart = buf.length();
- buf.append("org.example.foo.");
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - o~.e~.f~.", buf.toString());
-
- buf.setLength(0);
- buf.append("DEBUG - ");
- fieldStart = buf.length();
- buf.append("foo.bar");
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - f~.bar", buf.toString());
-
- buf.setLength(0);
- buf.append("DEBUG - ");
- fieldStart = buf.length();
- buf.append("bar");
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - bar", buf.toString());
-
- buf.setLength(0);
- buf.append("DEBUG - ");
- fieldStart = buf.length();
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - ", buf.toString());
-
- buf.setLength(0);
- buf.append("DEBUG - ");
- fieldStart = buf.length();
- buf.append(".");
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - .", buf.toString());
-
- buf.setLength(0);
- buf.append("DEBUG - ");
- fieldStart = buf.length();
- buf.append("o.e.f.bar");
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - o.e.f.bar", buf.toString());
- }
-
- /**
- * Check that getAbbreviator("2").abbreviate drops all but the last two elements.
- *
- */
- public void testTwo() {
- final NameAbbreviator abbrev = NameAbbreviator.getAbbreviator("2");
- final StringBuffer buf = new StringBuffer("DEBUG - ");
- int fieldStart = buf.length();
- buf.append("org.example.foo.bar");
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - foo.bar", buf.toString());
-
- buf.setLength(0);
- buf.append("DEBUG - ");
- fieldStart = buf.length();
- buf.append("foo.bar");
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - foo.bar", buf.toString());
-
- buf.setLength(0);
- buf.append("DEBUG - ");
- fieldStart = buf.length();
- buf.append("bar");
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - bar", buf.toString());
- }
-
- /**
- * Check that "0" drops all name content.
- *
- */
- public void testZero() {
- final NameAbbreviator abbrev = NameAbbreviator.getAbbreviator("0");
- final StringBuffer buf = new StringBuffer("DEBUG - ");
- final int fieldStart = buf.length();
- buf.append("org.example.foo.bar");
- abbrev.abbreviate(fieldStart, buf);
- assertEquals("DEBUG - ", buf.toString());
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/spi/LocationInfoTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/spi/LocationInfoTest.java
deleted file mode 100644
index 0679424cc63..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/spi/LocationInfoTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.spi;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for LocationInfo.
- */
-public class LocationInfoTest extends TestCase {
-
- /**
- * Tests four parameter constructor.
- */
- public void testFourParamConstructor() {
- final String className = LocationInfoTest.class.getName();
- final String methodName = "testFourParamConstructor";
- final String fileName = "LocationInfoTest.java";
- final String lineNumber = "41";
- final LocationInfo li = new LocationInfo(fileName, className, methodName, lineNumber);
- assertEquals(className, li.getClassName());
- assertEquals(methodName, li.getMethodName());
- assertEquals(fileName, li.getFileName());
- assertEquals(lineNumber, li.getLineNumber());
- assertEquals(className + "." + methodName + "(" + fileName + ":" + lineNumber + ")", li.fullInfo);
- }
-
- /**
- * Class with name that is a substring of its caller.
- */
- private static class NameSubstring {
- /**
- * Construct a LocationInfo. Location should be immediate caller of this method.
- *
- * @return location info.
- */
- public static LocationInfo getInfo() {
- return new LocationInfo(new Throwable(), NameSubstring.class.getName());
- }
- }
-
- /**
- * Class whose name is contains the name of the class that obtains the LocationInfo.
- */
- private static class NameSubstringCaller {
- /**
- * Construct a locationInfo. Location should be this location.
- *
- * @return location info.
- */
- public static LocationInfo getInfo() {
- return NameSubstring.getInfo();
- }
- }
-
- /**
- * Tests creation of location info when the logger class name is a substring of one of the other classes in the stack
- * trace. See bug 44888.
- */
- public void testLocationInfo() {
- final LocationInfo li = NameSubstringCaller.getInfo();
- assertEquals(NameSubstringCaller.class.getName(), li.getClassName());
- assertEquals("getInfo", li.getMethodName());
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/spi/ThrowableInformationTest.java b/log4j-1.2-api/src/test/java/org/apache/log4j/spi/ThrowableInformationTest.java
deleted file mode 100644
index 36e25538418..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/spi/ThrowableInformationTest.java
+++ /dev/null
@@ -1,329 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.spi;
-
-import java.io.PrintWriter;
-import junit.framework.TestCase;
-
-/**
- * Tests {@link ThrowableInformation}.
- */
-public class ThrowableInformationTest extends TestCase {
-
- /**
- * Create ThrowableInformationTest.
- *
- * @param name test name.
- */
- public ThrowableInformationTest(final String name) {
- super(name);
- }
-
- /**
- * Custom throwable that only calls methods overridden by VectorWriter in log4j 1.2.14 and earlier.
- */
- private static final class OverriddenThrowable extends Throwable {
- private static final long serialVersionUID = 1L;
-
- /**
- * Create new instance.
- */
- public OverriddenThrowable() {}
-
- /**
- * Print stack trace.
- *
- * @param s print writer.
- */
- public void printStackTrace(final PrintWriter s) {
- s.print((Object) "print(Object)");
- s.print("print(char[])".toCharArray());
- s.print("print(String)");
- s.println((Object) "println(Object)");
- s.println("println(char[])".toCharArray());
- s.println("println(String)");
- s.write("write(char[])".toCharArray());
- s.write("write(char[], int, int)".toCharArray(), 2, 8);
- s.write("write(String, int, int)", 2, 8);
- }
- }
-
- /**
- * Test capturing stack trace from a throwable that only uses the PrintWriter methods overridden in log4j 1.2.14 and
- * earlier.
- */
- public void testOverriddenBehavior() {
- final ThrowableInformation ti = new ThrowableInformation(new OverriddenThrowable());
- final String[] rep = ti.getThrowableStrRep();
- assertEquals(4, rep.length);
- assertEquals("print(Object)print(char[])print(String)println(Object)", rep[0]);
- assertEquals("println(char[])", rep[1]);
- assertEquals("println(String)", rep[2]);
- assertEquals("write(char[])ite(charite(Stri", rep[3]);
- }
-
- /**
- * Custom throwable that calls methods not overridden by VectorWriter in log4j 1.2.14 and earlier.
- */
- private static final class NotOverriddenThrowable extends Throwable {
- private static final long serialVersionUID = 1L;
-
- /**
- * Create new instance.
- */
- public NotOverriddenThrowable() {}
-
- /**
- * Print stack trace.
- *
- * @param s print writer.
- */
- public void printStackTrace(final PrintWriter s) {
- s.print(true);
- s.print('a');
- s.print(1);
- s.print(2L);
- s.print(Float.MAX_VALUE);
- s.print(Double.MIN_VALUE);
- s.println(true);
- s.println('a');
- s.println(1);
- s.println(2L);
- s.println(Float.MAX_VALUE);
- s.println(Double.MIN_VALUE);
- s.write('C');
- }
- }
-
- /**
- * Test capturing stack trace from a throwable that uses the PrintWriter methods not overridden in log4j 1.2.14 and
- * earlier.
- */
- public void testNotOverriddenBehavior() {
- final ThrowableInformation ti = new ThrowableInformation(new NotOverriddenThrowable());
- final String[] rep = ti.getThrowableStrRep();
- assertEquals(7, rep.length);
- final StringBuffer buf = new StringBuffer(String.valueOf(true));
- buf.append('a');
- buf.append(String.valueOf(1));
- buf.append(String.valueOf(2L));
- buf.append(String.valueOf(Float.MAX_VALUE));
- buf.append(String.valueOf(Double.MIN_VALUE));
- buf.append(String.valueOf(true));
- assertEquals(buf.toString(), rep[0]);
- assertEquals("a", rep[1]);
- assertEquals(String.valueOf(1), rep[2]);
- assertEquals(String.valueOf(2L), rep[3]);
- assertEquals(String.valueOf(Float.MAX_VALUE), rep[4]);
- assertEquals(String.valueOf(Double.MIN_VALUE), rep[5]);
- assertEquals("C", rep[6]);
- }
-
- /**
- * Custom throwable that calls methods of VectorWriter with null.
- */
- private static final class NullThrowable extends Throwable {
- private static final long serialVersionUID = 1L;
-
- /**
- * Create new instance.
- */
- public NullThrowable() {}
-
- /**
- * Print stack trace.
- *
- * @param s print writer.
- */
- public void printStackTrace(final PrintWriter s) {
- s.print((Object) null);
- s.print((String) null);
- s.println((Object) null);
- s.println((String) null);
- }
- }
-
- /**
- * Test capturing stack trace from a throwable that passes null to PrintWriter methods.
- */
- public void testNull() {
- final ThrowableInformation ti = new ThrowableInformation(new NullThrowable());
- final String[] rep = ti.getThrowableStrRep();
- assertEquals(2, rep.length);
- final String nullStr = String.valueOf((Object) null);
- assertEquals(nullStr + nullStr + nullStr, rep[0]);
- assertEquals(nullStr, rep[1]);
- }
-
- /**
- * Custom throwable that does nothing in printStackTrace.
- */
- private static final class EmptyThrowable extends Throwable {
- private static final long serialVersionUID = 1L;
-
- /**
- * Create new instance.
- */
- public EmptyThrowable() {}
-
- /**
- * Print stack trace.
- *
- * @param s print writer.
- */
- public void printStackTrace(final PrintWriter s) {}
- }
-
- /**
- * Test capturing stack trace from a throwable that does nothing on a call to printStackTrace.
- */
- public void testEmpty() {
- final ThrowableInformation ti = new ThrowableInformation(new EmptyThrowable());
- final String[] rep = ti.getThrowableStrRep();
- assertEquals(0, rep.length);
- }
-
- /**
- * Custom throwable that emits a specified string in printStackTrace.
- */
- private static final class StringThrowable extends Throwable {
- private static final long serialVersionUID = 1L;
- /**
- * Stack trace.
- */
- private final String stackTrace;
-
- /**
- * Create new instance.
- *
- * @param trace stack trace.
- */
- public StringThrowable(final String trace) {
- stackTrace = trace;
- }
-
- /**
- * Print stack trace.
- *
- * @param s print writer.
- */
- public void printStackTrace(final PrintWriter s) {
- s.print(stackTrace);
- }
- }
-
- /**
- * Test capturing stack trace from throwable that just has a line feed.
- */
- public void testLineFeed() {
- final ThrowableInformation ti = new ThrowableInformation(new StringThrowable("\n"));
- final String[] rep = ti.getThrowableStrRep();
- assertEquals(1, rep.length);
- assertEquals("", rep[0]);
- }
-
- /**
- * Test capturing stack trace from throwable that just has a carriage return.
- */
- public void testCarriageReturn() {
- final ThrowableInformation ti = new ThrowableInformation(new StringThrowable("\r"));
- final String[] rep = ti.getThrowableStrRep();
- assertEquals(1, rep.length);
- assertEquals("", rep[0]);
- }
-
- /**
- * Test parsing of line breaks.
- */
- public void testParsing() {
- final ThrowableInformation ti =
- new ThrowableInformation(new StringThrowable("Line1\rLine2\nLine3\r\nLine4\n\rLine6"));
- final String[] rep = ti.getThrowableStrRep();
- assertEquals(6, rep.length);
- assertEquals("Line1", rep[0]);
- assertEquals("Line2", rep[1]);
- assertEquals("Line3", rep[2]);
- assertEquals("Line4", rep[3]);
- assertEquals("", rep[4]);
- assertEquals("Line6", rep[5]);
- }
-
- /**
- * Test capturing stack trace from throwable that a line feed followed by blank.
- */
- public void testLineFeedBlank() {
- final ThrowableInformation ti = new ThrowableInformation(new StringThrowable("\n "));
- final String[] rep = ti.getThrowableStrRep();
- assertEquals(2, rep.length);
- assertEquals("", rep[0]);
- assertEquals(" ", rep[1]);
- }
-
- /**
- * Test that getThrowable returns the throwable provided to the constructor.
- */
- public void testGetThrowable() {
- final Throwable t = new StringThrowable("Hello, World");
- final ThrowableInformation ti = new ThrowableInformation(t);
- assertSame(t, ti.getThrowable());
- }
-
- /**
- * Tests isolation of returned string representation from internal state of ThrowableInformation. log4j 1.2.15 and
- * earlier did not isolate initial call. See bug 44032.
- */
- public void testIsolation() {
- final ThrowableInformation ti = new ThrowableInformation(new StringThrowable("Hello, World"));
- final String[] rep = ti.getThrowableStrRep();
- assertEquals("Hello, World", rep[0]);
- rep[0] = "Bonjour, Monde";
- final String[] rep2 = ti.getThrowableStrRep();
- assertEquals("Hello, World", rep2[0]);
- }
-
- /**
- * Custom throwable that throws a runtime exception when printStackTrace is called.
- */
- private static final class NastyThrowable extends Throwable {
- private static final long serialVersionUID = 1L;
-
- /**
- * Create new instance.
- */
- public NastyThrowable() {}
-
- /**
- * Print stack trace.
- *
- * @param s print writer.
- */
- public void printStackTrace(final PrintWriter s) {
- s.print("NastyException");
- throw new RuntimeException("Intentional exception");
- }
- }
-
- /**
- * Tests that a failure in printStackTrace does not percolate out of getThrowableStrRep().
- *
- */
- public void testNastyException() {
- final ThrowableInformation ti = new ThrowableInformation(new NastyThrowable());
- final String[] rep = ti.getThrowableStrRep();
- assertEquals("NastyException", rep[0]);
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/util/AbsoluteDateAndTimeFilter.java b/log4j-1.2-api/src/test/java/org/apache/log4j/util/AbsoluteDateAndTimeFilter.java
deleted file mode 100644
index 538e7228b7c..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/util/AbsoluteDateAndTimeFilter.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.util;
-
-import org.apache.oro.text.perl.Perl5Util;
-
-public class AbsoluteDateAndTimeFilter implements Filter {
-
- Perl5Util util = new Perl5Util();
-
- @Override
- public String filter(final String in) {
- final String pat = "/" + Filter.ABSOLUTE_DATE_AND_TIME_PAT + "/";
-
- if (util.match(pat, in)) {
- return util.substitute("s/" + Filter.ABSOLUTE_DATE_AND_TIME_PAT + "//", in);
- } else {
- return in;
- }
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/util/AbsoluteTimeFilter.java b/log4j-1.2-api/src/test/java/org/apache/log4j/util/AbsoluteTimeFilter.java
deleted file mode 100644
index d9c173668e5..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/util/AbsoluteTimeFilter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.util;
-
-import org.apache.oro.text.perl.Perl5Util;
-
-public class AbsoluteTimeFilter implements Filter {
-
- Perl5Util util = new Perl5Util();
-
- @Override
- public String filter(final String in) {
- final String pat = "/" + Filter.ABSOLUTE_TIME_PAT + "/";
-
- if (util.match(pat, in)) {
- return util.substitute("s/" + Filter.ABSOLUTE_TIME_PAT + "//", in);
- }
- return in;
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/util/Compare.java b/log4j-1.2-api/src/test/java/org/apache/log4j/util/Compare.java
deleted file mode 100644
index 36af9f5e295..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/util/Compare.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.util;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-public class Compare {
-
- static final int B1_NULL = -1;
- static final int B2_NULL = -2;
-
- public static boolean compare(final Class testClass, final String file1, final String file2) throws IOException {
- try (final BufferedReader in1 = new BufferedReader(new FileReader(file1));
- final BufferedReader in2 = new BufferedReader(new InputStreamReader(open(testClass, file2)))) {
- return compare(testClass, file1, file2, in1, in2);
- }
- }
-
- public static boolean compare(
- final Class testClass,
- final String file1,
- final String file2,
- final BufferedReader in1,
- final BufferedReader in2)
- throws IOException {
-
- String s1;
- int lineCounter = 0;
-
- while ((s1 = in1.readLine()) != null) {
- lineCounter++;
-
- final String s2 = in2.readLine();
-
- if (!s1.equals(s2)) {
- System.out.println("Files [" + file1 + "] and [" + file2 + "] differ on line " + lineCounter);
- System.out.println("One reads: [" + s1 + "].");
- System.out.println("Other reads:[" + s2 + "].");
- outputFile(testClass, file1);
- outputFile(testClass, file2);
-
- return false;
- }
- }
-
- // the second file is longer
- if (in2.read() != -1) {
- System.out.println("File [" + file2 + "] longer than file [" + file1 + "].");
- outputFile(testClass, file1);
- outputFile(testClass, file2);
-
- return false;
- }
-
- return true;
- }
-
- public static boolean compare(final String file1, final String file2) throws FileNotFoundException, IOException {
- try (final BufferedReader in1 = new BufferedReader(new FileReader(file1));
- final BufferedReader in2 = new BufferedReader(new FileReader(file2))) {
-
- String s1;
- int lineCounter = 0;
- while ((s1 = in1.readLine()) != null) {
- lineCounter++;
- final String s2 = in2.readLine();
- if (!s1.equals(s2)) {
- System.out.println("Files [" + file1 + "] and [" + file2 + "] differ on line " + lineCounter);
- System.out.println("One reads: [" + s1 + "].");
- System.out.println("Other reads:[" + s2 + "].");
- return false;
- }
- }
-
- // the second file is longer
- if (in2.read() != -1) {
- System.out.println("File [" + file2 + "] longer than file [" + file1 + "].");
- return false;
- }
-
- return true;
- }
- }
-
- private static final InputStream open(final Class testClass, final String fileName) throws IOException {
- String resourceName = fileName;
- if (fileName.startsWith("witness/")) {
- resourceName = fileName.substring(fileName.lastIndexOf('/') + 1);
- }
- InputStream is = testClass.getResourceAsStream(resourceName);
- if (is == null) {
- final File file = new File(fileName);
- if (file.exists()) {
- is = new FileInputStream(file);
- } else {
- throw new FileNotFoundException("Resource " + resourceName + " not found");
- }
- }
- return is;
- }
-
- /**
- *
- * Prints file on the console.
- *
- */
- private static void outputFile(final Class testClass, final String file) throws IOException {
- try (final InputStream is = open(testClass, file);
- final BufferedReader in1 = new BufferedReader(new InputStreamReader(is))) {
-
- String s1;
- int lineCounter = 0;
- System.out.println("--------------------------------");
- System.out.println("Contents of " + file + ":");
-
- while ((s1 = in1.readLine()) != null) {
- lineCounter++;
- System.out.print(lineCounter);
-
- if (lineCounter < 10) {
- System.out.print(" : ");
- } else if (lineCounter < 100) {
- System.out.print(" : ");
- } else if (lineCounter < 1000) {
- System.out.print(" : ");
- } else {
- System.out.print(": ");
- }
-
- System.out.println(s1);
- }
- }
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/util/ControlFilter.java b/log4j-1.2-api/src/test/java/org/apache/log4j/util/ControlFilter.java
deleted file mode 100644
index a2f872a1ae8..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/util/ControlFilter.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.util;
-
-import java.util.Arrays;
-import org.apache.oro.text.perl.Perl5Util;
-
-public class ControlFilter implements Filter {
-
- Perl5Util util = new Perl5Util();
-
- String[] allowedPatterns;
-
- public ControlFilter(final String[] allowedPatterns) {
- this.allowedPatterns = allowedPatterns;
- }
-
- @Override
- public String filter(final String in) throws UnexpectedFormatException {
- final int len = allowedPatterns.length;
- for (int i = 0; i < len; i++) {
- // System.out.println("["+allowedPatterns[i]+"]");
- if (util.match("/" + allowedPatterns[i] + "/", in)) {
- // System.out.println("["+in+"] matched ["+allowedPatterns[i]);
- return in;
- }
- }
-
- throw new UnexpectedFormatException("[" + in + "] allowedPatterns = " + Arrays.toString(allowedPatterns));
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/util/EnhancedJunitTestRunnerFilter.java b/log4j-1.2-api/src/test/java/org/apache/log4j/util/EnhancedJunitTestRunnerFilter.java
deleted file mode 100644
index 7b44b1c0f9d..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/util/EnhancedJunitTestRunnerFilter.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.util;
-
-import org.apache.oro.text.perl.Perl5Util;
-
-public class EnhancedJunitTestRunnerFilter implements Filter {
- private static final String[] PATTERNS = {
- "at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner",
- "at org.apache.tools.ant",
- "at junit.textui.TestRunner",
- "at com.intellij.rt.execution.junit",
- "at java.lang.reflect.Method.invoke",
- "at org.apache.maven.",
- "at org.codehaus.",
- "at org.junit.internal.runners.",
- "at junit.framework.JUnit4TestAdapter"
- };
-
- private final Perl5Util util = new Perl5Util();
-
- public EnhancedJunitTestRunnerFilter() {}
-
- /**
- * Filter out stack trace lines coming from the various JUnit TestRunners.
- */
- @Override
- public String filter(final String in) {
- if (in == null) {
- return null;
- }
-
- //
- // restore the one instance of Method.invoke that we actually want
- //
- if (in.indexOf("at junit.framework.TestCase.runTest") != -1) {
- return "\tat java.lang.reflect.Method.invoke(X)\n\t" + in.trim();
- }
-
- for (final String element : PATTERNS) {
- if (in.indexOf(element) != -1) {
- return null;
- }
- }
- if (util.match("/\\sat /", in)) {
- return "\t" + in.trim();
- }
- return in;
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/util/EnhancedLineNumberFilter.java b/log4j-1.2-api/src/test/java/org/apache/log4j/util/EnhancedLineNumberFilter.java
deleted file mode 100644
index fa8132adf0f..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/util/EnhancedLineNumberFilter.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.util;
-
-import java.util.regex.Pattern;
-
-public class EnhancedLineNumberFilter implements Filter {
- private final Pattern linePattern;
- private final Pattern nativePattern;
-
- public EnhancedLineNumberFilter() {
- linePattern = Pattern.compile("\\(.*:\\d{1,4}\\)");
- nativePattern = Pattern.compile("\\(Native Method\\)");
- }
-
- @Override
- public String filter(final String in) {
-
- if (linePattern.matcher(in).find()) {
- return linePattern.matcher(in).replaceAll("(X)");
- } else if (nativePattern.matcher(in).find()) {
- return nativePattern.matcher(in).replaceAll("(X)");
- } else {
- return in;
- }
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/util/Filter.java b/log4j-1.2-api/src/test/java/org/apache/log4j/util/Filter.java
deleted file mode 100644
index f3ebdcea693..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/util/Filter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.util;
-
-public interface Filter {
-
- final String BASIC_PAT = "\\[main\\] (FATAL|ERROR|WARN|INFO|DEBUG)";
- final String ISO8601_PAT = "^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2},\\d{3}";
-
- // 06 avr. 2002 18:36:32,036
- // 18 fevr. 2002 20:05:36,222
- public static final String ABSOLUTE_DATE_AND_TIME_PAT = "^\\d{1,2} .{2,6}\\.? 2\\d{3} \\d{2}:\\d{2}:\\d{2},\\d{3}";
-
- // 18:54:19,201
- public static final String ABSOLUTE_TIME_PAT = "^\\d{2}:\\d{2}:\\d{2},\\d{3}";
-
- public static final String RELATIVE_TIME_PAT = "^\\d{1,10}";
-
- String filter(String in) throws UnexpectedFormatException;
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/util/ISO8601Filter.java b/log4j-1.2-api/src/test/java/org/apache/log4j/util/ISO8601Filter.java
deleted file mode 100644
index 023337e9af5..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/util/ISO8601Filter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.util;
-
-import org.apache.oro.text.perl.Perl5Util;
-
-public class ISO8601Filter implements Filter {
-
- Perl5Util util = new Perl5Util();
-
- @Override
- public String filter(final String in) {
- final String pat = "/" + ISO8601_PAT + "/";
-
- if (util.match(pat, in)) {
- return util.substitute("s/" + ISO8601_PAT + "//", in);
- }
- return in;
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/util/JunitTestRunnerFilter.java b/log4j-1.2-api/src/test/java/org/apache/log4j/util/JunitTestRunnerFilter.java
deleted file mode 100644
index bd18f8893ae..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/util/JunitTestRunnerFilter.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.util;
-
-import org.apache.oro.text.perl.Perl5Util;
-
-public class JunitTestRunnerFilter implements Filter {
- Perl5Util util = new Perl5Util();
-
- /**
- * Filter out stack trace lines coming from the various JUnit TestRunners.
- */
- @Override
- public String filter(final String in) {
- if (in == null) {
- return null;
- }
-
- if (util.match("/at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner/", in)) {
- return null;
- } else if (util.match("/at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner/", in)) {
- return null;
- } else if (util.match("/at com.intellij/", in)) {
- return null;
- } else if (in.indexOf("at junit.") >= 0 && in.indexOf("ui.TestRunner") >= 0) {
- return null;
- } else if (in.indexOf("org.apache.maven") >= 0) {
- return null;
- } else if (in.indexOf("junit.internal") >= 0) {
- return null;
- } else if (in.indexOf("JUnit4TestAdapter") >= 0) {
- return null;
- } else if (util.match("/\\sat /", in)) {
- return "\t" + in.trim();
- } else {
- return in;
- }
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/util/LineNumberFilter.java b/log4j-1.2-api/src/test/java/org/apache/log4j/util/LineNumberFilter.java
deleted file mode 100644
index 3148d927eb9..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/util/LineNumberFilter.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.util;
-
-import org.apache.oro.text.perl.Perl5Util;
-
-public class LineNumberFilter implements Filter {
-
- Perl5Util util = new Perl5Util();
-
- @Override
- public String filter(final String in) {
- if (util.match("/\\(.*:\\d{1,4}\\)/", in)) {
- return util.substitute("s/:\\d{1,4}\\)/:XXX)/", in);
- }
- if (in.indexOf(", Compiled Code") >= 0) {
- return util.substitute("s/, Compiled Code/:XXX/", in);
- }
- return in;
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/util/RelativeTimeFilter.java b/log4j-1.2-api/src/test/java/org/apache/log4j/util/RelativeTimeFilter.java
deleted file mode 100644
index 3f7c251478a..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/util/RelativeTimeFilter.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.util;
-
-import org.apache.oro.text.perl.Perl5Util;
-
-public class RelativeTimeFilter implements Filter {
-
- Perl5Util util = new Perl5Util();
-
- @Override
- public String filter(final String in) {
- final String pat = "/" + Filter.RELATIVE_TIME_PAT + "/";
-
- if (util.match(pat, in)) {
- // System.out.println("Removing relative time from line ["+in+"]");
- return util.substitute("s/" + Filter.RELATIVE_TIME_PAT + "//", in);
- }
- return in;
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/util/SerializationTestHelper.java b/log4j-1.2-api/src/test/java/org/apache/log4j/util/SerializationTestHelper.java
deleted file mode 100644
index cdbf1f9dcec..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/util/SerializationTestHelper.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.util;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import org.apache.commons.io.FileUtils;
-
-/**
- * Utiities for serialization tests.
- */
-public final class SerializationTestHelper {
- /**
- * Checks the serialization of an object against an file containing the expected serialization.
- *
- * @param witness name of file containing expected serialization.
- * @param obj object to be serialized.
- * @param skip positions in serialized stream that should not be compared.
- * @param endCompare position to stop comparison.
- * @throws Exception thrown on IO or serialization exception.
- */
- public static void assertSerializationEquals(
- final String witness, final Object obj, final int[] skip, final int endCompare) throws Exception {
- final ByteArrayOutputStream memOut = new ByteArrayOutputStream();
- try (final ObjectOutputStream objOut = new ObjectOutputStream(memOut)) {
- objOut.writeObject(obj);
- }
-
- assertStreamEquals(witness, memOut.toByteArray(), skip, endCompare);
- }
-
- /**
- * Asserts the serialized form of an object.
- *
- * @param witness file name of expected serialization.
- * @param actual byte array of actual serialization.
- * @param skip positions to skip comparison.
- * @param endCompare position to stop comparison.
- * @throws IOException thrown on IO or serialization exception.
- */
- public static void assertStreamEquals(
- final String witness, final byte[] actual, final int[] skip, final int endCompare) throws IOException {
- final File witnessFile = new File(witness);
-
- if (witnessFile.exists()) {
- int skipIndex = 0;
- final byte[] expected = FileUtils.readFileToByteArray(witnessFile);
- final int bytesRead = expected.length;
-
- if (bytesRead < endCompare) {
- assertEquals(bytesRead, actual.length);
- }
-
- int endScan = actual.length;
-
- if (endScan > endCompare) {
- endScan = endCompare;
- }
-
- for (int i = 0; i < endScan; i++) {
- if ((skipIndex < skip.length) && (skip[skipIndex] == i)) {
- skipIndex++;
- } else if (expected[i] != actual[i]) {
- assertEquals("Difference at offset " + i, expected[i], actual[i]);
- }
- }
- } else {
- //
- // if the file doesn't exist then
- // assume that we are setting up and need to write it
- FileUtils.writeByteArrayToFile(witnessFile, actual);
- fail("Writing witness file " + witness);
- }
- }
-
- /**
- * Deserializes a specified file.
- *
- * @param witness serialization file, may not be null.
- * @return deserialized object.
- * @throws Exception thrown on IO or deserialization exception.
- */
- public static Object deserializeStream(final String witness) throws Exception {
- try (final ObjectInputStream objIs = new ObjectInputStream(new FileInputStream(witness))) {
- return objIs.readObject();
- }
- }
-
- /**
- * Creates a clone by serializing object and deserializing byte stream.
- *
- * @param obj object to serialize and deserialize.
- * @return clone
- * @throws IOException on IO error.
- * @throws ClassNotFoundException if class not found.
- */
- public static Object serializeClone(final Object obj) throws IOException, ClassNotFoundException {
- final ByteArrayOutputStream memOut = new ByteArrayOutputStream();
- try (final ObjectOutputStream objOut = new ObjectOutputStream(memOut)) {
- objOut.writeObject(obj);
- }
-
- final ByteArrayInputStream src = new ByteArrayInputStream(memOut.toByteArray());
- final ObjectInputStream objIs = new ObjectInputStream(src);
-
- return objIs.readObject();
- }
-
- /**
- * Private constructor.
- */
- private SerializationTestHelper() {}
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/util/SunReflectFilter.java b/log4j-1.2-api/src/test/java/org/apache/log4j/util/SunReflectFilter.java
deleted file mode 100644
index 07866f0294c..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/util/SunReflectFilter.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.util;
-
-import org.apache.oro.text.perl.Perl5Util;
-
-/**
- * The sun.reflect.* and java.lang.reflect.* lines are not present in all JDKs.
- */
-public class SunReflectFilter implements Filter {
- Perl5Util util = new Perl5Util();
-
- @Override
- public String filter(final String in) {
- if ((in == null) || util.match("/at sun.reflect/", in) || (in.indexOf("at java.lang.reflect.") >= 0)) {
- return null;
- }
- if (in.indexOf("Compiled Code") >= 0) {
- if (in.indexOf("junit.framework.TestSuite") >= 0) {
- return util.substitute("s/Compiled Code/TestSuite.java:XXX/", in);
- }
- }
- if (util.match("/\\(Method.java:.*\\)/", in)) {
- return util.substitute("s/\\(Method.java:.*\\)/(Native Method)/", in);
- }
- return in;
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/util/Transformer.java b/log4j-1.2-api/src/test/java/org/apache/log4j/util/Transformer.java
deleted file mode 100644
index d28d4003eb0..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/util/Transformer.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.util;
-
-import java.io.BufferedReader;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.PrintStream;
-
-public class Transformer {
-
- public static void transform(final String in, final String out, final Filter filter)
- throws IOException, UnexpectedFormatException {
-
- String line;
- final BufferedReader input = new BufferedReader(new FileReader(in));
- final PrintStream output = new PrintStream(new FileOutputStream(out));
-
- // Initialization of input and output omitted
- while ((line = input.readLine()) != null) {
- line = filter.filter(line);
- output.println(line);
- }
- }
-
- public static void transform(final String in, final String out, final Filter[] filters)
- throws IOException, UnexpectedFormatException {
-
- String line;
- final BufferedReader input = new BufferedReader(new FileReader(in));
- final PrintStream output = new PrintStream(new FileOutputStream(out, false));
-
- // Initialization of input and output omitted
- while ((line = input.readLine()) != null) {
- // apply all filters
- for (final Filter filter : filters) {
- line = filter.filter(line);
- }
- if (line != null) {
- output.println(line);
- }
- }
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/util/UnexpectedFormatException.java b/log4j-1.2-api/src/test/java/org/apache/log4j/util/UnexpectedFormatException.java
deleted file mode 100644
index e770fb1d32a..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/util/UnexpectedFormatException.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.util;
-
-public class UnexpectedFormatException extends Exception {
-
- private static final long serialVersionUID = 1787725660780924147L;
-
- public UnexpectedFormatException(final String msg) {
- super(msg);
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/util/XMLLineAttributeFilter.java b/log4j-1.2-api/src/test/java/org/apache/log4j/util/XMLLineAttributeFilter.java
deleted file mode 100644
index 86727f436c8..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/util/XMLLineAttributeFilter.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.util;
-
-import org.apache.oro.text.perl.Perl5Util;
-
-public class XMLLineAttributeFilter implements Filter {
-
- Perl5Util util = new Perl5Util();
-
- @Override
- public String filter(final String in) {
- if (util.match("/line=\"\\d{1,3}\"/", in)) {
- return util.substitute("s/line=\"\\d{1,3}\"/line=\"X\"/", in);
- } else if (util.match("/line=\"?\"/", in)) {
- return util.substitute("s/line=\"?\"/line=\"X\"/", in);
- } else {
- return in;
- }
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/util/XMLTimestampFilter.java b/log4j-1.2-api/src/test/java/org/apache/log4j/util/XMLTimestampFilter.java
deleted file mode 100644
index 6a0fb531c5a..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/util/XMLTimestampFilter.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.util;
-
-import org.apache.oro.text.perl.Perl5Util;
-
-public class XMLTimestampFilter implements Filter {
-
- Perl5Util util = new Perl5Util();
-
- @Override
- public String filter(final String in) {
- if (util.match("/timestamp=\"\\d{10,13}\"/", in)) {
- return util.substitute("s/timestamp=\"\\d{10,13}\"/timestamp=\"XXX\"/", in);
- }
- return in;
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/xml/DOMTestCase.java b/log4j-1.2-api/src/test/java/org/apache/log4j/xml/DOMTestCase.java
deleted file mode 100644
index 63fca289ce5..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/xml/DOMTestCase.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.xml;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-import org.apache.log4j.Appender;
-import org.apache.log4j.FileAppender;
-import org.apache.log4j.LogManager;
-import org.apache.log4j.Logger;
-import org.apache.log4j.VectorAppender;
-import org.apache.log4j.bridge.AppenderWrapper;
-import org.apache.log4j.spi.ErrorHandler;
-import org.apache.log4j.spi.LoggerFactory;
-import org.apache.log4j.spi.LoggingEvent;
-import org.apache.log4j.spi.OptionHandler;
-import org.apache.log4j.spi.ThrowableRenderer;
-import org.apache.log4j.spi.ThrowableRendererSupport;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-public class DOMTestCase {
-
- /**
- * CustomErrorHandler for testCategoryFactory2.
- */
- public static class CustomErrorHandler implements ErrorHandler {
- public CustomErrorHandler() {}
-
- public void activateOptions() {}
-
- @Override
- public void error(final String message) {}
-
- @Override
- public void error(final String message, final Exception e, final int errorCode) {}
-
- @Override
- public void error(final String message, final Exception e, final int errorCode, final LoggingEvent event) {}
-
- @Override
- public void setAppender(final Appender appender) {}
-
- @Override
- public void setBackupAppender(final Appender appender) {}
-
- @Override
- public void setLogger(final Logger logger) {}
- }
-
- /**
- * CustomLogger implementation for testCategoryFactory1 and 2.
- */
- private static class CustomLogger extends Logger {
- /**
- * Creates new instance.
- *
- * @param name logger name.
- */
- public CustomLogger(final String name) {
- super(name);
- }
- }
-
- /**
- * Creates new instances of CustomLogger.
- */
- public static class CustomLoggerFactory implements LoggerFactory {
-
- /**
- * Additivity, expected to be set false in configuration file.
- */
- private boolean additivity;
-
- /**
- * Create new instance of factory.
- */
- public CustomLoggerFactory() {
- additivity = true;
- }
-
- /**
- * Create new logger.
- *
- * @param name logger name.
- * @return new logger.
- */
- @Override
- public Logger makeNewLoggerInstance(final String name) {
- final Logger logger = new CustomLogger(name);
- assertFalse(additivity);
- return logger;
- }
-
- /**
- * Set additivity.
- *
- * @param newVal new value of additivity.
- */
- public void setAdditivity(final boolean newVal) {
- additivity = newVal;
- }
- }
-
- /**
- * Mock ThrowableRenderer for testThrowableRenderer. See bug 45721.
- */
- public static class MockThrowableRenderer implements ThrowableRenderer, OptionHandler {
- private boolean activated = false;
- private boolean showVersion = true;
-
- public MockThrowableRenderer() {}
-
- @Override
- public void activateOptions() {
- activated = true;
- }
-
- @Override
- public String[] doRender(final Throwable t) {
- return new String[0];
- }
-
- public boolean getShowVersion() {
- return showVersion;
- }
-
- public boolean isActivated() {
- return activated;
- }
-
- public void setShowVersion(final boolean v) {
- showVersion = v;
- }
- }
-
- private static final boolean Log4j1ActualAppender = false;
-
- private static final boolean AssumeThrowableRendererSupport = false;
-
- Logger root;
-
- Logger logger;
-
- @BeforeEach
- public void setUp() {
- root = Logger.getRootLogger();
- logger = Logger.getLogger(DOMTestCase.class);
- }
-
- @AfterEach
- public void tearDown() {
- root.getLoggerRepository().resetConfiguration();
- }
-
- /**
- * Test checks that configureAndWatch does initial configuration, see bug 33502.
- *
- * @throws Exception if IO error.
- */
- @Test
- public void testConfigureAndWatch() throws Exception {
- DOMConfigurator.configureAndWatch("src/test/resources/log4j1-1.2.17/input/xml/DOMTestCase1.xml");
- assertNotNull(Logger.getRootLogger().getAppender("A1"));
- }
-
- /**
- * Test for bug 47465. configure(URL) did not close opened JarURLConnection.
- *
- * @throws IOException if IOException creating properties jar.
- */
- @Test
- public void testJarURL() throws IOException {
- final File input = new File("src/test/resources/log4j1-1.2.17/input/xml/defaultInit.xml");
- System.out.println(input.getAbsolutePath());
- final File configJar = new File("target/output/xml.jar");
- final File dir = new File("target/output");
- dir.mkdirs();
- try (final InputStream inputStream = new FileInputStream(input);
- final FileOutputStream out = new FileOutputStream(configJar);
- final ZipOutputStream zos = new ZipOutputStream(out)) {
- zos.putNextEntry(new ZipEntry("log4j.xml"));
- int len;
- final byte[] buf = new byte[1024];
- while ((len = inputStream.read(buf)) > 0) {
- zos.write(buf, 0, len);
- }
- zos.closeEntry();
- }
- final URL urlInJar = new URL("jar:" + configJar.toURL() + "!/log4j.xml");
- DOMConfigurator.configure(urlInJar);
- assertTrue(configJar.delete());
- assertFalse(configJar.exists());
- }
-
- /**
- * This test checks that the subst method of an extending class is checked when evaluating parameters. See bug 43325.
- *
- */
- @Test
- public void testOverrideSubst() {
- final DOMConfigurator configurator = new DOMConfigurator() {
- protected String subst(final String value) {
- if ("target/output/temp.A1".equals(value)) {
- return "target/output/subst-test.A1";
- }
- return value;
- }
- };
- configurator.doConfigure(
- "src/test/resources/log4j1-1.2.17/input/xml/DOMTestCase1.xml", LogManager.getLoggerRepository());
- final String name = "A1";
- final Appender appender = Logger.getRootLogger().getAppender(name);
- assertNotNull(name, appender);
- if (Log4j1ActualAppender) {
- final FileAppender a1 = (FileAppender) appender;
- assertNotNull(name, a1);
- final String file = a1.getFile();
- assertEquals("target/output/subst-test.A1", file);
- } else {
- final AppenderWrapper wrapper = (AppenderWrapper) appender;
- assertNotNull(name, wrapper);
- final org.apache.logging.log4j.core.appender.FileAppender a1 =
- (org.apache.logging.log4j.core.appender.FileAppender) wrapper.getAppender();
- assertNotNull(wrapper.toString(), a1);
- final String file = a1.getFileName();
- assertNotNull(a1.toString(), file);
- // TODO Support this or not?
- // assertEquals("target/output/subst-test.A1", file);
- }
- }
-
- /**
- * Tests that reset="true" on log4j:configuration element resets repository before configuration.
- *
- * @throws Exception thrown on error.
- */
- @Test
- public void testReset() throws Exception {
- final VectorAppender appender = new VectorAppender();
- appender.setName("V1");
- Logger.getRootLogger().addAppender(appender);
- DOMConfigurator.configure("src/test/resources/log4j1-1.2.17/input/xml/testReset.xml");
- assertNull(Logger.getRootLogger().getAppender("V1"));
- }
-
- /**
- * Test of log4j.throwableRenderer support. See bug 45721.
- */
- @Test
- public void testThrowableRenderer1() {
- DOMConfigurator.configure("src/test/resources/log4j1-1.2.17/input/xml/throwableRenderer1.xml");
- final ThrowableRendererSupport repo = (ThrowableRendererSupport) LogManager.getLoggerRepository();
- final MockThrowableRenderer renderer = (MockThrowableRenderer) repo.getThrowableRenderer();
- LogManager.resetConfiguration();
- if (AssumeThrowableRendererSupport) {
- assertNotNull(renderer);
- assertEquals(true, renderer.isActivated());
- assertEquals(false, renderer.getShowVersion());
- }
- }
-}
diff --git a/log4j-1.2-api/src/test/java/org/apache/log4j/xml/XLevel.java b/log4j-1.2-api/src/test/java/org/apache/log4j/xml/XLevel.java
deleted file mode 100644
index 58e9d8afb73..00000000000
--- a/log4j-1.2-api/src/test/java/org/apache/log4j/xml/XLevel.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.log4j.xml;
-
-import static org.apache.logging.log4j.util.Strings.toRootUpperCase;
-
-import org.apache.log4j.Level;
-
-/**
- * This class introduces a new level called TRACE. TRACE has lower level than DEBUG.
- */
-public class XLevel extends Level {
- private static final long serialVersionUID = 7288304330257085144L;
-
- public static final int TRACE_INT = Level.DEBUG_INT - 1;
- public static final int LETHAL_INT = Level.FATAL_INT + 1;
-
- private static final String TRACE_STR = "TRACE";
- private static final String LETHAL_STR = "LETHAL";
-
- public static final XLevel TRACE = new XLevel(TRACE_INT, TRACE_STR, 7);
- public static final XLevel LETHAL = new XLevel(LETHAL_INT, LETHAL_STR, 0);
-
- public static Level toLevel(final int i) throws IllegalArgumentException {
- switch (i) {
- case TRACE_INT:
- return XLevel.TRACE;
- case LETHAL_INT:
- return XLevel.LETHAL;
- }
- return Level.toLevel(i);
- }
-
- /**
- * Convert the string passed as argument to a level. If the conversion fails, then this method returns {@link #TRACE}.
- */
- public static Level toLevel(final String sArg) {
- return toLevel(sArg, XLevel.TRACE);
- }
-
- public static Level toLevel(final String sArg, final Level defaultValue) {
-
- if (sArg == null) {
- return defaultValue;
- }
- final String stringVal = toRootUpperCase(sArg);
-
- if (stringVal.equals(TRACE_STR)) {
- return XLevel.TRACE;
- } else if (stringVal.equals(LETHAL_STR)) {
- return XLevel.LETHAL;
- }
-
- return Level.toLevel(sArg, defaultValue);
- }
-
- protected XLevel(final int level, final String strLevel, final int syslogEquiv) {
- super(level, strLevel, syslogEquiv);
- }
-}
diff --git a/log4j-1.2-api/src/test/resources/L7D_en_US.properties b/log4j-1.2-api/src/test/resources/L7D_en_US.properties
deleted file mode 100644
index 0121fbe931c..00000000000
--- a/log4j-1.2-api/src/test/resources/L7D_en_US.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-test=This is the English, US test.
-hello_world=Hello world.
-msg1=This is test number {0} with string argument {1}.
diff --git a/log4j-1.2-api/src/test/resources/L7D_fr.properties b/log4j-1.2-api/src/test/resources/L7D_fr.properties
deleted file mode 100644
index 1c68863f210..00000000000
--- a/log4j-1.2-api/src/test/resources/L7D_fr.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-test=Ceci est le test en francais pour la France.
-hello_world=Bonjour la France.
-msg1=Ceci est le test numero {0} contenant l''argument {1}.
diff --git a/log4j-1.2-api/src/test/resources/L7D_fr_CH.properties b/log4j-1.2-api/src/test/resources/L7D_fr_CH.properties
deleted file mode 100644
index a6af2511118..00000000000
--- a/log4j-1.2-api/src/test/resources/L7D_fr_CH.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-test=Ceci est le test en francais pour la p'tite Suisse.
-hello world=Salut le monde.
diff --git a/log4j-1.2-api/src/test/resources/LOG4J2-3247.properties b/log4j-1.2-api/src/test/resources/LOG4J2-3247.properties
deleted file mode 100644
index 9593823b24b..00000000000
--- a/log4j-1.2-api/src/test/resources/LOG4J2-3247.properties
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
-log4j.appender.CONSOLE.filter.1=org.apache.log4j.config.NeutralFilterFixture
-log4j.appender.CONSOLE.filter.1.onMatch=neutral
-log4j.appender.CONSOLE.Target=System.out
-log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
-log4j.appender.CONSOLE.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
-
-log4j.appender.A1=org.apache.log4j.FileAppender
-log4j.appender.A1.File=target/temp.A1
-log4j.appender.A1.Append=false
-log4j.appender.A1.layout=org.apache.log4j.PatternLayout
-log4j.appender.A1.layout.ConversionPattern=%-5p %c{2} - %m%n
-log4j.appender.A2=org.apache.log4j.FileAppender
-log4j.appender.A2.File=target/temp.A2
-log4j.appender.A2.Append=false
-log4j.appender.A2.layout=org.apache.log4j.TTCCLayout
-log4j.appender.A2.layout.DateFormat=ISO8601
-log4j.logger.org.apache.log4j.xml=trace, A1
-log4j.rootLogger=trace, CONSOLE, A1, A2
diff --git a/log4j-1.2-api/src/test/resources/LOG4J2-3281.properties b/log4j-1.2-api/src/test/resources/LOG4J2-3281.properties
deleted file mode 100644
index 78d3af5a423..00000000000
--- a/log4j-1.2-api/src/test/resources/LOG4J2-3281.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.appender.CUSTOM=org.apache.log4j.CustomNoopAppender
-log4j.appender.CUSTOM.filter.1=org.apache.log4j.config.NeutralFilterFixture
-log4j.appender.CUSTOM.filter.1.onMatch=neutral
-log4j.appender.CUSTOM.Target=System.out
-log4j.appender.CUSTOM.layout=org.apache.log4j.PatternLayout
-log4j.appender.CUSTOM.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
-
-log4j.logger.org.apache.log4j.xml=trace, CUSTOM
-log4j.rootLogger=trace, CUSTOM
diff --git a/log4j-1.2-api/src/test/resources/LOG4J2-3326.properties b/log4j-1.2-api/src/test/resources/LOG4J2-3326.properties
deleted file mode 100644
index 9fc31300b5f..00000000000
--- a/log4j-1.2-api/src/test/resources/LOG4J2-3326.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.appender.CUSTOM=org.apache.log4j.ListAppender
-log4j.appender.CUSTOM.filter.1=org.apache.log4j.varia.LevelRangeFilter
-log4j.appender.CUSTOM.filter.1.levelMin=ALL
-log4j.appender.CUSTOM.filter.2=org.apache.log4j.varia.LevelRangeFilter
-log4j.appender.CUSTOM.filter.2.levelMin=INFO
-log4j.appender.CUSTOM.filter.2.levelMax=ERROR
-log4j.appender.CUSTOM.filter.3=org.apache.log4j.varia.LevelRangeFilter
-
-log4j.rootLogger=trace, CUSTOM
diff --git a/log4j-1.2-api/src/test/resources/LOG4J2-3407.properties b/log4j-1.2-api/src/test/resources/LOG4J2-3407.properties
deleted file mode 100644
index b0634222d3c..00000000000
--- a/log4j-1.2-api/src/test/resources/LOG4J2-3407.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
-log4j.appender.CONSOLE.filter.1=org.apache.log4j.config.NeutralFilterFixture
-log4j.appender.CONSOLE.filter.1.onMatch=neutral
-log4j.appender.CONSOLE.Target=System.out
-log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
-log4j.appender.CONSOLE.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
-
-log4j.logger.org.apache.log4j.xml=trace, A1
-log4j.rootLogger=trace, CONSOLE
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-DailyRollingFileAppender.properties b/log4j-1.2-api/src/test/resources/config-1.2/log4j-DailyRollingFileAppender.properties
deleted file mode 100644
index d7d2c2527b7..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-DailyRollingFileAppender.properties
+++ /dev/null
@@ -1,47 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-###############################################################################
-#
-# Log4J 1.2 Configuration.
-#
-
-hadoop.log.dir=target
-hadoop.log.file=hadoop.log
-
-log4j.rootLogger=TRACE, DRFA
-
-#
-# Daily Rolling File Appender
-#
-
-log4j.appender.DRFA=org.apache.log4j.DailyRollingFileAppender
-log4j.appender.DRFA.Append=false
-log4j.appender.DRFA.BufferedIO=true
-log4j.appender.DRFA.BufferSize=1000
-log4j.appender.DRFA.File=${hadoop.log.dir}/${hadoop.log.file}
-log4j.appender.DRFA.ImmediateFlush=false
-
-# Rollover at midnight
-log4j.appender.DRFA.DatePattern=.dd-MM-yyyy
-
-log4j.appender.DRFA.layout=org.apache.log4j.PatternLayout
-
-# Pattern format: Date LogLevel LoggerName LogMessage
-log4j.appender.DRFA.layout.ConversionPattern=%d{ISO8601} %p %c: %m%n
-# Debugging Pattern format
-#log4j.appender.DRFA.layout.ConversionPattern=%d{ISO8601} %-5p %c{2} (%F:%M(%L)) - %m%n
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-DailyRollingFileAppender.xml b/log4j-1.2-api/src/test/resources/config-1.2/log4j-DailyRollingFileAppender.xml
deleted file mode 100644
index a2a9f6e98c7..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-DailyRollingFileAppender.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-EnhancedRollingFileAppender.properties b/log4j-1.2-api/src/test/resources/config-1.2/log4j-EnhancedRollingFileAppender.properties
deleted file mode 100644
index a0ef860d21c..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-EnhancedRollingFileAppender.properties
+++ /dev/null
@@ -1,65 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-###############################################################################
-#
-# Log4J 1.2 Configuration.
-#
-
-log4j.rootLogger=TRACE, DEFAULT_TIME, DEFAULT_SIZE, TIME, SIZE
-
-log4j.appender.DEFAULT_TIME = org.apache.log4j.rolling.RollingFileAppender
-log4j.appender.DEFAULT_TIME.layout = org.apache.log4j.SimpleLayout
-log4j.appender.DEFAULT_TIME.File = target/EnhancedRollingFileAppender/defaultTime.log
-log4j.appender.DEFAULT_TIME.rollingPolicy = org.apache.log4j.rolling.TimeBasedRollingPolicy
-log4j.appender.DEFAULT_TIME.rollingPolicy.FileNamePattern = target/EnhancedRollingFileAppender/defaultTime.%d{yyyy-MM-dd}.log
-
-log4j.appender.DEFAULT_SIZE = org.apache.log4j.rolling.RollingFileAppender
-log4j.appender.DEFAULT_SIZE.File = target/EnhancedRollingFileAppender/defaultSize.log
-log4j.appender.DEFAULT_SIZE.layout = org.apache.log4j.SimpleLayout
-log4j.appender.DEFAULT_SIZE.triggeringPolicy = org.apache.log4j.rolling.SizeBasedTriggeringPolicy
-log4j.appender.DEFAULT_SIZE.rollingPolicy = org.apache.log4j.rolling.FixedWindowRollingPolicy
-log4j.appender.DEFAULT_SIZE.rollingPolicy.FileNamePattern = target/EnhancedRollingFileAppender/defaultSize.%i.log
-
-log4j.appender.TIME = org.apache.log4j.rolling.RollingFileAppender
-log4j.appender.TIME.Append = false
-log4j.appender.TIME.BufferedIO = true
-log4j.appender.TIME.BufferSize = 1000
-log4j.appender.TIME.File = target/EnhancedRollingFileAppender/ignoredTime.log
-log4j.appender.TIME.ImmediateFlush = false
-log4j.appender.TIME.layout = org.apache.log4j.SimpleLayout
-log4j.appender.TIME.triggeringPolicy = org.apache.log4j.rolling.TimeBasedRollingPolicy
-# It is explicitly not a TimeBasedRolling
-log4j.appender.TIME.rollingPolicy = org.apache.log4j.rolling.FixedWindowRollingPolicy
-log4j.appender.TIME.rollingPolicy.ActiveFileName = target/EnhancedRollingFileAppender/time.log
-log4j.appender.TIME.rollingPolicy.FileNamePattern = target/EnhancedRollingFileAppender/time.%d{yyyy-MM-dd}.log
-
-log4j.appender.SIZE = org.apache.log4j.rolling.RollingFileAppender
-log4j.appender.SIZE.Append = false
-log4j.appender.SIZE.BufferedIO = true
-log4j.appender.SIZE.BufferSize = 1000
-log4j.appender.SIZE.File = target/EnhancedRollingFileAppender/ignoredSize.log
-log4j.appender.SIZE.ImmediateFlush = false
-log4j.appender.SIZE.layout = org.apache.log4j.SimpleLayout
-log4j.appender.SIZE.FileName = target/EnhancedRollingFileAppender/size.log
-log4j.appender.SIZE.triggeringPolicy = org.apache.log4j.rolling.SizeBasedTriggeringPolicy
-log4j.appender.SIZE.triggeringPolicy.MaxFileSize = 10000000
-log4j.appender.SIZE.rollingPolicy = org.apache.log4j.rolling.FixedWindowRollingPolicy
-log4j.appender.SIZE.rollingPolicy.ActiveFileName = target/EnhancedRollingFileAppender/size.log
-log4j.appender.SIZE.rollingPolicy.FileNamePattern = target/EnhancedRollingFileAppender/size.%i.log
-log4j.appender.SIZE.rollingPolicy.MinIndex = 11
-log4j.appender.SIZE.rollingPolicy.MaxIndex = 20
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-EnhancedRollingFileAppender.xml b/log4j-1.2-api/src/test/resources/config-1.2/log4j-EnhancedRollingFileAppender.xml
deleted file mode 100644
index a568dc21ca2..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-EnhancedRollingFileAppender.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-FileAppender-with-props.properties b/log4j-1.2-api/src/test/resources/config-1.2/log4j-FileAppender-with-props.properties
deleted file mode 100644
index 56de9df9711..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-FileAppender-with-props.properties
+++ /dev/null
@@ -1,41 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-###############################################################################
-#
-# Log4J 1.2 Configuration.
-#
-
-hadoop.log.file=hadoop.log
-
-log4j.rootLogger=TRACE, FILE_APPENDER
-
-#
-# Rolling File Appender
-#
-hadoop.log.maxfilesize=256MB
-hadoop.log.maxbackupindex=20
-log4j.appender.FILE_APPENDER=org.apache.log4j.FileAppender
-log4j.appender.FILE_APPENDER.Append=false
-log4j.appender.FILE_APPENDER.BufferedIO=true
-log4j.appender.FILE_APPENDER.BufferSize=1000
-log4j.appender.FILE_APPENDER.File=${log4j.test.tmpdir}/${hadoop.log.file}
-log4j.appender.FILE_APPENDER.ImmediateFlush=false
-log4j.appender.FILE_APPENDER.layout=org.apache.log4j.PatternLayout
-
-# Pattern format: Date LogLevel LoggerName LogMessage
-log4j.appender.FILE_APPENDER.layout.ConversionPattern=%d{ISO8601} %p %c: %m%n
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-LevelRangeFilter.properties b/log4j-1.2-api/src/test/resources/config-1.2/log4j-LevelRangeFilter.properties
deleted file mode 100644
index b84788b417d..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-LevelRangeFilter.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.appender.LIST = org.apache.log4j.ListAppender
-log4j.appender.LIST.filter.1 = org.apache.log4j.varia.LevelRangeFilter
-log4j.appender.LIST.filter.1.LevelMin = INFO
-log4j.appender.LIST.filter.1.LevelMax = ERROR
-log4j.appender.LIST.filter.1.AcceptOnMatch = false
-log4j.rootLogger = debug, LIST
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-LevelRangeFilter.xml b/log4j-1.2-api/src/test/resources/config-1.2/log4j-LevelRangeFilter.xml
deleted file mode 100644
index ab4cdd7e5a4..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-LevelRangeFilter.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-NullAppender.properties b/log4j-1.2-api/src/test/resources/config-1.2/log4j-NullAppender.properties
deleted file mode 100644
index bb3bc83654b..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-NullAppender.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-###############################################################################
-#
-# Log4J 1.2 Configuration.
-#
-
-log4j.rootLogger=TRACE, NullAppender
-
-# Null Appender
-log4j.appender.NullAppender=org.apache.log4j.varia.NullAppender
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-NullAppender.xml b/log4j-1.2-api/src/test/resources/config-1.2/log4j-NullAppender.xml
deleted file mode 100644
index f030cb88371..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-NullAppender.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-RollingFileAppender-with-props.properties b/log4j-1.2-api/src/test/resources/config-1.2/log4j-RollingFileAppender-with-props.properties
deleted file mode 100644
index 9b897aed81f..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-RollingFileAppender-with-props.properties
+++ /dev/null
@@ -1,47 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-###############################################################################
-#
-# Log4J 1.2 Configuration.
-#
-
-hadoop.log.dir=target
-hadoop.log.file=hadoop.log
-
-log4j.rootLogger=TRACE, RFA
-
-#
-# Rolling File Appender - cap space usage at 5gb.
-#
-hadoop.log.maxfilesize=256MB
-hadoop.log.maxbackupindex=20
-log4j.appender.RFA=org.apache.log4j.RollingFileAppender
-log4j.appender.RFA.Append=false
-log4j.appender.RFA.BufferedIO=true
-log4j.appender.RFA.BufferSize=1000
-log4j.appender.RFA.File=${hadoop.log.dir}/${hadoop.log.file}
-log4j.appender.RFA.ImmediateFlush=false
-log4j.appender.RFA.MaxFileSize=${hadoop.log.maxfilesize}
-log4j.appender.RFA.MaxBackupIndex=${hadoop.log.maxbackupindex}
-
-log4j.appender.RFA.layout=org.apache.log4j.PatternLayout
-
-# Pattern format: Date LogLevel LoggerName LogMessage
-log4j.appender.RFA.layout.ConversionPattern=%d{ISO8601} %p %c: %m%n
-# Debugging Pattern format
-#log4j.appender.RFA.layout.ConversionPattern=%d{ISO8601} %-5p %c{2} (%F:%M(%L)) - %m%n
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-RollingFileAppender.properties b/log4j-1.2-api/src/test/resources/config-1.2/log4j-RollingFileAppender.properties
deleted file mode 100644
index 911ab683653..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-RollingFileAppender.properties
+++ /dev/null
@@ -1,42 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-###############################################################################
-#
-# Log4J 1.2 Configuration.
-#
-
-log4j.rootLogger=TRACE, RFA
-
-#
-# Rolling File Appender - cap space usage at 5gb.
-#
-log4j.appender.RFA=org.apache.log4j.RollingFileAppender
-log4j.appender.RFA.Append=false
-log4j.appender.RFA.BufferedIO=true
-log4j.appender.RFA.BufferSize=1000
-log4j.appender.RFA.File=target/hadoop.log
-log4j.appender.RFA.ImmediateFlush=false
-log4j.appender.RFA.MaxFileSize=256MB
-log4j.appender.RFA.MaxBackupIndex=20
-
-log4j.appender.RFA.layout=org.apache.log4j.PatternLayout
-
-# Pattern format: Date LogLevel LoggerName LogMessage
-log4j.appender.RFA.layout.ConversionPattern=%d{ISO8601} %p %c: %m%n
-# Debugging Pattern format
-#log4j.appender.RFA.layout.ConversionPattern=%d{ISO8601} %-5p %c{2} (%F:%M(%L)) - %m%n
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-RollingFileAppender.xml b/log4j-1.2-api/src/test/resources/config-1.2/log4j-RollingFileAppender.xml
deleted file mode 100644
index 2ef6d18cbdd..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-RollingFileAppender.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-capitalization.properties b/log4j-1.2-api/src/test/resources/config-1.2/log4j-capitalization.properties
deleted file mode 100644
index c57d69690bf..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-capitalization.properties
+++ /dev/null
@@ -1,44 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-###############################################################################
-#
-# Log4J 1.2 Configuration.
-#
-
-log4j.rootLogger=TRACE, ConsoleCapitalized, ConsoleJavaStyle
-
-##############################################################################
-#
-# The Console log
-#
-
-log4j.appender.ConsoleCapitalized=org.apache.log4j.ConsoleAppender
-log4j.appender.ConsoleCapitalized.Encoding=ISO-8859-1
-log4j.appender.ConsoleCapitalized.Follow=true
-log4j.appender.ConsoleCapitalized.ImmediateFlush=false
-log4j.appender.ConsoleCapitalized.Target=System.err
-log4j.appender.ConsoleCapitalized.layout=org.apache.log4j.PatternLayout
-log4j.appender.ConsoleCapitalized.layout.ConversionPattern=%d{ISO8601} [%t][%c] %-5p: %m%n
-
-log4j.appender.ConsoleJavaStyle=org.apache.log4j.ConsoleAppender
-log4j.appender.ConsoleJavaStyle.Encoding=ISO-8859-1
-log4j.appender.ConsoleJavaStyle.Follow=true
-log4j.appender.ConsoleJavaStyle.ImmediateFlush=false
-log4j.appender.ConsoleJavaStyle.Target=System.err
-log4j.appender.ConsoleJavaStyle.layout=org.apache.log4j.PatternLayout
-log4j.appender.ConsoleJavaStyle.layout.ConversionPattern=%d{ISO8601} [%t][%c] %-5p: %m%n
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-capitalization.xml b/log4j-1.2-api/src/test/resources/config-1.2/log4j-capitalization.xml
deleted file mode 100644
index 272b79fc8d0..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-capitalization.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-EnhancedPatternLayout.properties b/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-EnhancedPatternLayout.properties
deleted file mode 100644
index 82bc2b82084..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-EnhancedPatternLayout.properties
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-###############################################################################
-#
-# Log4J 1.2 Configuration.
-#
-
-log4j.rootLogger=TRACE, Console
-
-##############################################################################
-#
-# The Console log
-#
-
-log4j.appender.Console=org.apache.log4j.ConsoleAppender
-log4j.appender.Console.Follow=true
-log4j.appender.Console.Target=System.err
-log4j.appender.Console.layout=org.apache.log4j.EnhancedPatternLayout
-log4j.appender.Console.layout.ConversionPattern=%d{ISO8601} [%t][%c] %-5p %X %x: %m%n
-
-log4j.logger.com.example.foo = DEBUG
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-EnhancedPatternLayout.xml b/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-EnhancedPatternLayout.xml
deleted file mode 100644
index 65c64d7fac1..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-EnhancedPatternLayout.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-HtmlLayout.properties b/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-HtmlLayout.properties
deleted file mode 100644
index 400c9e2172b..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-HtmlLayout.properties
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-###############################################################################
-#
-# Log4J 1.2 Configuration.
-#
-
-log4j.rootLogger=TRACE, Console
-
-##############################################################################
-#
-# The Console log
-#
-
-log4j.appender.Console=org.apache.log4j.ConsoleAppender
-log4j.appender.Console.Follow=true
-log4j.appender.Console.Target=System.err
-log4j.appender.Console.layout=org.apache.log4j.HTMLLayout
-log4j.appender.Console.layout.Title=Headline
-log4j.appender.Console.layout.LocationInfo=true
-
-log4j.logger.com.example.foo = DEBUG
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-HtmlLayout.xml b/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-HtmlLayout.xml
deleted file mode 100644
index 36aeeb3938e..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-HtmlLayout.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-PatternLayout.properties b/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-PatternLayout.properties
deleted file mode 100644
index 139d25bde2e..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-PatternLayout.properties
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-###############################################################################
-#
-# Log4J 1.2 Configuration.
-#
-
-log4j.rootLogger=TRACE, Console
-
-##############################################################################
-#
-# The Console log
-#
-
-log4j.appender.Console=org.apache.log4j.ConsoleAppender
-log4j.appender.Console.Follow=true
-log4j.appender.Console.Target=System.err
-log4j.appender.Console.layout=org.apache.log4j.PatternLayout
-log4j.appender.Console.layout.ConversionPattern=%d{ISO8601} [%t][%c] %-5p: %m%n
-
-log4j.logger.com.example.foo = DEBUG
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-PatternLayout.xml b/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-PatternLayout.xml
deleted file mode 100644
index e1dd2a91c87..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-PatternLayout.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-SimpleLayout.properties b/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-SimpleLayout.properties
deleted file mode 100644
index fce9cd926a2..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-SimpleLayout.properties
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-###############################################################################
-#
-# Log4J 1.2 Configuration.
-#
-
-log4j.rootLogger=TRACE, Console
-
-##############################################################################
-#
-# The Console log
-#
-
-log4j.appender.Console=org.apache.log4j.ConsoleAppender
-log4j.appender.Console.Follow=true
-log4j.appender.Console.Target=System.err
-log4j.appender.Console.layout=org.apache.log4j.SimpleLayout
-
-log4j.logger.com.example.foo = DEBUG
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-SimpleLayout.xml b/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-SimpleLayout.xml
deleted file mode 100644
index 7d498484322..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-SimpleLayout.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-TTCCLayout.properties b/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-TTCCLayout.properties
deleted file mode 100644
index 011cef594b3..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-TTCCLayout.properties
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-###############################################################################
-#
-# Log4J 1.2 Configuration.
-#
-
-log4j.rootLogger=TRACE, Console
-
-##############################################################################
-#
-# The Console log
-#
-
-log4j.appender.Console=org.apache.log4j.ConsoleAppender
-log4j.appender.Console.Follow=true
-log4j.appender.Console.Target=System.err
-log4j.appender.Console.layout=org.apache.log4j.TTCCLayout
-log4j.appender.Console.layout.ThreadPrinting=false
-log4j.appender.Console.layout.CategoryPrefixing=false
-log4j.appender.Console.layout.ContextPrinting=false
-log4j.appender.Console.layout.DateFormat=ISO8601
-log4j.appender.Console.layout.TimeZone=CET
-
-log4j.logger.com.example.foo = DEBUG
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-TTCCLayout.xml b/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-TTCCLayout.xml
deleted file mode 100644
index 574716eb5c9..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-TTCCLayout.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-XmlLayout.properties b/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-XmlLayout.properties
deleted file mode 100644
index bcf117148aa..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-console-XmlLayout.properties
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-###############################################################################
-#
-# Log4J 1.2 Configuration.
-#
-
-log4j.rootLogger=TRACE, Console
-
-##############################################################################
-#
-# The Console log
-#
-
-log4j.appender.Console=org.apache.log4j.ConsoleAppender
-log4j.appender.Console.Follow=true
-log4j.appender.Console.Target=System.err
-log4j.appender.Console.layout=org.apache.log4j.xml.XMLLayout
-log4j.appender.Console.layout.LocationInfo=true
-log4j.appender.Console.layout.Properties=false
-
-log4j.logger.com.example.foo = DEBUG
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-defaultValues.properties b/log4j-1.2-api/src/test/resources/config-1.2/log4j-defaultValues.properties
deleted file mode 100644
index b8815d325dd..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-defaultValues.properties
+++ /dev/null
@@ -1,82 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-##############################################################################
-#
-# Configuration file with minimal number of non-default values
-#
-log4j.rootLogger = TRACE, HTMLLayout, PatternLayout, TTCCLayout, XMLLayout,\
-ConsoleAppender, DailyRollingFileAppender, FileAppender, RollingFileAppender
-
-##############################################################################
-#
-# HTMLLayout
-#
-log4j.appender.HTMLLayout=org.apache.log4j.ConsoleAppender
-log4j.appender.HTMLLayout.layout=org.apache.log4j.HTMLLayout
-
-##############################################################################
-#
-# PatternLayout
-#
-log4j.appender.PatternLayout=org.apache.log4j.ConsoleAppender
-log4j.appender.PatternLayout.layout=org.apache.log4j.PatternLayout
-
-##############################################################################
-#
-# TTCCLayout
-#
-log4j.appender.TTCCLayout=org.apache.log4j.ConsoleAppender
-log4j.appender.TTCCLayout.layout=org.apache.log4j.TTCCLayout
-
-##############################################################################
-#
-# XMLLayout
-#
-log4j.appender.XMLLayout=org.apache.log4j.ConsoleAppender
-log4j.appender.XMLLayout.layout=org.apache.log4j.xml.XMLLayout
-
-##############################################################################
-#
-# ConsoleAppender
-#
-log4j.appender.ConsoleAppender=org.apache.log4j.ConsoleAppender
-log4j.appender.ConsoleAppender.layout=org.apache.log4j.SimpleLayout
-
-##############################################################################
-#
-# DailyRollingFileAppender
-#
-log4j.appender.DailyRollingFileAppender=org.apache.log4j.DailyRollingFileAppender
-log4j.appender.DailyRollingFileAppender.File=target/dailyRollingFileAppender
-log4j.appender.DailyRollingFileAppender.layout=org.apache.log4j.SimpleLayout
-
-##############################################################################
-#
-# FileAppender
-#
-log4j.appender.FileAppender=org.apache.log4j.FileAppender
-log4j.appender.FileAppender.File=target/fileAppender
-log4j.appender.FileAppender.layout=org.apache.log4j.SimpleLayout
-
-##############################################################################
-#
-# RollingFileAppender
-#
-log4j.appender.RollingFileAppender=org.apache.log4j.RollingFileAppender
-log4j.appender.RollingFileAppender.File=target/rollingFileAppender
-log4j.appender.RollingFileAppender.layout=org.apache.log4j.SimpleLayout
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-defaultValues.xml b/log4j-1.2-api/src/test/resources/config-1.2/log4j-defaultValues.xml
deleted file mode 100644
index 2def3f6d6a3..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-defaultValues.xml
+++ /dev/null
@@ -1,66 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-file-SimpleLayout.properties b/log4j-1.2-api/src/test/resources/config-1.2/log4j-file-SimpleLayout.properties
deleted file mode 100644
index 5cf42b5b637..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-file-SimpleLayout.properties
+++ /dev/null
@@ -1,38 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-###############################################################################
-#
-# Log4J 1.2 Configuration.
-#
-
-log4j.rootLogger=TRACE, File
-
-##############################################################################
-#
-# The Console log
-#
-
-log4j.appender.File=org.apache.log4j.FileAppender
-log4j.appender.File.Append=false
-log4j.appender.File.BufferedIO=true
-log4j.appender.File.BufferSize=1000
-log4j.appender.File.File=target/mylog.txt
-log4j.appender.File.ImmediateFlush=false
-log4j.appender.File.layout=org.apache.log4j.SimpleLayout
-
-log4j.logger.com.example.foo = DEBUG
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-file-SimpleLayout.xml b/log4j-1.2-api/src/test/resources/config-1.2/log4j-file-SimpleLayout.xml
deleted file mode 100644
index 90b3f3095ff..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-file-SimpleLayout.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-global-threshold.properties b/log4j-1.2-api/src/test/resources/config-1.2/log4j-global-threshold.properties
deleted file mode 100644
index 3171c4066c6..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-global-threshold.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.threshold = info
-log4j.appender.LIST = org.apache.log4j.ListAppender
-log4j.rootLogger = debug, LIST
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-global-threshold.xml b/log4j-1.2-api/src/test/resources/config-1.2/log4j-global-threshold.xml
deleted file mode 100644
index 82c48a0dfb7..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-global-threshold.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-system-properties-1.properties b/log4j-1.2-api/src/test/resources/config-1.2/log4j-system-properties-1.properties
deleted file mode 100644
index 4aebc427819..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-system-properties-1.properties
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-###############################################################################
-#
-# Log4J 1.2 Configuration.
-#
-
-hadoop.log.file=hadoop.log
-
-log4j.rootLogger=TRACE, RFA
-
-#
-# Rolling File Appender
-#
-log4j.appender.RFA=org.apache.log4j.RollingFileAppender
-log4j.appender.RFA.Append=false
-log4j.appender.RFA.BufferedIO=true
-log4j.appender.RFA.BufferSize=1000
-log4j.appender.RFA.File=${java.io.tmpdir}/${hadoop.log.file}
-log4j.appender.RFA.ImmediateFlush=false
-log4j.appender.RFA.MaxBackupIndex=16
-log4j.appender.RFA.MaxFileSize=20 MB
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-system-properties-1.xml b/log4j-1.2-api/src/test/resources/config-1.2/log4j-system-properties-1.xml
deleted file mode 100644
index 2ed5554337e..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-system-properties-1.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-system-properties-2.properties b/log4j-1.2-api/src/test/resources/config-1.2/log4j-system-properties-2.properties
deleted file mode 100644
index f635f194276..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-system-properties-2.properties
+++ /dev/null
@@ -1,38 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-###############################################################################
-#
-# Log4J 1.2 Configuration.
-#
-
-hadoop.log.dir=${java.io.tmpdir}
-hadoop.log.file=hadoop.log
-
-log4j.rootLogger=TRACE, RFA
-
-#
-# Rolling File Appender
-#
-log4j.appender.RFA=org.apache.log4j.RollingFileAppender
-log4j.appender.RFA.Append=false
-log4j.appender.RFA.BufferedIO=true
-log4j.appender.RFA.BufferSize=1000
-log4j.appender.RFA.File=${hadoop.log.dir}/${hadoop.log.file}
-log4j.appender.RFA.ImmediateFlush=false
-log4j.appender.RFA.MaxBackupIndex=16
-log4j.appender.RFA.MaxBackupSize=20 MB
diff --git a/log4j-1.2-api/src/test/resources/config-1.2/log4j-untrimmed.properties b/log4j-1.2-api/src/test/resources/config-1.2/log4j-untrimmed.properties
deleted file mode 100644
index 116859ae741..00000000000
--- a/log4j-1.2-api/src/test/resources/config-1.2/log4j-untrimmed.properties
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-###
-# Warning: this file contains INTENTIONAL trailing spaces on all properties
-#
-
-log4j.threshold = INFO
-
-log4j.appender.Console = org.apache.log4j.ConsoleAppender
-log4j.appender.Console.layout = org.apache.log4j.SimpleLayout
-log4j.appender.Console.filter.1 = org.apache.log4j.varia.DenyAllFilter
-
-log4j.rootLogger = DEBUG , Console
diff --git a/log4j-1.2-api/src/test/resources/hello.vm b/log4j-1.2-api/src/test/resources/hello.vm
deleted file mode 100644
index 5ce97550285..00000000000
--- a/log4j-1.2-api/src/test/resources/hello.vm
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- #set( $foo = "Velocity" )
-Hello $foo World!
-
-
\ No newline at end of file
diff --git a/log4j-1.2-api/src/test/resources/log-RouteWithMDC.xml b/log4j-1.2-api/src/test/resources/log-RouteWithMDC.xml
deleted file mode 100644
index 7de6461c4a8..00000000000
--- a/log4j-1.2-api/src/test/resources/log-RouteWithMDC.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j-multipleFilters.properties b/log4j-1.2-api/src/test/resources/log4j-multipleFilters.properties
deleted file mode 100644
index 556a4c1bd69..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j-multipleFilters.properties
+++ /dev/null
@@ -1,69 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.appender.LIST=org.apache.log4j.ListAppender
-log4j.appender.LIST.Threshold=DEBUG
-log4j.appender.LIST.filter.1=org.apache.log4j.config.StartsWithFilter
-log4j.appender.LIST.filter.2=org.apache.log4j.varia.LevelMatchFilter
-log4j.appender.LIST.filter.2.LevelToMatch=INFO
-log4j.appender.LIST.filter.2.AcceptOnMatch=true
-log4j.appender.LIST.filter.3=org.apache.log4j.varia.DenyAllFilter
-
-log4j.appender.LIST2=org.apache.logging.log4j.test.appender.ListAppender
-log4j.appender.LIST2.Threshold=DEBUG
-log4j.appender.LIST2.filter.1=org.apache.log4j.config.StartsWithFilter
-log4j.appender.LIST2.filter.2=org.apache.log4j.varia.LevelMatchFilter
-log4j.appender.LIST2.filter.2.LevelToMatch=INFO
-log4j.appender.LIST2.filter.2.AcceptOnMatch=true
-log4j.appender.LIST2.filter.3=org.apache.log4j.varia.DenyAllFilter
-
-log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
-log4j.appender.CONSOLE.Threshold=DEBUG
-log4j.appender.CONSOLE.filter.1=org.apache.log4j.config.StartsWithFilter
-log4j.appender.CONSOLE.filter.2=org.apache.log4j.varia.LevelMatchFilter
-log4j.appender.CONSOLE.filter.2.LevelToMatch=INFO
-log4j.appender.CONSOLE.filter.2.AcceptOnMatch=true
-log4j.appender.CONSOLE.filter.3=org.apache.log4j.varia.DenyAllFilter
-
-log4j.appender.FILE=org.apache.log4j.FileAppender
-log4j.appender.FILE.Threshold=DEBUG
-log4j.appender.FILE.File=${test.tmpDir}/file-appender.log
-log4j.appender.FILE.filter.1=org.apache.log4j.config.StartsWithFilter
-log4j.appender.FILE.filter.2=org.apache.log4j.varia.LevelMatchFilter
-log4j.appender.FILE.filter.2.LevelToMatch=INFO
-log4j.appender.FILE.filter.2.AcceptOnMatch=true
-log4j.appender.FILE.filter.3=org.apache.log4j.varia.DenyAllFilter
-
-log4j.appender.RFA=org.apache.log4j.RollingFileAppender
-log4j.appender.RFA.Threshold=DEBUG
-log4j.appender.RFA.File=${test.tmpDir}/rolling-file-appender.log
-log4j.appender.RFA.filter.1=org.apache.log4j.config.StartsWithFilter
-log4j.appender.RFA.filter.2=org.apache.log4j.varia.LevelMatchFilter
-log4j.appender.RFA.filter.2.LevelToMatch=INFO
-log4j.appender.RFA.filter.2.AcceptOnMatch=true
-log4j.appender.RFA.filter.3=org.apache.log4j.varia.DenyAllFilter
-
-log4j.appender.DRFA=org.apache.log4j.DailyRollingFileAppender
-log4j.appender.DRFA.Threshold=DEBUG
-log4j.appender.DRFA.File=${test.tmpDir}/daily-rolling-file-appender.log
-log4j.appender.DRFA.filter.1=org.apache.log4j.config.StartsWithFilter
-log4j.appender.DRFA.filter.2=org.apache.log4j.varia.LevelMatchFilter
-log4j.appender.DRFA.filter.2.LevelToMatch=INFO
-log4j.appender.DRFA.filter.2.AcceptOnMatch=true
-log4j.appender.DRFA.filter.3=org.apache.log4j.varia.DenyAllFilter
-
-log4j.rootLogger=TRACE, LIST, LIST2, CONSOLE, FILE, RFA, DRFA
diff --git a/log4j-1.2-api/src/test/resources/log4j-multipleFilters.xml b/log4j-1.2-api/src/test/resources/log4j-multipleFilters.xml
deleted file mode 100644
index 092d342f549..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j-multipleFilters.xml
+++ /dev/null
@@ -1,92 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j.xml b/log4j-1.2-api/src/test/resources/log4j.xml
deleted file mode 100644
index 478a92e0311..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/RFA1.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/RFA1.properties
deleted file mode 100644
index 1a81ab8d13d..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/RFA1.properties
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootLogger=DEBUG, testAppender
-log4j.appender.testAppender=org.apache.log4j.RollingFileAppender
-log4j.appender.testAppender.file=output/RFA-test1.log
-log4j.appender.testAppender.Append=false
-log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=%m\n
-log4j.appender.testAppender.maxFileSize=100
-
-# Prevent internal log4j DEBUG messages from polluting the output.
-log4j.logger.org.apache.log4j.PropertyConfigurator=INFO
-log4j.logger.org.apache.log4j.config.PropertySetter=INFO
-log4j.logger.org.apache.log4j.FileAppender=INFO
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/defaultInit3.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/defaultInit3.properties
deleted file mode 100644
index d9191bea106..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/defaultInit3.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=DEBUG, D3
-log4j.appender.D3=org.apache.log4j.FileAppender
-log4j.appender.D3.File=output/temp
-log4j.appender.D3.Append=false
-log4j.appender.D3.layout=org.apache.log4j.PatternLayout
-log4j.appender.D3.layout.ConversionPattern=%d [%t] %-5p %.16c - %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/fallback1.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/fallback1.properties
deleted file mode 100644
index fb4bfc8cc2c..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/fallback1.properties
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.debug=true
-log4j.appender.PRIMARY=org.apache.log4j.FileAppender
-log4j.appender.PRIMARY.errorhandler=org.apache.log4j.varia.FallbackErrorHandler
-log4j.appender.PRIMARY.errorhandler.root-ref=true
-log4j.appender.PRIMARY.errorhandler.appender-ref=FALLBACK
-log4j.appender.PRIMARY.file=/xyz/:x.log
-log4j.appender.PRIMARY.append=false
-log4j.appender.PRIMARY.layout=org.apache.log4j.PatternLayout
-log4j.appender.PRIMARY.layout.conversionPattern=%-5p %c{2} - %m%n
-
-log4j.appender.FALLBACK=org.apache.log4j.FileAppender
-log4j.appender.FALLBACK.File=output/temp
-log4j.appender.FALLBACK.Append=false
-log4j.appender.FALLBACK.layout=org.apache.log4j.PatternLayout
-log4j.appender.FALLBACK.layout.ConversionPattern=FALLBACK - %c - %m%n
-
-log4j.rootLogger=DEBUG, PRIMARY
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/filter1.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/filter1.properties
deleted file mode 100644
index c2168ab02f2..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/filter1.properties
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.appender.ROLLING=org.apache.log4j.PropertyConfiguratorTest$RollingFileAppender
-log4j.appender.ROLLING.append=false
-log4j.appender.ROLLING.rollingPolicy=org.apache.log4j.PropertyConfiguratorTest$FixedWindowRollingPolicy
-log4j.appender.ROLLING.rollingPolicy.activeFileName=filterBase-test1.log
-log4j.appender.ROLLING.rollingPolicy.fileNamePattern=filterBased-test1.%i
-log4j.appender.ROLLING.rollingPolicy.minIndex=0
-log4j.appender.ROLLING.triggeringPolicy=org.apache.log4j.PropertyConfiguratorTest$FilterBasedTriggeringPolicy
-log4j.appender.ROLLING.triggeringPolicy.filter=org.apache.log4j.varia.LevelRangeFilter
-log4j.appender.ROLLING.triggeringPolicy.filter.levelMin=info
-log4j.appender.ROLLING.layout=org.apache.log4j.PatternLayout
-log4j.appender.ROLLING.layout.ConversionPattern=%m%n
-log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
-log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
-log4j.appender.CONSOLE.layout.ConversionPattern=%m%n
-log4j.logger.org.apache.log4j.PropertyConfiguratorTest=debug, ROLLING
-log4j.additivity.org.apache.log4j.rolling.FilterBasedRollingTest=false
-log4j.roolLogger=info, CONSOLE
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/hierarchyThreshold1.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/hierarchyThreshold1.properties
deleted file mode 100644
index e9260a12c5e..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/hierarchyThreshold1.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.threshold=OFF
-log4j.rootLogger=,A
-log4j.appender.A=org.apache.log4j.FileAppender
-log4j.appender.A.File=output/temp
-log4j.appender.A.Append=false
-log4j.appender.A.layout=org.apache.log4j.PatternLayout
-log4j.appender.A.layout.ConversionPattern=%p [%t] %c{2} = %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/hierarchyThreshold2.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/hierarchyThreshold2.properties
deleted file mode 100644
index ff042bf71fa..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/hierarchyThreshold2.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.threshold=FATAL
-log4j.rootLogger=,A
-log4j.appender.A=org.apache.log4j.FileAppender
-log4j.appender.A.File=output/temp
-log4j.appender.A.Append=false
-log4j.appender.A.layout=org.apache.log4j.PatternLayout
-log4j.appender.A.layout.ConversionPattern=%p [%t] %c{2} = %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/hierarchyThreshold3.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/hierarchyThreshold3.properties
deleted file mode 100644
index ce35952b4d7..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/hierarchyThreshold3.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.threshold=ERROR
-log4j.rootLogger=,A
-log4j.appender.A=org.apache.log4j.FileAppender
-log4j.appender.A.File=output/temp
-log4j.appender.A.Append=false
-log4j.appender.A.layout=org.apache.log4j.PatternLayout
-log4j.appender.A.layout.ConversionPattern=%p [%t] %c{2} = %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/hierarchyThreshold4.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/hierarchyThreshold4.properties
deleted file mode 100644
index e503cf83521..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/hierarchyThreshold4.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.threshold=WARN
-log4j.rootLogger=,A
-log4j.appender.A=org.apache.log4j.FileAppender
-log4j.appender.A.File=output/temp
-log4j.appender.A.Append=false
-log4j.appender.A.layout=org.apache.log4j.PatternLayout
-log4j.appender.A.layout.ConversionPattern=%p [%t] %c{2} = %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/hierarchyThreshold5.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/hierarchyThreshold5.properties
deleted file mode 100644
index d870d80d18d..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/hierarchyThreshold5.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.threshold=INFO
-log4j.rootLogger=,A
-log4j.appender.A=org.apache.log4j.FileAppender
-log4j.appender.A.File=output/temp
-log4j.appender.A.Append=false
-log4j.appender.A.layout=org.apache.log4j.PatternLayout
-log4j.appender.A.layout.ConversionPattern=%p [%t] %c{2} = %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/hierarchyThreshold6.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/hierarchyThreshold6.properties
deleted file mode 100644
index a77dae331bf..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/hierarchyThreshold6.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.threshold=DEBUG
-log4j.rootLogger=,A
-log4j.appender.A=org.apache.log4j.FileAppender
-log4j.appender.A.File=output/temp
-log4j.appender.A.Append=false
-log4j.appender.A.layout=org.apache.log4j.PatternLayout
-log4j.appender.A.layout.ConversionPattern=%p [%t] %c{2} = %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/hierarchyThreshold7.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/hierarchyThreshold7.properties
deleted file mode 100644
index 8602ac3c11c..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/hierarchyThreshold7.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.threshold=TRACE#org.apache.log4j.xml.XLevel
-log4j.rootLogger=ALL,A
-log4j.appender.A=org.apache.log4j.FileAppender
-log4j.appender.A.File=output/temp
-log4j.appender.A.Append=false
-log4j.appender.A.layout=org.apache.log4j.PatternLayout
-log4j.appender.A.layout.ConversionPattern=%p [%t] %c{2} = %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/hierarchyThreshold8.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/hierarchyThreshold8.properties
deleted file mode 100644
index 6408afd4512..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/hierarchyThreshold8.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.threshold=ALL
-log4j.rootLogger=ALL,A
-log4j.appender.A=org.apache.log4j.FileAppender
-log4j.appender.A.File=output/temp
-log4j.appender.A.Append=false
-log4j.appender.A.layout=org.apache.log4j.PatternLayout
-log4j.appender.A.layout.ConversionPattern=%p [%t] %c{2} = %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout.mdc.1.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout.mdc.1.properties
deleted file mode 100644
index e228b49dbb0..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout.mdc.1.properties
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=DEBUG, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.File=output/temp
-log4j.appender.testAppender.Append=false
-log4j.appender.testAppender.layout=org.apache.log4j.EnhancedPatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=%-5p - %m %X%n
-
-# Prevent internal log4j DEBUG messages from polluting the output.
-log4j.logger.org.apache.log4j.PropertyConfigurator=INFO
-log4j.logger.org.apache.log4j.config.PropertySetter=INFO
-log4j.logger.org.apache.log4j.FileAppender=INFO
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout1.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout1.properties
deleted file mode 100644
index 3c2b837eb27..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout1.properties
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootLogger=DEBUG, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.file=output/temp
-log4j.appender.testAppender.Append=false
-log4j.appender.testAppender.layout=org.apache.log4j.EnhancedPatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=%-5p - %m%n
-
-# Prevent internal log4j DEBUG messages from polluting the output.
-log4j.logger.org.apache.log4j.PropertyConfigurator=INFO
-log4j.logger.org.apache.log4j.config.PropertySetter=INFO
-log4j.logger.org.apache.log4j.FileAppender=INFO
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout10.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout10.properties
deleted file mode 100644
index e8eef911699..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout10.properties
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=DEBUG, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.File=output/temp
-log4j.appender.testAppender.Append= false
-log4j.appender.testAppender.layout=org.apache.log4j.EnhancedPatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=[%t] %-5p %l: %m%n
-
-# Prevent internal log4j DEBUG messages from polluting the output.
-log4j.logger.org.apache.log4j.PropertyConfigurator=INFO
-log4j.logger.org.apache.log4j.config.PropertySetter=INFO
-log4j.logger.org.apache.log4j.FileAppender=INFO
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout11.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout11.properties
deleted file mode 100644
index 67bb7177627..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout11.properties
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=DEBUG, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.File=output/temp
-log4j.appender.testAppender.Append=false
-log4j.appender.testAppender.layout=org.apache.log4j.EnhancedPatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=%-5p [%t] %c{2}: %m%n
-
-# Prevent internal log4j DEBUG messages from polluting the output.
-log4j.logger.org.apache.log4j.PropertyConfigurator=INFO
-log4j.logger.org.apache.log4j.config.PropertySetter=INFO
-log4j.logger.org.apache.log4j.FileAppender=INFO
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout12.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout12.properties
deleted file mode 100644
index d1753a9d953..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout12.properties
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=DEBUG, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.File=output/temp
-log4j.appender.testAppender.Append=false
-log4j.appender.testAppender.layout=org.apache.log4j.EnhancedPatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=[%t] %-5p %C.%M(%F:%L): %m%n
-
-# Prevent internal log4j DEBUG messages from polluting the output.
-log4j.logger.org.apache.log4j.PropertyConfigurator=INFO
-log4j.logger.org.apache.log4j.config.PropertySetter=INFO
-log4j.logger.org.apache.log4j.FileAppender=INFO
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout13.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout13.properties
deleted file mode 100644
index 6998d503b55..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout13.properties
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=DEBUG, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.File=output/temp
-log4j.appender.testAppender.Append=false
-log4j.appender.testAppender.layout=org.apache.log4j.EnhancedPatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=[%t] %-5p %C{3}.%M(%F:%L): %m%n
-
-# Prevent internal log4j DEBUG messages from polluting the output.
-log4j.logger.org.apache.log4j.PropertyConfigurator=INFO
-log4j.logger.org.apache.log4j.config.PropertySetter=INFO
-log4j.logger.org.apache.log4j.FileAppender=INFO
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout14.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout14.properties
deleted file mode 100644
index c7691decbe8..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout14.properties
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=DEBUG, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.File=output/temp
-log4j.appender.testAppender.Append=false
-log4j.appender.testAppender.layout=org.apache.log4j.EnhancedPatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=%-5p [%t] %c{1.}: %m%n
-
-# Prevent internal log4j DEBUG messages from polluting the output.
-log4j.logger.org.apache.log4j.PropertyConfigurator=INFO
-log4j.logger.org.apache.log4j.config.PropertySetter=INFO
-log4j.logger.org.apache.log4j.FileAppender=INFO
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout15.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout15.properties
deleted file mode 100644
index e9b58b1678e..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout15.properties
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=TRACE, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.File=output/temp
-log4j.appender.testAppender.Append=false
-log4j.appender.testAppender.layout=org.apache.log4j.EnhancedMyPatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=%5p %-4# - %m%n
-
-# Prevent internal log4j DEBUG messages from polluting the output.
-log4j.logger.org.apache.log4j.PropertyConfigurator=INFO
-log4j.logger.org.apache.log4j.config.PropertySetter=INFO
-log4j.logger.org.apache.log4j.FileAppender=INFO
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout16.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout16.properties
deleted file mode 100644
index 327175c15b7..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout16.properties
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=TRACE, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.File=output/patternLayout16.log
-log4j.appender.testAppender.Append=false
-log4j.appender.testAppender.layout=org.apache.log4j.EnhancedPatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss}{GMT}Z %d{yyyy-MM-dd HH:mm:ss}{GMT-6}-0600 - %m%n
-
-# Prevent internal log4j DEBUG messages from polluting the output.
-log4j.logger.org.apache.log4j.PropertyConfigurator=INFO
-log4j.logger.org.apache.log4j.config.PropertySetter=INFO
-log4j.logger.org.apache.log4j.FileAppender=INFO
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout2.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout2.properties
deleted file mode 100644
index a863c9d5379..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout2.properties
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=DEBUG, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.File=output/temp
-log4j.appender.testAppender.Append= false
-log4j.appender.testAppender.layout=org.apache.log4j.EnhancedPatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=%d{ISO8601} [%t] %-5p %.16c - %m%n
-
-# Prevent internal log4j DEBUG messages from polluting the output.
-log4j.logger.org.apache.log4j.PropertyConfigurator=INFO
-log4j.logger.org.apache.log4j.config.PropertySetter=INFO
-log4j.logger.org.apache.log4j.FileAppender=INFO
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout3.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout3.properties
deleted file mode 100644
index 093faca9f5a..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout3.properties
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=DEBUG, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.File=output/temp
-log4j.appender.testAppender.Append=false
-log4j.appender.testAppender.layout=org.apache.log4j.EnhancedPatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} [%t] %-5p %.16c - %m%n
-
-# Prevent internal log4j DEBUG messages from polluting the output.
-log4j.logger.org.apache.log4j.PropertyConfigurator=INFO
-log4j.logger.org.apache.log4j.config.PropertySetter=INFO
-log4j.logger.org.apache.log4j.FileAppender=INFO
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout4.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout4.properties
deleted file mode 100644
index 5d09b4aa5dc..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout4.properties
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=DEBUG, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.File=output/temp
-log4j.appender.testAppender.Append=false
-log4j.appender.testAppender.layout=org.apache.log4j.EnhancedPatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=%d{DATE} [%t] %-5p %.16c - %m%n
-
-# Prevent internal log4j DEBUG messages from polluting the output.
-log4j.logger.org.apache.log4j.PropertyConfigurator=INFO
-log4j.logger.org.apache.log4j.config.PropertySetter=INFO
-log4j.logger.org.apache.log4j.FileAppender=INFO
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout5.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout5.properties
deleted file mode 100644
index 5b0f3ceda41..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout5.properties
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=DEBUG, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.File=output/temp
-log4j.appender.testAppender.Append=false
-log4j.appender.testAppender.layout=org.apache.log4j.EnhancedPatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss,SSS} [%t] %-5p %.16c - %m%n
-
-# Prevent internal log4j DEBUG messages from polluting the output.
-log4j.logger.org.apache.log4j.PropertyConfigurator=INFO
-log4j.logger.org.apache.log4j.config.PropertySetter=INFO
-log4j.logger.org.apache.log4j.FileAppender=INFO
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout6.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout6.properties
deleted file mode 100644
index cd4f7c5f864..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout6.properties
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=DEBUG, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.File=output/temp
-log4j.appender.testAppender.Append=false
-log4j.appender.testAppender.layout=org.apache.log4j.EnhancedPatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=%d{ABSOLUTE} [%t] %-5p %.16c - %m%n
-
-
-# Prevent internal log4j DEBUG messages from polluting the output.
-log4j.logger.org.apache.log4j.PropertyConfigurator=INFO
-log4j.logger.org.apache.log4j.config.PropertySetter=INFO
-log4j.logger.org.apache.log4j.FileAppender=INFO
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout7.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout7.properties
deleted file mode 100644
index 00b3f7131a2..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout7.properties
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=DEBUG, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.File=output/temp
-log4j.appender.testAppender.Append=false
-log4j.appender.testAppender.layout=org.apache.log4j.EnhancedPatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=%d{HH:mm:ss,SSS} [%t] %-5p %.16c - %m%n
-
-# Prevent internal log4j DEBUG messages from polluting the output.
-log4j.logger.org.apache.log4j.PropertyConfigurator=INFO
-log4j.logger.org.apache.log4j.config.PropertySetter=INFO
-log4j.logger.org.apache.log4j.FileAppender=INFO
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout8.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout8.properties
deleted file mode 100644
index 67cde918108..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout8.properties
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=DEBUG, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.File=output/temp
-log4j.appender.testAppender.Append=false
-log4j.appender.testAppender.layout=org.apache.log4j.EnhancedPatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=%r [%t] %-5p %.16c - %m%n
-
-# Prevent internal log4j DEBUG messages from polluting the output.
-log4j.logger.org.apache.log4j.PropertyConfigurator=INFO
-log4j.logger.org.apache.log4j.config.PropertySetter=INFO
-log4j.logger.org.apache.log4j.FileAppender=INFO
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout9.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout9.properties
deleted file mode 100644
index 7ca09b8e4d1..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/pattern/enhancedPatternLayout9.properties
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=DEBUG, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.File=output/temp
-log4j.appender.testAppender.Append=false
-log4j.appender.testAppender.layout=org.apache.log4j.EnhancedPatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=[%t] %-5p %.16c : %m%n
-
-# Prevent internal log4j DEBUG messages from polluting the output.
-log4j.logger.org.apache.log4j.PropertyConfigurator=INFO
-log4j.logger.org.apache.log4j.config.PropertySetter=INFO
-log4j.logger.org.apache.log4j.FileAppender=INFO
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout.mdc.1.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout.mdc.1.properties
deleted file mode 100644
index 8e9b136261e..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout.mdc.1.properties
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=DEBUG, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.File=output/temp
-log4j.appender.testAppender.Append=false
-log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=%-5p - %m %X%n
-
-# Prevent internal log4j DEBUG messages from polluting the output.
-log4j.logger.org.apache.log4j.PropertyConfigurator=INFO
-log4j.logger.org.apache.log4j.config.PropertySetter=INFO
-log4j.logger.org.apache.log4j.FileAppender=INFO
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout1.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout1.properties
deleted file mode 100644
index aed43bbf02a..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout1.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=TRACE, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.File=output/temp
-log4j.appender.testAppender.Append=false
-log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=%-5p - %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout10.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout10.properties
deleted file mode 100644
index 73bdba89c4e..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout10.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=TRACE, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.File= output/temp
-log4j.appender.testAppender.Append= false
-log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=[%t] %-5p %l: %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout11.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout11.properties
deleted file mode 100644
index 8d985f8149f..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout11.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=TRACE, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.File=output/temp
-log4j.appender.testAppender.Append=false
-log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=%-5p [%t] %c{2}: %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout12.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout12.properties
deleted file mode 100644
index 85c9c4b8365..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout12.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=TRACE, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.File=output/temp
-log4j.appender.testAppender.Append=false
-log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=[%t] %-5p %C.%M(%F:%L): %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout13.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout13.properties
deleted file mode 100644
index 211a430e38d..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout13.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=TRACE, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.File= output/temp
-log4j.appender.testAppender.Append=false
-log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=[%t] %-5p %C{3}.%M(%F:%L): %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout14.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout14.properties
deleted file mode 100644
index 495775ba424..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout14.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=TRACE, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.File= output/temp
-log4j.appender.testAppender.Append=false
-log4j.appender.testAppender.layout=org.apache.log4j.MyPatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=%5p %-4# - %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout2.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout2.properties
deleted file mode 100644
index c6dc606e75e..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout2.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=TRACE, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.File=output/temp
-log4j.appender.testAppender.Append= false
-log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=%d{ISO8601} [%t] %-5p %.16c - %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout3.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout3.properties
deleted file mode 100644
index 5a413b4e81f..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout3.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=TRACE, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.File=output/temp
-log4j.appender.testAppender.Append=false
-log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} [%t] %-5p %.16c - %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout4.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout4.properties
deleted file mode 100644
index f03a494202a..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout4.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=TRACE, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.File=output/temp
-log4j.appender.testAppender.Append=false
-log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=%d{DATE} [%t] %-5p %.16c - %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout5.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout5.properties
deleted file mode 100644
index 20176088407..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout5.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=TRACE, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.File=output/temp
-log4j.appender.testAppender.Append=false
-log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss,SSS} [%t] %-5p %.16c - %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout6.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout6.properties
deleted file mode 100644
index aaa7c220838..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout6.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=TRACE, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.File=output/temp
-log4j.appender.testAppender.Append=false
-log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=%d{ABSOLUTE} [%t] %-5p %.16c - %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout7.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout7.properties
deleted file mode 100644
index 7c0c6f33b3a..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout7.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=TRACE, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.File=output/temp
-log4j.appender.testAppender.Append=false
-log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=%d{HH:mm:ss,SSS} [%t] %-5p %.16c - %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout8.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout8.properties
deleted file mode 100644
index 03272e5cf1f..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout8.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=TRACE, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.File=output/temp
-log4j.appender.testAppender.Append=false
-log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=%r [%t] %-5p %.16c - %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout9.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout9.properties
deleted file mode 100644
index b59c7a45bd9..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/patternLayout9.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootCategory=TRACE, testAppender
-log4j.appender.testAppender=org.apache.log4j.FileAppender
-log4j.appender.testAppender.File=output/temp
-log4j.appender.testAppender.Append=false
-log4j.appender.testAppender.layout=org.apache.log4j.PatternLayout
-log4j.appender.testAppender.layout.ConversionPattern=[%t] %-5p %.16c : %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/socketServer1.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/socketServer1.properties
deleted file mode 100644
index e4fea1cf1b5..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/socketServer1.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootLogger=TRACE, A
-log4j.logger.org.apache.log4j.test.ShortSocketServer=WARN
-log4j.logger.org.apache.log4j.net.SocketNode=WARN
-log4j.appender.A=org.apache.log4j.FileAppender
-log4j.appender.A.file=output/temp
-log4j.appender.A.Append=false
-log4j.appender.A.layout=org.apache.log4j.PatternLayout
-log4j.appender.A.layout.ConversionPattern=%5p %x [%t] %c %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/socketServer2.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/socketServer2.properties
deleted file mode 100644
index 9121f610039..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/socketServer2.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootLogger=TRACE, A
-log4j.logger.org.apache.log4j.test.ShortSocketServer=WARN
-log4j.logger.org.apache.log4j.net.SocketNode=WARN
-log4j.appender.A=org.apache.log4j.FileAppender
-log4j.appender.A.file=output/temp
-log4j.appender.A.Append=false
-log4j.appender.A.layout=org.apache.log4j.PatternLayout
-log4j.appender.A.layout.ConversionPattern=%5p %x [%t] %C (%F:%L) %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/socketServer3.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/socketServer3.properties
deleted file mode 100644
index 3cbea3c040f..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/socketServer3.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootLogger=TRACE, A
-log4j.Logger.org.apache.log4j.test.ShortSocketServer=WARN
-log4j.Logger.org.apache.log4j.net.SocketNode=WARN
-log4j.appender.A=org.apache.log4j.FileAppender
-log4j.appender.A.file=output/temp
-log4j.appender.A.Append=false
-log4j.appender.A.layout=org.apache.log4j.PatternLayout
-log4j.appender.A.layout.ConversionPattern=%5p %x [%t] %C (%F:%L) %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/socketServer4.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/socketServer4.properties
deleted file mode 100644
index f5fb662484e..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/socketServer4.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootLogger=TRACE, A
-log4j.Logger.org.apache.log4j.test.ShortSocketServer=WARN
-log4j.Logger.org.apache.log4j.net.SocketNode=WARN
-log4j.appender.A=org.apache.log4j.FileAppender
-log4j.appender.A.file=output/temp
-log4j.appender.A.Append=false
-log4j.appender.A.layout=org.apache.log4j.PatternLayout
-log4j.appender.A.layout.ConversionPattern=%5p %x %X{key1}%X{key4} [%t] %c{1} - %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/socketServer5.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/socketServer5.properties
deleted file mode 100644
index 4640cd3016c..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/socketServer5.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootLogger=TRACE, A
-log4j.Logger.org.apache.log4j.test.ShortSocketServer=WARN
-log4j.Logger.org.apache.log4j.net.SocketNode=WARN
-log4j.appender.A=org.apache.log4j.FileAppender
-log4j.appender.A.file=output/temp
-log4j.appender.A.Append=false
-log4j.appender.A.layout=org.apache.log4j.PatternLayout
-log4j.appender.A.layout.ConversionPattern=%5p %x %X{key1}%X{key5} [%t] %c{1} - %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/socketServer6.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/socketServer6.properties
deleted file mode 100644
index a5cb07d919a..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/socketServer6.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootLogger=TRACE, A
-log4j.Logger.org.apache.log4j.test.ShortSocketServer=WARN
-log4j.Logger.org.apache.log4j.net.SocketNode=WARN
-log4j.appender.A=org.apache.log4j.FileAppender
-log4j.appender.A.file=output/temp
-log4j.appender.A.Append=false
-log4j.appender.A.layout=org.apache.log4j.PatternLayout
-log4j.appender.A.layout.ConversionPattern=%5p %x %X{hostID} %X{key6} [%t] %c{1} - %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/socketServer7.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/socketServer7.properties
deleted file mode 100644
index fd07c4ef21a..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/socketServer7.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootLogger=TRACE, A
-log4j.Logger.org.apache.log4j.test.ShortSocketServer=WARN
-log4j.Logger.org.apache.log4j.net.SocketNode=WARN
-log4j.appender.A=org.apache.log4j.FileAppender
-log4j.appender.A.file=output/temp
-log4j.appender.A.Append=false
-log4j.appender.A.layout=org.apache.log4j.PatternLayout
-log4j.appender.A.layout.ConversionPattern=%5p %x %X{hostID} %X{key7} [%t] %c{1} - %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/socketServer8.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/socketServer8.properties
deleted file mode 100644
index 87b9cd03406..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/socketServer8.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootLogger=TRACE, A
-log4j.Logger.org.apache.log4j.test.ShortSocketServer=WARN
-log4j.Logger.org.apache.log4j.net.SocketNode=WARN
-log4j.appender.A=org.apache.log4j.FileAppender
-log4j.appender.A.file=output/temp
-log4j.appender.A.Append=false
-log4j.appender.A.layout=org.apache.log4j.PatternLayout
-log4j.appender.A.layout.ConversionPattern=%5p %x %X{hostID} %X{key8} [%t] %c{1} - %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/DOMTest4.xml b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/DOMTest4.xml
deleted file mode 100644
index e8a80ef5e98..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/DOMTest4.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
-]>
-
- &a1;
- &a2;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/DOMTest4_A1.xml b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/DOMTest4_A1.xml
deleted file mode 100644
index f24dda87654..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/DOMTest4_A1.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/DOMTest4_A2.xml b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/DOMTest4_A2.xml
deleted file mode 100644
index 00cdd55b766..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/DOMTest4_A2.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/DOMTestCase1.xml b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/DOMTestCase1.xml
deleted file mode 100644
index d637afad3b9..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/DOMTestCase1.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/SocketAppenderTestConfig.xml b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/SocketAppenderTestConfig.xml
deleted file mode 100644
index a83f440457c..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/SocketAppenderTestConfig.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/categoryfactory1.xml b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/categoryfactory1.xml
deleted file mode 100644
index 24812860d47..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/categoryfactory1.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/categoryfactory2.xml b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/categoryfactory2.xml
deleted file mode 100644
index eccea215c58..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/categoryfactory2.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/customLevel1.xml b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/customLevel1.xml
deleted file mode 100644
index 0a9e394e06f..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/customLevel1.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/customLevel2.xml b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/customLevel2.xml
deleted file mode 100644
index 9ebe5954be6..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/customLevel2.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/customLevel3.xml b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/customLevel3.xml
deleted file mode 100644
index 3d50a858495..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/customLevel3.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/customLevel4.xml b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/customLevel4.xml
deleted file mode 100644
index 5d74d7f333c..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/customLevel4.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/customLogger1.xml b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/customLogger1.xml
deleted file mode 100644
index 50ebffab2e6..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/customLogger1.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/customLogger2.xml b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/customLogger2.xml
deleted file mode 100644
index a3c84db2b52..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/customLogger2.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/customLogger3.xml b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/customLogger3.xml
deleted file mode 100644
index 0c50ea5be3f..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/customLogger3.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/defaultInit.xml b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/defaultInit.xml
deleted file mode 100644
index 868e66ae8de..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/defaultInit.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/fallback1.xml b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/fallback1.xml
deleted file mode 100644
index 1c6fd57f00e..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/fallback1.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/loggerfactory1.xml b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/loggerfactory1.xml
deleted file mode 100644
index 031f714d232..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/loggerfactory1.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/testReset.xml b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/testReset.xml
deleted file mode 100644
index b0e565008e0..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/testReset.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/throwableRenderer1.xml b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/throwableRenderer1.xml
deleted file mode 100644
index a8af90d6558..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/input/xml/throwableRenderer1.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/L7D_en_US.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/L7D_en_US.properties
deleted file mode 100644
index 0121fbe931c..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/L7D_en_US.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-test=This is the English, US test.
-hello_world=Hello world.
-msg1=This is test number {0} with string argument {1}.
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/L7D_fr.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/L7D_fr.properties
deleted file mode 100644
index 1c68863f210..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/L7D_fr.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-test=Ceci est le test en francais pour la France.
-hello_world=Bonjour la France.
-msg1=Ceci est le test numero {0} contenant l''argument {1}.
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/L7D_fr_CH.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/L7D_fr_CH.properties
deleted file mode 100644
index a6af2511118..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/L7D_fr_CH.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-test=Ceci est le test en francais pour la p'tite Suisse.
-hello world=Salut le monde.
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/TestLogSFPatterns.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/TestLogSFPatterns.properties
deleted file mode 100644
index 3d251346fbd..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/TestLogSFPatterns.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Iteration0=Iteration {}
-Hello1=Hello, World
-Malformed=Hello, {.
-Hello2=Hello, {}World
-Hello3=Hello, {}
-Hello4={}, {}.
-Hello5={}{} {}.
-Hello6={}{} {}{}
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/org/apache/log4j/TestLogMFPatterns.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/org/apache/log4j/TestLogMFPatterns.properties
deleted file mode 100644
index f5962dab3b8..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/org/apache/log4j/TestLogMFPatterns.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Iteration0=Iteration {0}
-Hello1=Hello, World
-Malformed=Hello, {.
-Hello2=Hello, {0}World
-Hello3=Hello, {0}
-Hello4={1}, {0}.
-Hello5={1}{2} {0}.
-Hello6={1}{2} {0}{3}
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/org/apache/log4j/TestLogSFPatterns.properties b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/org/apache/log4j/TestLogSFPatterns.properties
deleted file mode 100644
index 3d251346fbd..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/org/apache/log4j/TestLogSFPatterns.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-Iteration0=Iteration {}
-Hello1=Hello, World
-Malformed=Hello, {.
-Hello2=Hello, {}World
-Hello3=Hello, {}
-Hello4={}, {}.
-Hello5={}{} {}.
-Hello6={}{} {}{}
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/org/apache/log4j/rewrite/map.log b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/org/apache/log4j/rewrite/map.log
deleted file mode 100644
index 3ce933f832d..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/org/apache/log4j/rewrite/map.log
+++ /dev/null
@@ -1,3 +0,0 @@
-INFO org.apache.log4j.rewrite.RewriteAppenderTest - p1: p2: Message 0
-INFO org.apache.log4j.rewrite.RewriteAppenderTest - p1:Hello p2:World {p1=Hello, p2=World, x1=Mundo}
-INFO org.apache.log4j.rewrite.RewriteAppenderTest - p1:Hello p2:World Message 1
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/org/apache/log4j/rewrite/map.xml b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/org/apache/log4j/rewrite/map.xml
deleted file mode 100644
index 503a548156b..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/org/apache/log4j/rewrite/map.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/org/apache/log4j/rewrite/property.log b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/org/apache/log4j/rewrite/property.log
deleted file mode 100644
index 9aa2c499137..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/org/apache/log4j/rewrite/property.log
+++ /dev/null
@@ -1,2 +0,0 @@
-INFO org.apache.log4j.rewrite.RewriteAppenderTest - p1:Hello p2:World Message 0
-INFO org.apache.log4j.rewrite.RewriteAppenderTest - p1:Hola p2:World Message 1
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/org/apache/log4j/rewrite/property.xml b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/org/apache/log4j/rewrite/property.xml
deleted file mode 100644
index 62f872027e9..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/org/apache/log4j/rewrite/property.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/org/apache/log4j/rewrite/reflection.log b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/org/apache/log4j/rewrite/reflection.log
deleted file mode 100644
index da0b52f2dc4..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/org/apache/log4j/rewrite/reflection.log
+++ /dev/null
@@ -1,3 +0,0 @@
-INFO org.apache.log4j.rewrite.RewriteAppenderTest - p1: p2: Message 0
-INFO org.apache.log4j.rewrite.RewriteAppenderTest - p1: p2:Hello I am bean.
-INFO org.apache.log4j.rewrite.RewriteAppenderTest - p1:Hola p2:Hello Welcome to The Hub
diff --git a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/org/apache/log4j/rewrite/reflection.xml b/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/org/apache/log4j/rewrite/reflection.xml
deleted file mode 100644
index 7a96f185053..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-1.2.17/resources/org/apache/log4j/rewrite/reflection.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-appenders-custom-1.properties b/log4j-1.2-api/src/test/resources/log4j1-appenders-custom-1.properties
deleted file mode 100644
index c0d481e9353..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-appenders-custom-1.properties
+++ /dev/null
@@ -1,38 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
-log4j.appender.CONSOLE.Target=System.out
-log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
-log4j.appender.CONSOLE.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
-#
-log4j.appender.A1=org.apache.log4j.CustomNoopAppender
-log4j.appender.A1.booleanA=true
-log4j.appender.A1.intA=1
-log4j.appender.A1.stringA=A
-#
-log4j.appender.A2=org.apache.log4j.CustomFileAppender
-log4j.appender.A2.booleanA=true
-log4j.appender.A2.intA=1
-log4j.appender.A2.stringA=A
-log4j.appender.A2.File=target/temp.A2
-log4j.appender.A2.Append=false
-log4j.appender.A2.layout=org.apache.log4j.TTCCLayout
-log4j.appender.A2.layout.DateFormat=ISO8601
-#
-log4j.logger.org.apache.log4j.xml=trace, A1
-log4j.rootLogger=trace, A1, A2
diff --git a/log4j-1.2-api/src/test/resources/log4j1-appenders-custom-2.properties b/log4j-1.2-api/src/test/resources/log4j1-appenders-custom-2.properties
deleted file mode 100644
index f514396ff2a..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-appenders-custom-2.properties
+++ /dev/null
@@ -1,38 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
-log4j.appender.CONSOLE.Target=System.out
-log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
-log4j.appender.CONSOLE.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
-#
-log4j.appender.A1=org.apache.log4j.CustomNoopAppender
-log4j.appender.A1.booleanA=false
-log4j.appender.A1.intA=2
-log4j.appender.A1.stringA=B
-#
-log4j.appender.A2=org.apache.log4j.CustomFileAppender
-log4j.appender.A2.booleanA=false
-log4j.appender.A2.intA=2
-log4j.appender.A2.stringA=B
-log4j.appender.A2.File=target/temp.A2
-log4j.appender.A2.Append=false
-log4j.appender.A2.layout=org.apache.log4j.TTCCLayout
-log4j.appender.A2.layout.DateFormat=ISO8601
-#
-log4j.logger.org.apache.log4j.xml=trace, A1
-log4j.rootLogger=trace, A1, A2
diff --git a/log4j-1.2-api/src/test/resources/log4j1-async.properties b/log4j-1.2-api/src/test/resources/log4j1-async.properties
deleted file mode 100644
index 60333593aa9..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-async.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.appender.list=org.apache.log4j.ListAppender
-log4j.appender.list.layout=org.apache.log4j.PatternLayout
-log4j.appender.list.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
-log4j.appender.async=org.apache.log4j.AsyncAppender
-log4j.appender.async.appender-ref=list
-log4j.rootLogger=trace, async
diff --git a/log4j-1.2-api/src/test/resources/log4j1-async.xml b/log4j-1.2-api/src/test/resources/log4j1-async.xml
deleted file mode 100644
index 2eee705c0dd..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-async.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-file-1.properties b/log4j-1.2-api/src/test/resources/log4j1-file-1.properties
deleted file mode 100644
index a1a213b267b..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-file-1.properties
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
-log4j.appender.CONSOLE.Target=System.out
-log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
-log4j.appender.CONSOLE.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
-#
-log4j.appender.A1=org.apache.log4j.FileAppender
-log4j.appender.A1.File=target/temp.A1
-log4j.appender.A1.Append=false
-log4j.appender.A1.layout=org.apache.log4j.PatternLayout
-log4j.appender.A1.layout.ConversionPattern=%-5p %c{2} - %m%n
-#
-log4j.appender.A2=org.apache.log4j.FileAppender
-log4j.appender.A2.File=target/temp.A2
-log4j.appender.A2.Append=false
-log4j.appender.A2.layout=org.apache.log4j.TTCCLayout
-log4j.appender.A2.layout.DateFormat=ISO8601
-#
-log4j.logger.org.apache.log4j.xml=trace, A1
-log4j.rootLogger=trace, A1, A2
diff --git a/log4j-1.2-api/src/test/resources/log4j1-file-2.properties b/log4j-1.2-api/src/test/resources/log4j1-file-2.properties
deleted file mode 100644
index 5405fcddbdd..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-file-2.properties
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
-log4j.appender.CONSOLE.Target=System.out
-log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
-log4j.appender.CONSOLE.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
-#
-log4j.appender.A1=org.apache.log4j.FileAppender
-log4j.appender.A1.File=target/temp.A1
-log4j.appender.A1.Append=true
-log4j.appender.A1.layout=org.apache.log4j.PatternLayout
-log4j.appender.A1.layout.ConversionPattern=%-5p %c{2} - %m%n
-#
-log4j.appender.A2=org.apache.log4j.FileAppender
-log4j.appender.A2.File=target/temp.A2
-log4j.appender.A2.Append=true
-log4j.appender.A2.layout=org.apache.log4j.TTCCLayout
-log4j.appender.A2.layout.DateFormat=ISO8601
-#
-log4j.logger.org.apache.log4j.xml=trace, A1
-log4j.rootLogger=trace, A1, A2
diff --git a/log4j-1.2-api/src/test/resources/log4j1-file.xml b/log4j-1.2-api/src/test/resources/log4j1-file.xml
deleted file mode 100644
index cba42154bef..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-file.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-list.properties b/log4j-1.2-api/src/test/resources/log4j1-list.properties
deleted file mode 100644
index 8860b6e050a..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-list.properties
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.appender.list=org.apache.log4j.ListAppender
-log4j.appender.list.layout=org.apache.log4j.PatternLayout
-log4j.appender.list.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
-log4j.appender.events=org.apache.log4j.ListAppender
-log4j.rootLogger=trace, list, events
diff --git a/log4j-1.2-api/src/test/resources/log4j1-list.xml b/log4j-1.2-api/src/test/resources/log4j1-list.xml
deleted file mode 100644
index 478a92e0311..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-list.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-mapRewrite.xml b/log4j-1.2-api/src/test/resources/log4j1-mapRewrite.xml
deleted file mode 100644
index fb4a1c799d3..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-mapRewrite.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-rewrite.xml b/log4j-1.2-api/src/test/resources/log4j1-rewrite.xml
deleted file mode 100644
index bd0ea8c7bad..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-rewrite.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-rolling-properties.properties b/log4j-1.2-api/src/test/resources/log4j1-rolling-properties.properties
deleted file mode 100644
index 0e856c9b627..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-rolling-properties.properties
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-# Properties for substitution
-somelogfile=somefile.log
-maxfilesize=256MB
-maxbackupindex=20
-
-log4j.rootLogger=TRACE, RFA
-
-# Appender configuration with variables
-log4j.appender.RFA=org.apache.log4j.RollingFileAppender
-log4j.appender.RFA.File=${test.directory}/${somelogfile}
-log4j.appender.RFA.MaxFileSize=${maxfilesize}
-log4j.appender.RFA.MaxBackupIndex=${maxbackupindex}
-log4j.appender.RFA.layout=org.apache.log4j.PatternLayout
-log4j.appender.RFA.layout.ConversionPattern=%d{ISO8601} %p %c: %m%n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-rolling-properties.xml b/log4j-1.2-api/src/test/resources/log4j1-rolling-properties.xml
deleted file mode 100644
index 33910d18e13..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-rolling-properties.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-socket-xml-layout.properties b/log4j-1.2-api/src/test/resources/log4j1-socket-xml-layout.properties
deleted file mode 100644
index d72784d23dc..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-socket-xml-layout.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootLogger=DEBUG,socket
-log4j.appender.socket=org.apache.log4j.net.SocketAppender
-log4j.appender.socket.remoteHost=localhost
-log4j.appender.socket.port=9999
-log4j.appender.socket.reconnectionDelay=100
-log4j.appender.socket.layout=org.apache.log4j.xml.XMLLayout
-log4j.appender.socket.Threshold=DEBUG
diff --git a/log4j-1.2-api/src/test/resources/log4j1-socket.properties b/log4j-1.2-api/src/test/resources/log4j1-socket.properties
deleted file mode 100644
index 151ca7ed5d2..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-socket.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootLogger=DEBUG,socket
-log4j.appender.socket=org.apache.log4j.net.SocketAppender
-log4j.appender.socket.remoteHost=localhost
-log4j.appender.socket.port=9999
-log4j.appender.socket.reconnectionDelay=100
-log4j.appender.socket.layout=org.apache.log4j.PatternLayout
-log4j.appender.socket.layout.conversionPattern=Main[%pid] :%t: %c %-4p - %m\n
-log4j.appender.socket.Threshold=DEBUG
diff --git a/log4j-1.2-api/src/test/resources/log4j1-socket.xml b/log4j-1.2-api/src/test/resources/log4j1-socket.xml
deleted file mode 100644
index c9c7fad9550..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-socket.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-syslog-protocol-default.properties b/log4j-1.2-api/src/test/resources/log4j1-syslog-protocol-default.properties
deleted file mode 100644
index 967644f2233..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-syslog-protocol-default.properties
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootLogger=DEBUG,syslog
-log4j.appender.syslog=org.apache.log4j.net.SyslogAppender
-log4j.appender.syslog.Threshold=DEBUG
-log4j.appender.syslog.syslogHost=localhost:${syslog.port}
-log4j.appender.syslog.header=true
-log4j.appender.syslog.Facility=LOCAL3
-log4j.appender.syslog.layout=org.apache.log4j.PatternLayout
-log4j.appender.syslog.layout.conversionPattern=Main[%pid] :%t: %c %-4p - %m\n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-syslog-protocol-tcp.properties b/log4j-1.2-api/src/test/resources/log4j1-syslog-protocol-tcp.properties
deleted file mode 100644
index be6a4887460..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-syslog-protocol-tcp.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootLogger=DEBUG,syslog
-log4j.appender.syslog=org.apache.log4j.net.SyslogAppender
-log4j.appender.syslog.Threshold=DEBUG
-log4j.appender.syslog.syslogHost=localhost:${syslog.port}
-log4j.appender.syslog.protocol=TCP
-log4j.appender.syslog.header=true
-log4j.appender.syslog.Facility=LOCAL3
-log4j.appender.syslog.layout=org.apache.log4j.PatternLayout
-log4j.appender.syslog.layout.conversionPattern=Main[%pid] :%t: %c %-4p - %m\n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-syslog-protocol-tcp.xml b/log4j-1.2-api/src/test/resources/log4j1-syslog-protocol-tcp.xml
deleted file mode 100644
index 9d065e2e15c..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-syslog-protocol-tcp.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-syslog-protocol-udp.properties b/log4j-1.2-api/src/test/resources/log4j1-syslog-protocol-udp.properties
deleted file mode 100644
index 3786306ed86..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-syslog-protocol-udp.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to you under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-log4j.rootLogger=DEBUG,syslog
-log4j.appender.syslog=org.apache.log4j.net.SyslogAppender
-log4j.appender.syslog.Threshold=DEBUG
-log4j.appender.syslog.syslogHost=localhost:${syslog.port}
-log4j.appender.syslog.protocol=UDP
-log4j.appender.syslog.header=true
-log4j.appender.syslog.Facility=LOCAL3
-log4j.appender.syslog.layout=org.apache.log4j.PatternLayout
-log4j.appender.syslog.layout.conversionPattern=Main[%pid] :%t: %c %-4p - %m\n
diff --git a/log4j-1.2-api/src/test/resources/log4j1-syslog-protocol-udp.xml b/log4j-1.2-api/src/test/resources/log4j1-syslog-protocol-udp.xml
deleted file mode 100644
index c1defbdd5f7..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-syslog-protocol-udp.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j1-syslog.xml b/log4j-1.2-api/src/test/resources/log4j1-syslog.xml
deleted file mode 100644
index 46d8a0d2d71..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j1-syslog.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/log4j2-config.xml b/log4j-1.2-api/src/test/resources/log4j2-config.xml
deleted file mode 100644
index 8b47ed485e9..00000000000
--- a/log4j-1.2-api/src/test/resources/log4j2-config.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/logWithMDC.xml b/log4j-1.2-api/src/test/resources/logWithMDC.xml
deleted file mode 100644
index 93ad097c59d..00000000000
--- a/log4j-1.2-api/src/test/resources/logWithMDC.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/log4j-1.2-api/src/test/resources/witness/serialization/info.bin b/log4j-1.2-api/src/test/resources/witness/serialization/info.bin
deleted file mode 100644
index f887f39e9b3..00000000000
Binary files a/log4j-1.2-api/src/test/resources/witness/serialization/info.bin and /dev/null differ
diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/util/OptionConverterTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/util/OptionConverterTest.java
deleted file mode 100644
index a0926f995b1..00000000000
--- a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/util/OptionConverterTest.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.core.util;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-import java.util.Properties;
-import org.junit.jupiter.api.Test;
-
-/**
- * Tests {@link OptionConverter}.
- */
-public class OptionConverterTest {
-
- @Test
- public void testSubstVars() {
- final Properties props = new Properties();
- props.setProperty("key", "${key}");
- props.setProperty("testKey", "Log4j");
- assertEquals("Value of key is ${key}.", OptionConverter.substVars("Value of key is ${key}.", props));
- assertEquals("Value of key is .", OptionConverter.substVars("Value of key is ${key2}.", props));
- assertEquals(
- "Value of testKey:testKey is Log4j:Log4j",
- OptionConverter.substVars("Value of testKey:testKey is ${testKey}:${testKey}", props));
- }
-
- /**
- * StrSubstitutor would resolve ${key} to Key, append the result to "test" and then resolve ${testKey}.
- * Verify that substVars doesn't construct dynamic keys.
- */
- @Test
- public void testAppend() {
- final Properties props = new Properties();
- props.setProperty("key", "Key");
- props.setProperty("testKey", "Hello");
- assertEquals("Value of testKey is }", OptionConverter.substVars("Value of testKey is ${test${key}}", props));
- }
-
- /**
- * StrSubstitutor would resolve ${key}, append the result to "test" and then resolve ${testKey}.
- * Verify that substVars will treat the second expression up to the first '}' as part of the key.
- */
- @Test
- public void testAppend2() {
- final Properties props = new Properties();
- props.setProperty("test${key", "Hello");
- assertEquals(
- "Value of testKey is Hello}", OptionConverter.substVars("Value of testKey is ${test${key}}", props));
- }
-
- @Test
- public void testRecursion() {
- final Properties props = new RecursiveProperties();
- props.setProperty("name", "Neo");
- props.setProperty("greeting", "Hello ${name}");
-
- final String s = props.getProperty("greeting");
- System.out.println("greeting = '" + s + "'");
- }
-
- private static class RecursiveProperties extends Properties {
- @Override
- public String getProperty(final String key) {
- System.out.println("getProperty for " + key);
- try {
- final String val = super.getProperty(key);
- // The following call works for log4j 2.17.0 and causes StackOverflowError for 2.17.1
- // This is because substVars change implementation in 2.17.1 to call StrSubstitutor.replace(val, props)
- // which calls props.getProperty() for EVERY property making it recursive
- return OptionConverter.substVars(val, this);
- } catch (Exception e) {
- return super.getProperty(key);
- }
- }
- }
-}
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/LiteralPatternConverter.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/LiteralPatternConverter.java
index bb630ae5718..283b68604b2 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/LiteralPatternConverter.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/LiteralPatternConverter.java
@@ -18,7 +18,6 @@
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.util.OptionConverter;
import org.apache.logging.log4j.util.PerformanceSensitive;
/**
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/OptionConverter.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/OptionConverter.java
new file mode 100644
index 00000000000..f8756e86b9c
--- /dev/null
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/OptionConverter.java
@@ -0,0 +1,64 @@
+/*
+ * 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.pattern;
+
+final class OptionConverter {
+
+ public static String convertSpecialChars(final String s) {
+ char c;
+ final int len = s.length();
+ final StringBuilder sbuf = new StringBuilder(len);
+
+ int i = 0;
+ while (i < len) {
+ c = s.charAt(i++);
+ if (c == '\\') {
+ c = s.charAt(i++);
+ switch (c) {
+ case 'n':
+ c = '\n';
+ break;
+ case 'r':
+ c = '\r';
+ break;
+ case 't':
+ c = '\t';
+ break;
+ case 'f':
+ c = '\f';
+ break;
+ case 'b':
+ c = '\b';
+ break;
+ case '"':
+ c = '\"';
+ break;
+ case '\'':
+ c = '\'';
+ break;
+ case '\\':
+ c = '\\';
+ break;
+ default:
+ // there is no default case.
+ }
+ }
+ sbuf.append(c);
+ }
+ return sbuf.toString();
+ }
+}
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/SimpleLiteralPatternConverter.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/SimpleLiteralPatternConverter.java
index 16e6c45cb3e..8ce888c6c97 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/SimpleLiteralPatternConverter.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/SimpleLiteralPatternConverter.java
@@ -17,7 +17,6 @@
package org.apache.logging.log4j.core.pattern;
import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.util.OptionConverter;
import org.apache.logging.log4j.util.PerformanceSensitive;
/**
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/OptionConverter.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/util/OptionConverter.java
deleted file mode 100644
index 7563eb87b70..00000000000
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/util/OptionConverter.java
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.logging.log4j.core.util;
-
-import java.io.InterruptedIOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.Logger;
-import org.apache.logging.log4j.kit.env.PropertyEnvironment;
-import org.apache.logging.log4j.status.StatusLogger;
-import org.apache.logging.log4j.util.LoaderUtil;
-import org.apache.logging.log4j.util.Strings;
-
-/**
- * A convenience class to convert property values to specific types.
- */
-public final class OptionConverter {
-
- private static final Logger LOGGER = StatusLogger.getLogger();
-
- private static final String DELIM_START = "${";
- private static final char DELIM_STOP = '}';
- private static final int DELIM_START_LEN = 2;
- private static final int DELIM_STOP_LEN = 1;
-
- /**
- * OptionConverter is a static class.
- */
- private OptionConverter() {}
-
- public static String convertSpecialChars(final String s) {
- char c;
- final int len = s.length();
- final StringBuilder sbuf = new StringBuilder(len);
-
- int i = 0;
- while (i < len) {
- c = s.charAt(i++);
- if (c == '\\') {
- c = s.charAt(i++);
- switch (c) {
- case 'n':
- c = '\n';
- break;
- case 'r':
- c = '\r';
- break;
- case 't':
- c = '\t';
- break;
- case 'f':
- c = '\f';
- break;
- case 'b':
- c = '\b';
- break;
- case '"':
- c = '\"';
- break;
- case '\'':
- c = '\'';
- break;
- case '\\':
- c = '\\';
- break;
- default:
- // there is no default case.
- }
- }
- sbuf.append(c);
- }
- return sbuf.toString();
- }
-
- public static Object instantiateByKey(
- final Properties props, final String key, final Class> superClass, final Object defaultValue) {
-
- // Get the value of the property in string form
- final String className = findAndSubst(key, props);
- if (className == null) {
- LOGGER.error("Could not find value for key {}", key);
- return defaultValue;
- }
- // Trim className to avoid trailing spaces that cause problems.
- return OptionConverter.instantiateByClassName(className.trim(), superClass, defaultValue);
- }
-
- public static Level toLevel(String value, Level defaultValue) {
- if (value == null) {
- return defaultValue;
- }
-
- value = value.trim();
-
- final int hashIndex = value.indexOf('#');
- if (hashIndex == -1) {
- if ("NULL".equalsIgnoreCase(value)) {
- return null;
- } else {
- // no class name specified : use standard Level class
- return Level.toLevel(value, defaultValue);
- }
- }
-
- Level result = defaultValue;
-
- final String clazz = value.substring(hashIndex + 1);
- final String levelName = value.substring(0, hashIndex);
-
- // This is degenerate case but you never know.
- if ("NULL".equalsIgnoreCase(levelName)) {
- return null;
- }
-
- LOGGER.debug("toLevel" + ":class=[" + clazz + "]" + ":pri=[" + levelName + "]");
-
- try {
- final Class> customLevel = Loader.loadClass(clazz);
-
- // get a ref to the specified class' static method
- // toLevel(String, org.apache.log4j.Level)
- final Class>[] paramTypes = new Class[] {String.class, Level.class};
- final java.lang.reflect.Method toLevelMethod = customLevel.getMethod("toLevel", paramTypes);
-
- // now call the toLevel method, passing level string + default
- final Object[] params = new Object[] {levelName, defaultValue};
- final Object o = toLevelMethod.invoke(null, params);
-
- result = (Level) o;
- } catch (ClassNotFoundException e) {
- LOGGER.warn("custom level class [" + clazz + "] not found.");
- } catch (NoSuchMethodException e) {
- LOGGER.warn(
- "custom level class [" + clazz + "]" + " does not have a class function toLevel(String, Level)", e);
- } catch (java.lang.reflect.InvocationTargetException e) {
- if (e.getTargetException() instanceof InterruptedException
- || e.getTargetException() instanceof InterruptedIOException) {
- Thread.currentThread().interrupt();
- }
- LOGGER.warn("custom level class [" + clazz + "]" + " could not be instantiated", e);
- } catch (ClassCastException e) {
- LOGGER.warn("class [" + clazz + "] is not a subclass of org.apache.log4j.Level", e);
- } catch (IllegalAccessException e) {
- LOGGER.warn("class [" + clazz + "] cannot be instantiated due to access restrictions", e);
- } catch (RuntimeException e) {
- LOGGER.warn("class [" + clazz + "], level [" + levelName + "] conversion failed.", e);
- }
- return result;
- }
-
- /**
- * Find the value corresponding to key
in
- * props
. Then perform variable substitution on the
- * found value.
- * @param key The key to locate.
- * @param props The properties.
- * @return The String after substitution.
- */
- public static String findAndSubst(final String key, final Properties props) {
- final String value = props.getProperty(key);
- if (value == null) {
- return null;
- }
-
- try {
- return substVars(value, props);
- } catch (final IllegalArgumentException e) {
- LOGGER.error("Bad option value [{}].", value, e);
- return value;
- }
- }
-
- /**
- * Instantiate an object given a class name. Check that the
- * className
is a subclass of
- * superClass
. If that test fails or the object could
- * not be instantiated, then defaultValue
is returned.
- *
- * @param className The fully qualified class name of the object to instantiate.
- * @param superClass The class to which the new object should belong.
- * @param defaultValue The object to return in case of non-fulfillment
- * @return The created object.
- */
- public static Object instantiateByClassName(
- final String className, final Class> superClass, final Object defaultValue) {
- if (className != null) {
- try {
- final Class> classObj = Loader.loadClass(className);
- if (!superClass.isAssignableFrom(classObj)) {
- LOGGER.error(
- "A \"{}\" object is not assignable to a \"{}\" variable.", className, superClass.getName());
- LOGGER.error(
- "The class \"{}\" was loaded by [{}] whereas object of type [{}] was loaded by [{}].",
- superClass.getName(),
- superClass.getClassLoader(),
- classObj.getTypeName(),
- classObj.getName());
- return defaultValue;
- }
- return LoaderUtil.newInstanceOf(classObj);
- } catch (final Exception e) {
- LOGGER.error("Could not instantiate class [{}].", className, e);
- }
- }
- return defaultValue;
- }
-
- /**
- * Perform variable substitution in string val
from the
- * values of keys found in the system propeties.
- *
- * The variable substitution delimiters are ${ and } .
- *
- * For example, if the System properties contains "key=value", then
- * the call
- *
- * String s = OptionConverter.substituteVars("Value of key is ${key}.");
- *
- *
- * will set the variable s
to "Value of key is value.".
- *
- * If no value could be found for the specified key, then the
- * props
parameter is searched, if the value could not
- * be found there, then substitution defaults to the empty string.
- *
- * For example, if system properties contains no value for the key
- * "inexistentKey", then the call
- *
- *
- * String s = OptionConverter.subsVars("Value of inexistentKey is [${inexistentKey}]");
- *
- *
- * will set s
to "Value of inexistentKey is []"
- *
- * An {@link java.lang.IllegalArgumentException} is thrown if
- * val
contains a start delimeter "${" which is not
- * balanced by a stop delimeter "}".
- *
- * @param val The string on which variable substitution is performed.
- * @param props The properties to use for substitution.
- * @return The String after substitution.
- * @throws IllegalArgumentException if val
is malformed.
- */
- public static String substVars(final String val, final Properties props) throws IllegalArgumentException {
- return substVars(val, props, new ArrayList<>());
- }
-
- private static String substVars(final String val, final Properties props, final List keys)
- throws IllegalArgumentException {
-
- final StringBuilder sbuf = new StringBuilder();
-
- int i = 0;
- int j;
- int k;
-
- while (true) {
- j = val.indexOf(DELIM_START, i);
- if (j == -1) {
- // no more variables
- if (i == 0) { // this is a simple string
- return val;
- }
- // add the tail string which contails no variables and return the result.
- sbuf.append(val.substring(i, val.length()));
- return sbuf.toString();
- }
- sbuf.append(val.substring(i, j));
- k = val.indexOf(DELIM_STOP, j);
- if (k == -1) {
- throw new IllegalArgumentException(
- Strings.dquote(val) + " has no closing brace. Opening brace at position " + j + '.');
- }
- j += DELIM_START_LEN;
- final String key = val.substring(j, k);
- // first try in System properties
- String replacement = PropertyEnvironment.getGlobal().getProperty(key);
- // then try props parameter
- if (replacement == null && props != null) {
- replacement = props.getProperty(key);
- }
-
- if (replacement != null) {
-
- // Do variable substitution on the replacement string
- // such that we can solve "Hello ${x2}" as "Hello p1"
- // the where the properties are
- // x1=p1
- // x2=${x1}
- if (!keys.contains(key)) {
- final List usedKeys = new ArrayList<>(keys);
- usedKeys.add(key);
- final String recursiveReplacement = substVars(replacement, props, usedKeys);
- sbuf.append(recursiveReplacement);
- } else {
- sbuf.append(replacement);
- }
- }
- i = k + DELIM_STOP_LEN;
- }
- }
-}
diff --git a/log4j-flume-ng/pom.xml b/log4j-flume-ng/pom.xml
index fcfdff50f05..17b6171e0ed 100644
--- a/log4j-flume-ng/pom.xml
+++ b/log4j-flume-ng/pom.xml
@@ -72,11 +72,6 @@
com.sleepycat
je
-
- org.apache.logging.log4j
- log4j-1.2-api
- test
-
org.apache.logging.log4j
log4j-core-test
diff --git a/log4j-layout-template-json-test/pom.xml b/log4j-layout-template-json-test/pom.xml
index 68df2d6d44d..024b187f430 100644
--- a/log4j-layout-template-json-test/pom.xml
+++ b/log4j-layout-template-json-test/pom.xml
@@ -47,13 +47,6 @@
log4j-layout-template-json
-
-
- org.apache.logging.log4j
- log4j-1.2-api
- test
-
-
org.apache.logging.log4j
log4j-config-properties
diff --git a/log4j-layout-template-json-test/src/test/java/org/apache/logging/log4j/layout/template/json/resolver/MessageResolverTest.java b/log4j-layout-template-json-test/src/test/java/org/apache/logging/log4j/layout/template/json/resolver/MessageResolverTest.java
index cde99202f8c..1ac9497e052 100644
--- a/log4j-layout-template-json-test/src/test/java/org/apache/logging/log4j/layout/template/json/resolver/MessageResolverTest.java
+++ b/log4j-layout-template-json-test/src/test/java/org/apache/logging/log4j/layout/template/json/resolver/MessageResolverTest.java
@@ -22,59 +22,20 @@
import static org.apache.logging.log4j.layout.template.json.TestHelpers.writeJson;
import static org.assertj.core.api.Assertions.assertThat;
-import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.LinkedHashMap;
-import java.util.List;
import java.util.Map;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.impl.Log4jLogEvent;
-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.kit.json.JsonReader;
import org.apache.logging.log4j.layout.template.json.JsonTemplateLayout;
import org.apache.logging.log4j.message.Message;
import org.apache.logging.log4j.message.ObjectMessage;
import org.apache.logging.log4j.message.SimpleMessage;
import org.apache.logging.log4j.message.StringMapMessage;
-import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
class MessageResolverTest {
- /**
- * Tests the inconsistent fallbackKey
behaviour described in LOG4J2-3080 .
- */
- @Test
- @LoggerContextSource("messageFallbackKeyUsingJsonTemplateLayout.xml")
- void log4j1_logger_calls_should_use_fallbackKey(final @Named(value = "List") ListAppender appender) {
-
- // Log using legacy Log4j 1 API.
- final String log4j1Message = "Message logged using org.apache.log4j.Category.info(Object)";
- org.apache.log4j.LogManager.getLogger(MessageResolverTest.class).info(log4j1Message);
-
- // Log using Log4j 2 API.
- final String log4j2Message = "Message logged using org.apache.logging.log4j.Logger.info(String)";
- org.apache.logging.log4j.LogManager.getLogger(MessageResolverTest.class).info(log4j2Message);
-
- // Collect and parse logged messages.
- final List actualLoggedEvents = appender.getData().stream()
- .map(jsonBytes -> {
- final String json = new String(jsonBytes, StandardCharsets.UTF_8);
- return JsonReader.read(json);
- })
- .collect(Collectors.toList());
-
- // Verify logged messages.
- final List expectedLoggedEvents = Stream.of(log4j1Message, log4j2Message)
- .map(message -> Collections.singletonMap("message", Collections.singletonMap("fallback", message)))
- .collect(Collectors.toList());
- Assertions.assertThat(actualLoggedEvents).isEqualTo(expectedLoggedEvents);
- }
-
@Test
void test_message_fallbackKey() {
diff --git a/log4j-osgi-test/pom.xml b/log4j-osgi-test/pom.xml
index 3c8cad33745..48e8f62fbdc 100644
--- a/log4j-osgi-test/pom.xml
+++ b/log4j-osgi-test/pom.xml
@@ -50,11 +50,6 @@
1
provided
-
- org.apache.logging.log4j
- log4j-1.2-api
- test
-
org.apache.logging.log4j
log4j-api
diff --git a/log4j-osgi-test/src/test/java/org/apache/logging/log4j/osgi/tests/CoreOsgiTest.java b/log4j-osgi-test/src/test/java/org/apache/logging/log4j/osgi/tests/CoreOsgiTest.java
index c3f9bd15bee..12f273cc58e 100644
--- a/log4j-osgi-test/src/test/java/org/apache/logging/log4j/osgi/tests/CoreOsgiTest.java
+++ b/log4j-osgi-test/src/test/java/org/apache/logging/log4j/osgi/tests/CoreOsgiTest.java
@@ -90,19 +90,6 @@ public void testSimpleLogInAnOsgiContext() {
custom.clearEvents();
}
- @Test
- public void testLog4j12InAnOsgiContext() {
- final CustomConfiguration custom = getConfiguration();
- // Logging
- final org.apache.log4j.Logger logger = org.apache.log4j.LogManager.getLogger(getClass());
- logger.info("Hello OSGI from Log4j 1.2!");
- assertEquals(1, custom.getEvents().size());
- final LogEvent event = custom.getEvents().get(0);
- assertEquals("Hello OSGI from Log4j 1.2!", event.getMessage().getFormattedMessage());
- assertEquals(Level.INFO, event.getLevel());
- custom.clearEvents();
- }
-
private static CustomConfiguration getConfiguration() {
final LoggerContextFactory factory = LogManager.getFactory();
assertEquals(Log4jContextFactory.class, factory.getClass());
diff --git a/pom.xml b/pom.xml
index 199c333c256..c9b8408093a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -232,7 +232,6 @@
- log4j-1.2-api
log4j-async-logger
log4j-config-jackson
log4j-config-properties
@@ -366,12 +365,6 @@
-
- org.apache.logging.log4j
- log4j-1.2-api
- ${project.version}
-
-
org.apache.logging.log4j
log4j-api
@@ -841,9 +834,8 @@
Assume that the filesystem walks folder contents in alphanumeric order.
Sourcing `log4j-docgen:generate-*` from that folder will consume descriptors in the following order:
- 1. `log4j-1.2.api`
- 2. `log4j-cassandra`
- 3. `log4j-core`
+ 1. `log4j-cassandra`
+ 2. `log4j-core`
4. ...
For instance, `AbstractFilterable` is defined by the descriptors of both `log4j-cassandra` and `log4j-core`.
diff --git a/src/changelog/.3.x.x/remove_log4j-1.2-api.xml b/src/changelog/.3.x.x/remove_log4j-1.2-api.xml
new file mode 100644
index 00000000000..500f67c70f1
--- /dev/null
+++ b/src/changelog/.3.x.x/remove_log4j-1.2-api.xml
@@ -0,0 +1,8 @@
+
+
+
+ Remove `log4j-1.2-api` module
+
diff --git a/src/site/antora/modules/ROOT/nav.adoc b/src/site/antora/modules/ROOT/nav.adoc
index fc253b5984e..eada7080410 100644
--- a/src/site/antora/modules/ROOT/nav.adoc
+++ b/src/site/antora/modules/ROOT/nav.adoc
@@ -16,7 +16,6 @@
////
* xref:download.adoc[Download]
-** xref:runtime-dependencies.adoc[]
** xref:release-notes.adoc[]
* link:{logging-services-url}/support.html[Support]
** link:{logging-services-url}/security.html[Security]
diff --git a/src/site/antora/modules/ROOT/pages/_log4j1-eol.adoc b/src/site/antora/modules/ROOT/pages/_log4j1-eol.adoc
index b15526c6fe7..26d96d85fbf 100644
--- a/src/site/antora/modules/ROOT/pages/_log4j1-eol.adoc
+++ b/src/site/antora/modules/ROOT/pages/_log4j1-eol.adoc
@@ -19,5 +19,5 @@
====
http://logging.apache.org/log4j/1.x[Log4j 1] has https://blogs.apache.org/foundation/entry/apache_logging_services_project_announces[reached End of Life] in 2015, and is no longer supported.
Vulnerabilities reported after August 2015 against Log4j 1 are not checked and will not be fixed.
-Users should xref:manual/migration.adoc[upgrade to Log4j 2] to obtain security fixes.
+Users should upgrade to either {log4j2-url}[Log4j 2] or Log4j 3 to obtain security fixes.
====
diff --git a/src/site/antora/modules/ROOT/pages/log4j-flume-ng.adoc b/src/site/antora/modules/ROOT/pages/log4j-flume-ng.adoc
index a829d0994c7..f612c78a800 100644
--- a/src/site/antora/modules/ROOT/pages/log4j-flume-ng.adoc
+++ b/src/site/antora/modules/ROOT/pages/log4j-flume-ng.adoc
@@ -95,11 +95,6 @@ The following is a sample pom file for Maven that can be used as a template for
log4j-api
${log4j.version}
-
- org.apache.logging.log4j
- log4j-1.2-api
- ${log4j.version}
-
org.apache.logging.log4j
log4j-core
diff --git a/src/site/antora/modules/ROOT/pages/manual/compatibility.adoc b/src/site/antora/modules/ROOT/pages/manual/compatibility.adoc
deleted file mode 100644
index 8f2f0aff3d2..00000000000
--- a/src/site/antora/modules/ROOT/pages/manual/compatibility.adoc
+++ /dev/null
@@ -1,22 +0,0 @@
-////
-Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-////
-
-// NOTE: do not delete this page: external pages may be linking to it
-
-== Compatibility with Log4j 1
-
-See the xref:manual/migration.adoc#Log4j1.2Bridge[Log4j 1.x bridge (log4j-1.2-api)] section of the Log4j 1.x Migration page.
diff --git a/src/site/antora/modules/ROOT/pages/manual/index.adoc b/src/site/antora/modules/ROOT/pages/manual/index.adoc
index 08821f68616..490c4f968c4 100644
--- a/src/site/antora/modules/ROOT/pages/manual/index.adoc
+++ b/src/site/antora/modules/ROOT/pages/manual/index.adoc
@@ -62,5 +62,4 @@ include::partial$log4j-features.adoc[]
* xref:manual/configuration.adoc[How can I configure Log4j?]
* xref:manual/api.adoc[How can I use Log4j API?]
* xref:manual/performance.adoc[How can I tune my Log4j setup for performance?]
-* xref:manual/migration.adoc[How can I migrate from Log4j 1 to Log4j 2]?
* xref:manual/plugins.adoc[What are Log4j plugins] and xref:manual/extending.adoc[how can I use them to extend Log4j?]
diff --git a/src/site/antora/modules/ROOT/pages/manual/log4j1-compat.adoc b/src/site/antora/modules/ROOT/pages/manual/log4j1-compat.adoc
deleted file mode 100644
index 549339adc04..00000000000
--- a/src/site/antora/modules/ROOT/pages/manual/log4j1-compat.adoc
+++ /dev/null
@@ -1,97 +0,0 @@
-////
-vim: set syn=asciidoc :
-////
-////
- 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.
-////
-
-= Log4j 3 compatibility with Log4j 1
-
-== API Compatibility
-
-Log4j 3 provides support for the Log4j 1 logging methods by providing alternate implementations
-of the classes containing those methods. These classes may be found in the log4j-1.2-api jar
-distributed with the project. All calls to perform logging will result in the data passed to the logging methods
-to be forwarded to the Log4j2 API where they can be processed by implementations of the Log4j 2 API.
-
-== Configuration Compatibility
-
-Log4j 2 provides experimental support for Log4j 1 configuration files. Configuration of the Appenders, Layouts
-and Filters that were provided in the Log4j 1 distribution will be redirected to their Log4j 2 counterparts -
-with the exception of the implemented Rewrite Policies. This means that although the while the behavior of these
-components will be similar they may not be exactly the same. For example, the XML generated by the XMLLayout may
-not exactly match the XML generated by the Log4j 1XMLLayout.
-
-In addition, Log4j 2 supports custom Log4j 1 Appenders, Filters, and Layouts with some constraints. Since the
-original Log4j 1 components may not be present in Log4j 2, custom components that extend them will fail.
-
-As support for Log4j 1 is an experimental feature one of the following steps must be taken to enable it:
-
-. Set the system property "log4j1.compatibility" to a value of "true". Log4j 2 will then add log4j.properties,
-log4j-test.properties, log4j.xml and log4j-test.xml to the configuration files it searches for on the class path.
-. Set the Log4j 1 system property "log4j.configuration" to the location of the log4j 1 configuration file. The
-files must have a file extension of either ".properties" or ".xml".
-
-== Supported Components
-
-=== Appenders
-
-* AsyncAppender
-* ConsoleAppender
-* DailyRollingFileAppender
-* FileAppender
-* NullAppender
-* RewriteAppender (limited)
-* RollingFileAppender
-* SyslogAppender
-
-== Filters
-
-* DenyAllFilter
-* LevelMatchFilter
-* LevelRangeFilter
-* StringMatchFilter
-
-== Layouts
-
-* HtmlLayout
-* PatternLayout
-* SimpleLayout
-* TTCCLayout
-* XmlLayout
-
-== Rewrite Policies
-
-* MapRewritePolicy
-* PropertyRewritePolicy
-
-== Unsupported or Unimplemented Components
-
-=== Appenders
-
-* JDBCAppender (cannot be mapped to Log4j 2's JdbcAppender)
-* SocketAppender (Requires the use of the SerializedLayout which is a security risk)
-* SocketHubAppender (Requires the use of the SerializedLayout which is a security risk)
-* TelnetAppender (Security risk)
-
-== Rewrite Policies
-
-* ReflectionRewritePolicy
-* Custom rewrite policies since LoggingEvent is currently a no-op.
-
-=== Renderers
-
-Log4j 2 currently will ignore renderers.
diff --git a/src/site/antora/modules/ROOT/pages/manual/migration.adoc b/src/site/antora/modules/ROOT/pages/manual/migration.adoc
index 8ba23b47a72..6a11f97f3b8 100644
--- a/src/site/antora/modules/ROOT/pages/manual/migration.adoc
+++ b/src/site/antora/modules/ROOT/pages/manual/migration.adoc
@@ -15,434 +15,6 @@ Licensed to the Apache Software Foundation (ASF) under one or more
limitations under the License.
////
-= Migrating from Log4j 1
+= Migrating from Log4j 2
-http://logging.apache.org/log4j/1.2/[Log4j 1.x] has https://blogs.apache.org/foundation/entry/apache_logging_services_project_announces[reached End of Life] in 2015 and is no longer supported.
-
-This page explains how to migrate applications or libraries currently using the Log4j 1.x API to use Log4j v2 as their main logging framework.
-
-[#Log4j12Bridge]
-== Option 1: use the Log4j 1.x bridge (log4j-1.2-api)
-
-You may be able to convert an application to Log4j 2 _without any code changes_ by replacing the Log4j 1.x jar file with Log4j 2's `log4j-1.2-api.jar`.
-
-The Log4j 1.x bridge is useful when:
-
-* the application itself is (maybe partly) still using the Log4j 1.x API, or if
-* the application depends on a library which depends on the Log 1.x API, or
-* the application needs to support logging configurations in the old Log4j 1.x format.
-
-To use this option, applications need to use the following three jar files: the Log4j 2 API jar (`log4j-api.jar`), the Log4j 2 implementation jar (`log4j-core.jar`) and the Log4j 1.x bridge jar (`log4j-1.2-api.jar`).
-
-image:whichjar-log4j-1.2-api.png[Using log4j 2 via the log4j 1.x API]
-
-For most applications this is sufficient.
-This is a low-effort way to migrate, and may also allow for migration to proceed gradually over time.
-
-[id=enabling-the-log4j-1-x-bridge]
-=== Enabling the Log4j 1.x bridge
-
-Enable the Log4j 1.x bridge via one of the following steps:
-
-. Set the system property "log4j1.compatibility" to a value of "true".
-Log4j 2 will then add log4j.properties, log4j-test.properties, log4j.xml and log4j-test.xml to the xref:manual/configuration.adoc#AutomaticConfiguration[configuration files] it searches for on the class path.
-. Set the Log4j 1 system property "log4j.configuration" to the location of the log4j 1 configuration file.
-The files must have a file extension of either ".properties" or ".xml".
-
-[#APICompatibility]
-=== API Compatibility
-
-Log4j 2 provides support for the Log4j 1 logging methods by providing alternate implementations of the classes containing those methods.
-These classes may be found in the log4j-1.2-api jar distributed with the project.
-All calls to perform logging will result in the data passed to the logging methods to be forwarded to the Log4j2 API where they can be processed by implementations of the Log4j 2 API.
-
-[#ConfigurationCompatibility]
-=== Configuration Compatibility
-
-Log4j 2 provides support for Log4j 1 configuration files.
-Configuration of the Appenders, Layouts and Filters that were provided in the Log4j 1 distribution will be redirected to their Log4j 2 counterparts - with the exception of the implemented Rewrite Policies.
-This means that although the behavior of these components will be similar, they may not be exactly the same.
-For example, the XML generated by the XMLLayout may not exactly match the XML generated by the Log4j1XMLLayout.
-
-In addition, Log4j 2 supports custom Log4j 1 Appenders, Filters, and Layouts with some constraints.
-Since the original Log4j 1 components may not be present in Log4j 2, custom components that extend them will fail.
-
-==== Supported Components
-
-Supported Appenders include: AsyncAppender, ConsoleAppender, DailyRollingFileAppender, FileAppender, NullAppender, RewriteAppender (limited), RollingFileAppender, SyslogAppender.
-
-Supported Filters include: DenyAllFilter, LevelMatchFilter, LevelRangeFilter, StringMatchFilter.
-
-Supported Layouts include: HtmlLayout, PatternLayout, SimpleLayout, TTCCLayout , XmlLayout.
-
-Supported Rewrite Policies include: MapRewritePolicy, PropertyRewritePolicy.
-
-==== Unsupported or Unimplemented Components
-
-If your configuration contains any of the below components, consider xref:#Log4j2ConfigurationFormat[migrating your configuration] to the Log4j 2 format.
-
-===== Appenders
-
-* JDBCAppender (cannot be mapped to Log4j 2's JdbcAppender)
-* JMSAppender
-* SMTPAppender
-* SocketAppender (Requires the use of the SerializedLayout which is a security risk)
-* SocketHubAppender (Requires the use of the SerializedLayout which is a security risk)
-* TelnetAppender (Security risk)
-
-===== Rewrite Policies
-
-* ReflectionRewritePolicy
-* Custom rewrite policies since LoggingEvent is currently a no-op.
-
-===== Renderers
-
-Log4j 2 currently ignores renderers.
-
-[#Log4j12BridgeLimitations]
-=== Limitations of the Log4j 1.x bridge
-
-Applications can migrate by just using the bridge without further code changes, if they meet the following requirements:
-
-. They must not access methods and classes internal to the Log4j 1.x implementation such as ``Appender``s, `LoggerRepository` or ``Category``'s `callAppenders` method.
-. They must not programmatically configure Log4j.
-. They must not configure by calling the Log4j 1.x classes `DOMConfigurator` or `PropertyConfigurator`.
-
-=== When to stop using the Log4j 1.x bridge
-
-Once you have migrated all of your own application and library code under your control, you may not need the bridge anymore.
-Note that when you use a library/framework that can be configured to use several logging frameworks, then you typically don't need the log4j-1.2-api bridge either, as you may be able to directly configure it to use Log4j v2 instead v1.
-Some libraries/frameworks even auto-detect the presence of certain logging framework implementations on their classpath, and automagically switch their internal logging delegation accordingly;
-try simple removing the Log4j v1 dependency instead of replacing it with this bridge, and test if logging from all of your dependencies still work.
-
-If you own or can contribute open source to the library you depend on, consider replacing its use of the Log4j v1 API with the v2 API.
-
-While the Log4j 1.x bridge supports logging configurations that use the Log4j 1.x properties or XML format, migrating to the new 2.x format is not difficult.
-The Log4j 2 website contains extensive documentation on the 2.x configuration format.
-Examples for migrating logging configurations from the v1 format to the v2 format are below.
-
-[#Log4j2API]
-== Option 2: convert your application to the Log4j 2 API (log4j-api)
-
-The other migration option involves changing your application code to use the Log4j 2 API.
-For the most part, converting from the Log4j 1.x API to Log4j 2 should be fairly simple.
-Many of the log statements will require no modification.
-However, where necessary the following changes must be made.
-
-image:whichjar-log4j-api.png[Using log4j 2 via the log4j 2.x API]
-
-|===
-| Log4j 1.x | Log4j 2.x
-
-| Package name: `org.apache.log4j`
-| `org.apache.logging.log4j`
-
-| Calls to `org.apache.log4j.Logger.getLogger()`
-| `org.apache.logging.log4j.LogManager.getLogger()`
-
-| Calls to `org.apache.log4j.Logger.getRootLogger()` or `org.apache.log4j.LogManager.getRootLogger()`
-| `org.apache.logging.log4j.LogManager.getRootLogger()`
-
-| Calls to `org.apache.log4j.Logger.getLogger` that accept a `LoggerFactory`
-| Remove the `org.apache.log4j.spi.LoggerFactory` and use one of Log4j 2's other extension mechanisms
-
-| Calls to `org.apache.log4j.Logger.getEffectiveLevel()`
-| `org.apache.logging.log4j.Logger.getLevel()`
-
-| Calls to `org.apache.log4j.LogManager.shutdown()`
-| Not needed in version 2 because the Log4j Core now automatically adds a JVM shutdown hook on start up to perform any Core clean ups.
-Starting in Log4j 2.1, you can specify a custom link:../javadoc/log4j-core/org/apache/logging/log4j/core/util/ShutdownCallbackRegistry.html[ShutdownCallbackRegistry] to override the default JVM shutdown hook strategy.
-Starting in Log4j 2.6, you can use `org.apache.logging.log4j.LogManager.shutdown()` to initiate shutdown manually.
-
-| Calls to `org.apache.log4j.Logger.setLevel()` or similar methods
-| Not supported at API level.
-Equivalent functionality is provided in the Log4j 2 implementation classes, see `org.apache.logging.log4j.core.config.Configurator.setLevel()`, but this may leave the application susceptible to changes in Log4j 2 internals.
-
-| String concatenation like `logger.info("hi " + userName)`
-| Parameterized messages like `logger.info("hi {}", userName)`
-
-| http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/MDC.html[`org.apache.log4j.MDC`] and http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/NDC.html[`org.apache.log4j.NDC`]
-| {log4j2-url}/manual/thread-context.adoc[Thread Context]
-|===
-
-[#Log4j2ConfigurationFormat]
-== Migrating logging configurations to the Log4j 2 format
-
-Although the Log4j 2 configuration syntax is different from that of Log4j 1.x, most, if not all, of the same functionality is available.
-
-=== Interpolation
-
-Note that system property interpolation via the `+${foo}+` syntax has been extended to allow property lookups from many different sources.
-See the xref:manual/lookups.adoc[Lookups] documentation for more details.
-For example, using a lookup for the system property named `catalina.base`, in Log4j 1.x, the syntax would be `${catalina.base}`.
-In Log4j 2, the syntax would be `${sys:catalina.base}`.
-
-=== Layouts
-
-Log4j 1.x has a XMLLayout which is different from the XmlLayout in Log4j 2.
-The log4j-1.2-api module contains a `Log4j1XmlLayout` that produces output in the Log4j 1.x format.
-
-The Log4j 1.x `SimpleLayout` can be emulated with PatternLayout "%level - %m%n".
-
-The Log4j 1.x `TTCCLayout` can be emulated with PatternLayout "%r [%t] %p %c %notEmpty{%ndc }- %m%n".
-
-Both `PatternLayout` and `EnhancedPatternLayout` in Log4j 1.x can be replaced with `PatternLayout` in Log4j 2.
-The log4j-1.2-api module contains two pattern conversions "%ndc" and "%properties" which can be used to emulate "%x" and "%X" in Log4j 1.x PatternLayout ("%x" and %X" in Log4j 2 have a slightly different format).
-
-Below are some example configurations for Log4j 1.x and their counterparts in Log4j 2.
-
-=== Sample 1 - Migrating a simple Console Appender configuration
-
-Log4j 1.x XML configuration
-
-[,xml]
-----
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-----
-
-Log4j 2 XML configuration
-
-[,xml]
-----
-
-
-
-
-
-
-
-
-
-
-
-
-
-----
-
-=== Sample 2 - Migrating a simple File Appender, XMLLayout and SimpleLayout configuration
-
-Log4j 1.x XML configuration
-
-[,xml]
-----
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-----
-
-Log4j 2 XML configuration
-
-[,xml]
-----
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-----
-
-=== Sample 3 - Migrating a SocketAppender configuration
-
-Log4j 1.x XML configuration.
-This example from Log4j 1.x is misleading.
-The SocketAppender does not actually use a Layout.
-Configuring one will have no effect.
-
-[,xml]
-----
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-----
-
-Log4j 2 XML configuration
-
-[,xml]
-----
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-----
-
-=== Sample 4 - Migrating an AsyncAppender and TTCCLayout configuration
-
-Log4j 1.x XML configuration using the AsyncAppender.
-
-[,xml]
-----
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-----
-
-Log4j 2 XML configuration.
-
-[,xml]
-----
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-----
-
-=== Sample 5 - Migrating a configuration using AsyncAppender with Console and File
-
-Log4j 1.x XML configuration using the AsyncAppender.
-
-[,xml]
-----
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-----
-
-Log4j 2 XML configuration.
-Note that the Async Appender should be configured after the appenders it references.
-This will allow it to shut down properly.
-
-[,xml]
-----
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-----
+TODO
diff --git a/src/site/antora/modules/ROOT/pages/runtime-dependencies.adoc b/src/site/antora/modules/ROOT/pages/runtime-dependencies.adoc
deleted file mode 100644
index 3882e44f032..00000000000
--- a/src/site/antora/modules/ROOT/pages/runtime-dependencies.adoc
+++ /dev/null
@@ -1,242 +0,0 @@
-////
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-////
-= Runtime Dependencies
-
-Some Log4J features depend on external libraries. This page lists the required and optional dependencies.
-
-As of version 2.10.0, the Log4j API is a named Java module (with a `module-info.java`). Since version 2.21.0, all the remaining artifacts are named modules. The characteristics of the modules are:
-
-[options="header"]
-|===
-| Artifact Name | Module Name | Module Characteristics
-
-| log4j-api
-| org.apache.logging.log4j
-| Module Directive Notes
-exports org.apache.logging.log4j
-exports org.apache.logging.log4j.message
-exports org.apache.logging.log4j.simple
-exports org.apache.logging.log4j.spi
-exports org.apache.logging.log4j.spi
-exports org.apache.logging.log4j.util Some classes in this package are used by the logging implementation and should be considered private. The module info definition may be modified in the future to export these only to the logging implementation.
-uses org.apache.logging.log4j.spi.Provider Service that must be provided by the logging implementation.
-
-
-| log4j-appserver
-| org.apache.logging.log4j.appserver
-| Named Module
-
-| log4j-cassandra
-| org.apache.logging.log4j.cassandra
-| Named Module
-
-| log4j-core
-| org.apache.logging.log4j.core
-| Named Module. Most of its dependencies are optional.
-
-| log4j-couchdb
-| org.apache.logging.log4j.couchdb
-| Named Module
-
-| log4j-docker
-| org.apache.logging.log4j.docker
-| Named Module
-
-| log4j-1.2-api
-| org.apache.log4j
-| Named Module
-
-| log4j-flume-ng
-| org.apache.logging.log4j.flume
-| Named Module
-
-| log4j-iostreams
-| org.apache.logging.log4j.iostreams
-| Named Module
-
-| log4j-jakarta-smtp
-| org.apache.logging.log4j.smtp
-| Named Module
-
-| log4j-jakarta-web
-| org.apache.logging.log4j.web
-| Named Module. Uses the same name as `log4j-web` since it is its Jakarta EE 9 equivalent.
-
-| log4j-jcl
-| org.apache.logging.log4j.jcl
-| Named Module
-
-| log4j-jul
-| org.apache.logging.log4j.jul
-| Named Module
-
-| log4j-mongodb
-| org.apache.logging.log4j.mongodb
-| Named Module
-
-| log4j-slf4j-impl
-| org.apache.logging.log4j.slf4j.impl
-| Named Module
-
-| log4j-slf4j2-impl
-| org.apache.logging.log4j.slf4j2.impl
-| Named Module
-
-| log4j-taglib
-| org.apache.logging.log4j.taglib
-| Named Module
-
-| log4j-to-slf4j
-| org.apache.logging.log4j.to.slf4j
-| Named Module
-
-| log4j-web
-| org.apache.logging.log4j.web
-| Named Module. Uses the same name as `log4j-jakarta-web` since it is its Java EE 8 equivalent.
-|===
-
-As of version 2.9.1, Log4j supports Java 9 but will still work in Java 7 or 8. In this version, log4j-api is packaged as a multi-release jar and supports the use of the StackWalker and Process APIs.
-
-As of version 2.4, Log4J requires Java 7.
-
-Log4j version 2.3 and older require Java 6.
-
-== log4j-api
-
-The Log4J xref:log4j-api.adoc[API] module has no external dependencies.
-
-== log4j-core
-
-The Log4J implementation has several optional dependencies.
-
-Optional Dependencies per Feature in Log4J Implementation:
-
-[options="header"]
-|===
-| Feature | Requirements
-
-| XML configuration
-| -
-
-| Properties configuration
-| -
-
-| JSON configuration
-| https://github.com/FasterXML/jackson[Jackson core and databind]
-
-| YAML configuration
-| https://github.com/FasterXML/jackson[Jackson databind] and https://github.com/FasterXML/jackson-dataformat-yaml[YAML data format]
-
-| CSV Layout
-| https://commons.apache.org/proper/commons-csv/[Apache Commons CSV]
-
-| JSON Layout
-| https://github.com/FasterXML/jackson[Jackson core and databind]
-
-| XML Layout
-| https://github.com/FasterXML/jackson[Jackson core, databind and dataformat XML] and `com.fasterxml.woodstox:woodstox-core:5.0.2`
-
-| YAML Layout
-| https://github.com/FasterXML/jackson[Jackson core, databind] and https://github.com/FasterXML/jackson-dataformat-yaml[YAML data format]
-
-| Async Loggers
-| https://lmax-exchange.github.io/disruptor/[LMAX Disruptor]
-
-| Kafka Appender
-| https://kafka.apache.org/[Kafka client library]. Note that you need to use a version of the Kafka client library matching the Kafka server used.
-
-| SMTP Appender
-| an implementation of `javax.mail`
-
-| JMS Appender
-| a JMS broker like https://activemq.apache.org/[Apache ActiveMQ]
-
-| Windows console color support
-| https://fusesource.github.io/jansi/[Jansi]
-
-| JDBC Appender
-| a JDBC driver for the database you choose to write events to
-
-| JPA Appender
-| the Java Persistence API classes, a JPA provider implementation, and a decorated entity that the user implements. It also requires an appropriate JDBC driver
-
-| NoSQL Appender with MongoDB provider
-| MongoDB Java Client driver and Log4j MongoDB library
-
-| NoSQL Appender with Apache CouchDB provider
-| LightCouch CouchDB client library and Log4j CouchDB library
-
-| Cassandra Appender
-| Datastax Cassandra driver and Log4j Cassandra library
-
-| Bzip2, Deflate, Pack200, and XZ compression on rollover
-| https://commons.apache.org/proper/commons-compress/[Apache Commons Compress]. In addition, XZ requires https://tukaani.org/xz/java.html[xz-java] and ZStandard requires https://github.com/luben/zstd-jni[zstd-jni]
-
-| ZeroMQ Appender
-| The ZeroMQ appender uses the https://github.com/zeromq/jeromq[JeroMQ] library which is licensed under the terms of the Mozilla Public License Version 2.0 (MPLv2). For details see the file https://github.com/zeromq/jeromq/blob/master/LICENSE[LICENSE] included with the JeroMQ distribution.
-|===
-
-== log4j-docker
-
-xref:log4j-docker.adoc[Log4j Docker Support] requires https://github.com/FasterXML/jackson[Jackson annotations, core, and databind].
-
-== log4j-1.2-api
-
-The xref:log4j-1.2-api.adoc[Log4j 1.2 Bridge] has no external dependencies. This only requires the Log4j API. Including Log4j Core provides optional, extra functionality.
-
-== log4j-slf4j-impl
-
-The Log4j 2 xref:log4j-slf4j-impl.adoc[SLF4J Binding] depends on the https://www.slf4j.org/[SLF4J] API.
-
-[WARNING]
-.Do not use this with the log4j-to-slf4j module.
-====
-
-== log4j-jul
-
-The Log4j 2 xref:log4j-jul.adoc[Java Util Logging Adapter] has no external dependencies. It optionally depends on the xref:log4j-api.adoc[Log4j Core] library. The only required module is the Log4j API.
-
-== log4j-to-slf4j
-
-The xref:log4j-to-slf4j.adoc[Log4j 2 to SLF4J Adapter] requires the https://www.slf4j.org/[SLF4J] API and an SLF4J implementation.
-
-[WARNING]
-.Do not use this with the log4j-slf4j-impl module.
-====
-
-== log4j-flume-ng
-
-The xref:log4j-flume-ng.adoc[Flume Appender] requires https://flume.apache.org/[Apache Flume] and https://avro.apache.org/[Apache Avro]. The persistent agent uses Berkeley DB.
-
-== log4j-spring-cloud-config-client
-
-xref:log4j-spring-cloud-config-client.adoc[Log4j Spring Cloud Config Client] requires https://spring.io/projects/spring-cloud-config[Spring Cloud Config]. https://spring.io/projects/spring-cloud-bus[Spring Cloud Bus] is required if notification of logging configuration changes is desired. https://spring.io/projects/spring-boot[Spring Boot] is required but applications do not have to be packaged as a Spring Boot application.
-
-== log4j-mongodb
-
-The Log4J xref:log4j-mongodb.adoc[MongoDB] module depends on the https://docs.mongodb.org/ecosystem/drivers/java/[MongoDB Java Client driver].
-
-== log4j-iostreams
-
-The Log4j xref:log4j-iostreams.adoc[IO Streams] module has no external dependencies. This only requires the Log4j API.
-
-== log4j-jakarta-smtp
-
-The Log4j Simple Mail Transfer Protocol (SMTP) Appender, version for Jakarta EE 9 module has 2 external runtime dependencies for the jakarta.activation-api and jakarta.mail-api.
-
-. org.eclipse.angus:angus-activation
-. org.eclipse.angus:jakarta.mail
diff --git a/src/site/resources/.htaccess b/src/site/resources/.htaccess
deleted file mode 100755
index 1b4d70606cb..00000000000
--- a/src/site/resources/.htaccess
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-RewriteEngine On
-RewriteRule "^(/log4j/[23].x)/manual/scala-api.html" "/log4j/scala" [R=permanent]
-RewriteRule "^(/log4j/[23].x)/release-notes/index.html" "$1/release-notes.html" [R=permanent]