From 16ab482cab7e8fdc6468ce7da425f10660bf4057 Mon Sep 17 00:00:00 2001 From: Ceki Gulcu Date: Mon, 17 Jan 2022 22:11:33 +0100 Subject: [PATCH] added paragraph on JEP264, doc changes, minor refactoring Signed-off-by: Ceki Gulcu --- pom.xml | 1 + .../org/slf4j/jul/JDK14LoggerFactory.java | 7 ++- slf4j-site/src/site/pages/manual.html | 57 ++++++++++++++++--- slf4j-site/src/site/pages/news.html | 9 ++- slf4j-site/src/site/pages/templates/left.js | 7 ++- 5 files changed, 65 insertions(+), 16 deletions(-) diff --git a/pom.xml b/pom.xml index 59c7c932..f05d8008 100755 --- a/pom.xml +++ b/pom.xml @@ -34,6 +34,7 @@ 1.7.33 + 2.0.0-alpha6 8 ${jdk.version} diff --git a/slf4j-jdk14/src/main/java/org/slf4j/jul/JDK14LoggerFactory.java b/slf4j-jdk14/src/main/java/org/slf4j/jul/JDK14LoggerFactory.java index 38dc0987..bd314e0c 100644 --- a/slf4j-jdk14/src/main/java/org/slf4j/jul/JDK14LoggerFactory.java +++ b/slf4j-jdk14/src/main/java/org/slf4j/jul/JDK14LoggerFactory.java @@ -41,6 +41,11 @@ public class JDK14LoggerFactory implements ILoggerFactory { // key: name (String), value: a JDK14LoggerAdapter; ConcurrentMap loggerMap; + /** + * the root logger is called "" in JUL + */ + private static String JUL_ROOT_LOGGER_NAME = ""; + public JDK14LoggerFactory() { loggerMap = new ConcurrentHashMap<>(); // ensure jul initialization. see SLF4J-359 @@ -57,7 +62,7 @@ public class JDK14LoggerFactory implements ILoggerFactory { public Logger getLogger(String name) { // the root logger is called "" in JUL if (name.equalsIgnoreCase(Logger.ROOT_LOGGER_NAME)) { - name = ""; + name = JUL_ROOT_LOGGER_NAME; } Logger slf4jLogger = loggerMap.get(name); diff --git a/slf4j-site/src/site/pages/manual.html b/slf4j-site/src/site/pages/manual.html index 63fb063f..0fa8a95d 100755 --- a/slf4j-site/src/site/pages/manual.html +++ b/slf4j-site/src/site/pages/manual.html @@ -417,12 +417,12 @@ SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further detail

Basic rule Embedded components such as libraries or frameworks should not declare a dependency - on any SLF4J binding but only depend on slf4j-api. When a - library declares a transitive dependency on a specific binding, - that binding is imposed on the end-user negating the purpose of - SLF4J. Note that declaring a non-transitive dependency on a - binding, for example for testing, does not affect the - end-user.

+ on any SLF4J binding/provider but only depend on + slf4j-api. When a library declares a transitive dependency + on a specific binding, that binding is imposed on the end-user + negating the purpose of SLF4J. Note that declaring a + non-transitive dependency on a binding, for example for testing, + does not affect the end-user.

SLF4J usage in embedded components is also discussed in the FAQ in relation with -

log4j If you wish to use + +

reload4j If you wish to use + reload4j as the underlying logging framework, all you need to do is + to declare "org.slf4j:slf4j-reload4j" as a dependency in your + pom.xml file as shown below. In addition to + slf4j-reload4j-${latest.stable.version}.jar, this will pull + slf4j-api-${latest.stable.version}.jar as well as + reload4j-${reload4j.version}.jar into your project. Note + that explicitly declaring a dependency on + reload4j-${reload4j.version}.jar or + slf4j-api-${latest.stable.version}.jar is not wrong and may + be necessary to impose the correct version of said artifacts by + virtue of Maven's "nearest definition" dependency mediation + rule.

+ + +
<dependency> 
+  <groupId>org.slf4j</groupId>
+  <artifactId>slf4j-reload4j</artifactId>
+  <version>${latest.stable.version}</version>
+</dependency>
+ + + + +

log4j If you wish to use log4j as the underlying logging framework, all you need to do is to declare "org.slf4j:slf4j-log4j12" as a dependency in your pom.xml file as shown below. In addition to @@ -484,6 +509,8 @@ SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further detail

+ +

java.util.logging If you wish to use java.util.logging as the underlying logging framework, all you need to do is to declare @@ -561,6 +588,22 @@ SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further detail APIs.

+

Support for JDK Platform Logging (JEP 264) + SLF4J

+ +

Since 2.0.0-alpha5 The + slf4j-jdk-platform-logging module adds support for JDK Platform + Logging.

+ +
<dependency> 
+  <groupId>org.slf4j</groupId>
+  <artifactId>slf4j-jdk-platform-logging</artifactId>
+  <version>${latest.2.version}</version>
+</dependency>
+ + +

Mapped Diagnostic Context (MDC) support

"Mapped Diagnostic Context" is essentially a map maintained diff --git a/slf4j-site/src/site/pages/news.html b/slf4j-site/src/site/pages/news.html index c6eb11fa..d51fe0a2 100755 --- a/slf4j-site/src/site/pages/news.html +++ b/slf4j-site/src/site/pages/news.html @@ -53,7 +53,7 @@ page.

-

SLF4J version 2.0.0 requires Java 8. It builds upon the 1.8.x +

SLF4J 2.0.x series requires Java 8. It builds upon the 1.8.x series and adds a backward-compatible fluent logging api. By backward-compatible, we mean that existing logging frameworks do @@ -64,7 +64,7 @@ href="faq.html#changesInVersion200">detailed in the FAQ page.

-

SLF4J now ships with the slf4j-reload4j module +

• SLF4J now ships with the slf4j-reload4j module delegating to the reload4j backend. Reload4j is a drop-in replacement for log4j version 1.2.17.

@@ -77,10 +77,9 @@
-

30th of August, 2021 - Release of SLF4J 1.7.33/h3> +

2022-01-13 - Release of SLF4J 1.7.33

- -

SLF4J now ships with the slf4j-reload4j module +

• SLF4J now ships with the slf4j-reload4j module delegating to the reload4j backend. Reload4j is a drop-in replacement for log4j version 1.2.17.

diff --git a/slf4j-site/src/site/pages/templates/left.js b/slf4j-site/src/site/pages/templates/left.js index ba8c2f84..b2edb5ef 100755 --- a/slf4j-site/src/site/pages/templates/left.js +++ b/slf4j-site/src/site/pages/templates/left.js @@ -17,9 +17,10 @@ document.write(' '); document.write(' Logback'); document.write(' '); -document.write(' JDK14'); -document.write(' Log4j'); -document.write(' Simple'); +document.write(' JUL'); +document.write(' Log4j'); +document.write(' reload4j'); +document.write(' Simple'); document.write('

');