Skip to content

Commit

Permalink
added paragraph on JEP264, doc changes, minor refactoring
Browse files Browse the repository at this point in the history
Signed-off-by: Ceki Gulcu <ceki@qos.ch>
  • Loading branch information
ceki committed Jan 17, 2022
1 parent 39a07b9 commit 16ab482
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 16 deletions.
1 change: 1 addition & 0 deletions pom.xml
Expand Up @@ -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>
Expand Down
Expand Up @@ -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
Expand All @@ -57,7 +62,7 @@ public JDK14LoggerFactory() {
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);
Expand Down
57 changes: 50 additions & 7 deletions slf4j-site/src/site/pages/manual.html
Expand Up @@ -417,12 +417,12 @@ <h3 class="doAnchor" name="libraries">Libraries</h3>

<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
Expand Down Expand Up @@ -462,7 +462,32 @@ <h3 class="doAnchor" name="projectDep">Declaring project

<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
Expand All @@ -484,6 +509,8 @@ <h3 class="doAnchor" name="projectDep">Declaring project

<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
Expand Down Expand Up @@ -561,6 +588,22 @@ <h3 class="doAnchor" name="consolidate">Consolidate logging via
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
Expand Down
9 changes: 4 additions & 5 deletions slf4j-site/src/site/pages/news.html
Expand Up @@ -53,7 +53,7 @@ <h3>2022-01-13 - Release of SLF4J 2.0.0-alpha6</h3>
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
Expand All @@ -64,7 +64,7 @@ <h3>2022-01-13 - Release of SLF4J 2.0.0-alpha6</h3>
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>
Expand All @@ -77,10 +77,9 @@ <h3>2022-01-13 - Release of SLF4J 2.0.0-alpha6</h3>

<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>
Expand Down
7 changes: 4 additions & 3 deletions slf4j-site/src/site/pages/templates/left.js
Expand Up @@ -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>');


Expand Down

0 comments on commit 16ab482

Please sign in to comment.