From 93874817f6194597e1194cb7d66cdca0f17f9756 Mon Sep 17 00:00:00 2001 From: "Piotr P. Karwasz" Date: Wed, 24 May 2023 07:45:21 +0200 Subject: [PATCH] Replace log4j:WARN with reload4j:WARN Since the original `log4j:log4j` Maven artifact is still a quite common transitive dependency, an application might easily end up with both `log4j` and `reload4j`. This commit helps user distinguish the backend that is actually used. --- src/main/java/org/apache/log4j/Hierarchy.java | 2 +- src/main/java/org/apache/log4j/LogManager.java | 2 +- src/main/java/org/apache/log4j/helpers/LogLog.java | 6 +++--- src/test/java/org/apache/log4j/xml/DOMTestCase.java | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/apache/log4j/Hierarchy.java b/src/main/java/org/apache/log4j/Hierarchy.java index 9e750902..a0eebdf6 100644 --- a/src/main/java/org/apache/log4j/Hierarchy.java +++ b/src/main/java/org/apache/log4j/Hierarchy.java @@ -126,7 +126,7 @@ public void emitNoAppenderWarning(Category cat) { if (!this.emittedNoAppenderWarning) { LogLog.warn("No appenders could be found for logger (" + cat.getName() + ")."); LogLog.warn("Please initialize the log4j system properly."); - LogLog.warn("See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info."); + LogLog.warn("See https://reload4j.qos.ch/faq.html#noconfig for more info."); this.emittedNoAppenderWarning = true; } } diff --git a/src/main/java/org/apache/log4j/LogManager.java b/src/main/java/org/apache/log4j/LogManager.java index 2d98218e..08ea7a40 100644 --- a/src/main/java/org/apache/log4j/LogManager.java +++ b/src/main/java/org/apache/log4j/LogManager.java @@ -173,7 +173,7 @@ static public LoggerRepository getLoggerRepository() { repositorySelector = new DefaultRepositorySelector(new NOPLoggerRepository()); guard = null; Exception ex = new IllegalStateException("Class invariant violation"); - String msg = "log4j called after unloading, see http://logging.apache.org/log4j/1.2/faq.html#unload."; + String msg = "log4j called after unloading, see https://reload4j.qos.ch/faq.html#unload."; if (isLikelySafeScenario(ex)) { LogLog.debug(msg, ex); } else { diff --git a/src/main/java/org/apache/log4j/helpers/LogLog.java b/src/main/java/org/apache/log4j/helpers/LogLog.java index 0deb8f37..8512248a 100644 --- a/src/main/java/org/apache/log4j/helpers/LogLog.java +++ b/src/main/java/org/apache/log4j/helpers/LogLog.java @@ -65,9 +65,9 @@ public class LogLog { */ private static boolean quietMode = false; - private static final String PREFIX = "log4j: "; - private static final String ERR_PREFIX = "log4j:ERROR "; - private static final String WARN_PREFIX = "log4j:WARN "; + private static final String PREFIX = "reload4j: "; + private static final String ERR_PREFIX = "reload4j:ERROR "; + private static final String WARN_PREFIX = "reload4j:WARN "; static { String key = OptionConverter.getSystemProperty(DEBUG_KEY, null); diff --git a/src/test/java/org/apache/log4j/xml/DOMTestCase.java b/src/test/java/org/apache/log4j/xml/DOMTestCase.java index d45daca7..163d0609 100644 --- a/src/test/java/org/apache/log4j/xml/DOMTestCase.java +++ b/src/test/java/org/apache/log4j/xml/DOMTestCase.java @@ -131,9 +131,9 @@ public void externalEntitiesTest() throws Exception { System.setErr(sps); DOMConfigurator.configure(TEST_INPUT_PREFIX + "xml/DOMTest4.xml"); common(); - assertTrue(sps.stringList.get(0).contains("log4j:ERROR No appender named [A1] could be found.")); - assertTrue(sps.stringList.get(1).contains("log4j:ERROR No appender named [A1] could be found.")); - assertTrue(sps.stringList.get(2).contains("log4j:ERROR No appender named [A2] could be found.")); + assertTrue(sps.stringList.get(0).contains("reload4j:ERROR No appender named [A1] could be found.")); + assertTrue(sps.stringList.get(1).contains("reload4j:ERROR No appender named [A1] could be found.")); + assertTrue(sps.stringList.get(2).contains("reload4j:ERROR No appender named [A2] could be found.")); } finally { System.setErr(oldErr); }