1717 < div id ="content ">
1818
1919
20-
2120 < h2 > SLF4J user manual</ h2 >
2221
2322 < p > The Simple Logging Facade for Java (SLF4J) serves as a simple
@@ -89,15 +88,16 @@ <h3 class="doAnchor" name="hello_world">Hello World</h3>
8988 logger is in turn used to log the message "Hello World".
9089 </ p >
9190
92- < pre class =" prettyprint source " > import org.slf4j.Logger;
91+ < pre > < code > import org.slf4j.Logger;
9392import org.slf4j.LoggerFactory;
9493
9594public class HelloWorld {
95+
9696 public static void main(String[] args) {
9797 Logger logger = LoggerFactory.getLogger(HelloWorld.class);
9898 logger.info("Hello World");
9999 }
100- }</ pre >
100+ }</ code > </ pre >
101101
102102 < p > To run this example, you first need to < a
103103 href ="download.html "> obtain slf4j</ a > artifacts. Once that is
@@ -147,7 +147,7 @@ <h3 class="doAnchor" name="typical_usage">Typical usage
147147
148148 < p > </ p >
149149
150- < pre class =" prettyprint source " > 1: < b > import org.slf4j.Logger;</ b >
150+ < pre > < code > 1: < b > import org.slf4j.Logger;</ b >
151151 2: < b > import org.slf4j.LoggerFactory;</ b >
152152 3:
153153 4: public class Wombat {
@@ -167,7 +167,7 @@ <h3 class="doAnchor" name="typical_usage">Typical usage
16716718: < b > logger.info("Temperature has risen above 50 degrees.");</ b >
16816819: }
16916920: }
170- 21: } </ pre >
170+ 21: } </ code > </ pre >
171171
172172
173173 < h3 class ="doAnchor " name ="fluent "> Fluent Logging API</ h3 >
@@ -203,33 +203,32 @@ <h3 class="doAnchor" name="fluent">Fluent Logging API</h3>
203203 < p > Here are few usage examples:</ p >
204204
205205 < p > The statement</ p >
206- < pre class =" prettyprint source " > logger.atInfo().log("Hello world.");</ pre >
206+ < pre > < code > logger.atInfo().log("Hello world.");</ code > </ pre >
207207
208208 < p > is equivalent to:</ p >
209209
210- < pre class =" prettyprint source " > logger.info("Hello world.");</ pre >
210+ < pre > < code > logger.info("Hello world.");</ code > </ pre >
211211
212212
213213 < p > The following log statements are equivalent in their output
214214 (for the default implementation):</ p >
215215
216- < pre class ="prettyprint source ">
217- int newT = 15;
218- int oldT = 16;
216+ < pre > < code > int newT = 15;
217+ int oldT = 16;
219218
220- // using traditional API
221- logger.debug("Temperature set to {}. Old value was {}.", newT, oldT);
219+ // using traditional API
220+ logger.debug("Temperature set to {}. Old value was {}.", newT, oldT);
222221
223- // using fluent API, log message with arguments
224- logger.< b > atDebug()</ b > .log("Temperature set to {}. Old value was {}.", newT, oldT);
225-
226- // using fluent API, add arguments one by one and then log message
227- logger.< b > atDebug()</ b > .setMessage("Temperature set to {}. Old value was {}.").addArgument(newT).addArgument(oldT).< b > log()</ b > ;
222+ // using fluent API, log message with arguments
223+ logger.< b > atDebug()</ b > .log("Temperature set to {}. Old value was {}.", newT, oldT);
224+
225+ // using fluent API, add arguments one by one and then log message
226+ logger.< b > atDebug()</ b > .setMessage("Temperature set to {}. Old value was {}.").addArgument(newT).addArgument(oldT).< b > log()</ b > ;
228227
229- // using fluent API, add one argument with a Supplier and then log message with one more argument.
230- // Assume the method t16() returns 16.
231- logger.< b > atDebug()</ b > .setMessage("Temperature set to {}. Old value was {}.").addArgument(() -> t16()).addArgument(oldT).< b > log()</ b > ;
232- </ pre >
228+ // using fluent API, add one argument with a Supplier and then log message with one more argument.
229+ // Assume the method t16() returns 16.
230+ logger.< b > atDebug()</ b > .setMessage("Temperature set to {}. Old value was {}.").addArgument(() -> t16()).addArgument(oldT).< b > log()</ b > ;
231+ </ code > </ pre >
233232
234233 < p > The fluent logging API allows the specification of many
235234 different types of data to a < code > org.slf4j.Logger</ code >
@@ -246,16 +245,15 @@ <h3 class="doAnchor" name="fluent">Fluent Logging API</h3>
246245
247246 < p > The following log statements are equivalent:</ p >
248247
249- < pre class ="prettyprint source ">
250- int newT = 15;
251- int oldT = 16;
248+ < pre > < code > int newT = 15;
249+ int oldT = 16;
252250
253- // using classical API
254- logger.debug("oldT={} newT={} Temperature changed.", oldT, newT);
251+ // using classical API
252+ logger.debug("oldT={} newT={} Temperature changed.", oldT, newT);
255253
256- // using fluent API
257- logger.atDebug().setMessge("Temperature changed.").< b > addKeyValue("oldT", oldT)</ b > .addKeyValue("newT", newT).log();
258- </ pre >
254+ // using fluent API
255+ logger.atDebug().setMessge("Temperature changed.").< b > addKeyValue("oldT", oldT)</ b > .addKeyValue("newT", newT).log();
256+ </ code > </ pre >
259257
260258 < p > The key-value pair variant of the API stores the key-value
261259 pairs as separates objects. The default implementation as
@@ -385,9 +383,9 @@ <h3 class="doAnchor" name="swapping">Binding with a logging
385383 < p > Here is a graphical illustration of the general idea.
386384 </ p >
387385
388- < p > < a href ="images/concrete-bindings.png ">
389- < img border =" 1 " src ="images/concrete-bindings.png " alt ="click to enlarge " width ="800 "/>
390- </ a > </ p >
386+ < a href ="images/concrete-bindings.png ">
387+ < img src ="images/concrete-bindings.png " alt ="click to enlarge " width ="800 "/>
388+ </ a >
391389
392390 < p > The SLF4J interfaces and their various adapters are extremely
393391 simple. Most developers familiar with the Java language should
@@ -473,11 +471,11 @@ <h3 class="doAnchor" name="projectDep">Declaring project
473471 </ p >
474472
475473
476- < pre class =" prettyprint source " > <dependency>
474+ < pre > < code > <dependency>
477475 <groupId> org.slf4j</groupId>
478476 <artifactId> slf4j-api</artifactId>
479477 <version> ${latest.stable.version}</version>
480- </dependency> </ pre >
478+ </dependency> </ code > </ pre >
481479
482480 <!-- ========================================================= -->
483481 < p > < span class ="label notice "> logback-classic</ span > < span
@@ -498,11 +496,11 @@ <h3 class="doAnchor" name="projectDep">Declaring project
498496 rule.
499497 </ p >
500498
501- < pre class =" prettyprint source " > <dependency>
499+ < pre > < code > <dependency>
502500 <groupId> ch.qos.logback</groupId>
503501 <artifactId> logback-classic</artifactId>
504502 <version> ${logback-javax.version}</version>
505- </dependency> </ pre >
503+ </dependency> </ code > </ pre >
506504
507505 < p />
508506
@@ -528,11 +526,11 @@ <h3 class="doAnchor" name="projectDep">Declaring project
528526 mediation rule.
529527 </ p >
530528
531- < pre class =" prettyprint source " > <dependency>
529+ < pre > < code > <dependency>
532530 <groupId> ch.qos.logback</groupId>
533531 <artifactId> logback-classic</artifactId>
534532 <version> ${logback-jakarta.version}</version>
535- </dependency> </ pre >
533+ </dependency> </ code > </ pre >
536534
537535 < p />
538536
@@ -552,11 +550,11 @@ <h3 class="doAnchor" name="projectDep">Declaring project
552550 by virtue of Maven's "nearest definition" dependency mediation
553551 rule.</ p >
554552
555- < pre class =" prettyprint source " > <dependency>
553+ < pre > < code > <dependency>
556554 <groupId> org.slf4j</groupId>
557555 <artifactId> slf4j-reload4j</artifactId>
558556 <version> ${latest.stable.version}</version>
559- </dependency> </ pre >
557+ </dependency> </ code > </ pre >
560558
561559
562560 <!-- ================================== -->
@@ -567,11 +565,11 @@ <h3 class="doAnchor" name="projectDep">Declaring project
567565 < code > org.slf4j:slf4j-reload4j</ code > by virtue of Maven
568566 <relocation> directive. </ p >
569567
570- < pre class =" prettyprint source " > <dependency>
568+ < pre > < code > <dependency>
571569 <groupId> org.slf4j</groupId>
572570 <artifactId> slf4j-log4j12</artifactId>
573571 <version> ${latest.stable.version}</version>
574- </dependency> </ pre >
572+ </dependency> </ code > </ pre >
575573
576574 < p />
577575
@@ -590,11 +588,11 @@ <h3 class="doAnchor" name="projectDep">Declaring project
590588 by virtue of Maven's "nearest definition" dependency mediation
591589 rule.</ p >
592590
593- < pre class =" prettyprint source " > <dependency>
591+ < pre > < code > <dependency>
594592 <groupId> org.slf4j</groupId>
595593 <artifactId> slf4j-jdk14</artifactId>
596594 <version> ${latest.stable.version}</version>
597- </dependency> </ pre >
595+ </dependency> </ code > </ pre >
598596
599597 <!-- ================================== -->
600598
@@ -611,11 +609,11 @@ <h3 class="doAnchor" name="projectDep">Declaring project
611609 by virtue of Maven's "nearest definition" dependency mediation
612610 rule.</ p >
613611
614- < pre class =" prettyprint source " > <dependency>
612+ < pre > < code > <dependency>
615613 <groupId> org.slf4j</groupId>
616614 <artifactId> slf4j-simple</artifactId>
617615 <version> ${latest.stable.version}</version>
618- </dependency> </ pre >
616+ </dependency> </ code > </ pre >
619617
620618 <!-- =========================================================== -->
621619
@@ -683,11 +681,11 @@ <h3 class="doAnchor" name="jep264">Support for JDK Platform Logging (JEP 264)
683681 href ="http://openjdk.java.net/jeps/264 "> JDK Platform
684682 Logging</ a > . </ p >
685683
686- < pre class =" prettyprint source " > <dependency>
684+ < pre > < code > <dependency>
687685 <groupId> org.slf4j</groupId>
688686 <artifactId> slf4j-jdk-platform-logging</artifactId>
689687 <version> ${latest.2.version}</version>
690- </dependency> </ pre >
688+ </dependency> </ code > </ pre >
691689
692690
693691
@@ -722,7 +720,8 @@ <h3 class="doAnchor" name="mdc">Mapped Diagnostic Context (MDC) support</h3>
722720
723721
724722 < h3 class ="doAnchor " name ="summary "> Executive summary</ h3 >
725-
723+
724+ < div clas ="bodyTable ">
726725 < table class ="bodyTable striped " cellspacing ="4 " cellpadding ="4 ">
727726 < tr >
728727 < th align ="left "> Advantage</ th >
@@ -797,9 +796,7 @@ <h3 class="doAnchor" name="summary">Executive summary</h3>
797796 href ="faq.html#logging_performance "> improved performance</ a >
798797 results.</ td >
799798 </ tr >
800-
801-
802- </ table >
799+ </ table > </ div >
803800
804801 < script src ="templates/footer.js " type ="text/javascript "> </ script >
805802
0 commit comments