added paragraph on JEP264, doc changes, minor refactoring

Signed-off-by: Ceki Gulcu <ceki@qos.ch>
This commit is contained in:
Ceki Gulcu 2022-01-17 22:11:33 +01:00
parent 39a07b9ce4
commit 16ab482cab
5 changed files with 65 additions and 16 deletions

View File

@ -34,6 +34,7 @@
<properties>
<latest.stable.version>1.7.33</latest.stable.version>
<latest.2.version>2.0.0-alpha6</latest.2.version>
<!-- java.util.ServiceLoader requires Java 6 -->
<jdk.version>8</jdk.version>
<maven.compiler.source>${jdk.version}</maven.compiler.source>

View File

@ -41,6 +41,11 @@ public class JDK14LoggerFactory implements ILoggerFactory {
// key: name (String), value: a JDK14LoggerAdapter;
ConcurrentMap<String, Logger> 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);

View File

@ -417,12 +417,12 @@ SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further detail
<p><span class="label">Basic rule</span> <b>Embedded components
such as libraries or frameworks should not declare a dependency
on any SLF4J binding but only depend on slf4j-api</b>. 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.</p>
on any SLF4J binding/provider but only depend on
slf4j-api</b>. 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.</p>
<p>SLF4J usage in embedded components is also discussed in the
FAQ in relation with <a
@ -462,7 +462,32 @@ SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further detail
<p/>
<p><span class="label notice">log4j</span> If you wish to use
<!-- ================================== -->
<p><span class="label notice">reload4j</span> 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
<em>pom.xml</em> file as shown below. In addition to
<em>slf4j-reload4j-${latest.stable.version}.jar</em>, this will pull
<em>slf4j-api-${latest.stable.version}.jar</em> as well as
<em>reload4j-${reload4j.version}.jar</em> into your project. Note
that explicitly declaring a dependency on
<em>reload4j-${reload4j.version}.jar</em> or
<em>slf4j-api-${latest.stable.version}.jar</em> 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.</p>
<pre class="prettyprint source">&lt;dependency>
&lt;groupId>org.slf4j&lt;/groupId>
&lt;artifactId>slf4j-reload4j&lt;/artifactId>
&lt;version>${latest.stable.version}&lt;/version>
&lt;/dependency></pre>
<!-- ================================== -->
<p><span class="label notice">log4j</span> 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
<em>pom.xml</em> file as shown below. In addition to
@ -484,6 +509,8 @@ SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further detail
<p/>
<!-- ================================== -->
<p><span class="label notice">java.util.logging</span> 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</b></a>.
</p>
<h3 class="doAnchor" name="jep264">Support for JDK Platform Logging (JEP 264)
SLF4J</h3>
<p><span class="label notice">Since 2.0.0-alpha5</span> The
<em>slf4j-jdk-platform-logging</em> module adds support for <a
href="http://openjdk.java.net/jeps/264">JDK Platform
Logging</a>. </p>
<pre class="prettyprint source">&lt;dependency>
&lt;groupId>org.slf4j&lt;/groupId>
&lt;artifactId>slf4j-jdk-platform-logging&lt;/artifactId>
&lt;version>${latest.2.version}&lt;/version>
&lt;/dependency></pre>
<h3 class="doAnchor" name="mdc">Mapped Diagnostic Context (MDC) support</h3>
<p>"Mapped Diagnostic Context" is essentially a map maintained

View File

@ -53,7 +53,7 @@
page.
</p>
<p>SLF4J version 2.0.0 requires Java 8. It builds upon the 1.8.x
<p>SLF4J 2.0.x series requires Java 8. It builds upon the 1.8.x
series and adds a backward-compatible <a
href="manual.html#fluent">fluent logging api</a>. By
backward-compatible, we mean that existing logging frameworks do
@ -64,7 +64,7 @@
href="faq.html#changesInVersion200">detailed</a> in the FAQ page.
</p>
<p>SLF4J now ships with the <em>slf4j-reload4j</em> module
<p>&bull; SLF4J now ships with the <em>slf4j-reload4j</em> module
delegating to the reload4j backend. <a
href="https://reload4j.qos.ch">Reload4j</a> is a drop-in
replacement for log4j version 1.2.17.</p>
@ -77,10 +77,9 @@
<hr noshade="noshade" size="1"/>
<h3>30th of August, 2021 - Release of SLF4J 1.7.33/h3>
<h3>2022-01-13 - Release of SLF4J 1.7.33</h3>
<p>SLF4J now ships with the <em>slf4j-reload4j</em> module
<p>&bull; SLF4J now ships with the <em>slf4j-reload4j</em> module
delegating to the reload4j backend. <a
href="https://reload4j.qos.ch">Reload4j</a> is a drop-in
replacement for log4j version 1.2.17.</p>

View File

@ -17,9 +17,10 @@ document.write(' <p class="menu_header">Native implementations</p>');
document.write(' <a href="https://logback.qos.ch/">Logback</a>');
document.write(' <p class="menu_header">Wrapped implementations</p>');
document.write(' <a href="api/org/slf4j/impl/JDK14LoggerAdapter.html">JDK14</a>');
document.write(' <a href="api/org/slf4j/impl/Log4jLoggerAdapter.html">Log4j</a>');
document.write(' <a href="api/org/slf4j/impl/SimpleLogger.html">Simple</a>');
document.write(' <a href="api/org/slf4j/jul/JDK14LoggerAdapter.html">JUL</a>');
document.write(' <a href="org/org/slf4j/log4j12/Log4jLoggerAdapter.html">Log4j</a>');
document.write(' <a href="api/org/slf4j/reload4j/Reload4jLoggerAdapter.html">reload4j</a>');
document.write(' <a href="api/org/slf4j/simple/SimpleLogger.html">Simple</a>');
document.write(' </p>');