Skip to content

Commit

Permalink
Remove spurious semicolons in Layouts chapter
Browse files Browse the repository at this point in the history
Signed-off-by: Johnny Lim <[email protected]>
  • Loading branch information
izeye committed Mar 21, 2023
1 parent 00e6479 commit 64b8752
Showing 1 changed file with 82 additions and 82 deletions.
164 changes: 82 additions & 82 deletions src/site/pages/manual/layouts.html
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ <h3 class="doAnchor" name="configuringYourOwnLayout">Configuring

<pre><code>package chapters.layouts;

import ch.qos.logback.classic.;spi.ILoggingEvent;
import ch.qos.logback.core.;LayoutBase;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.LayoutBase;

public class MySampleLayout2 extends LayoutBase&lt;ILoggingEvent> {

Expand All @@ -244,19 +244,19 @@ <h3 class="doAnchor" name="configuringYourOwnLayout">Configuring
<b>if (prefix != null) {
sbuf.append(prefix + ": ");
}</b>
sbuf.append(event.;getTimeStamp() - event.getLoggerContextVO(;).getBirthTime(;));
sbuf.append(event.getTimeStamp() - event.getLoggerContextVO().getBirthTime());
sbuf.append(" ");
sbuf.append(event.;getLevel());
sbuf.append(event.getLevel());
<b>if (printThreadName) {
sbuf.append(" [");
sbuf.append(event.;getThreadName());
sbuf.append(event.getThreadName());
sbuf.append("] ");
} else {
sbuf.append(" ");
}</b>
sbuf.append(event.;getLoggerName());
sbuf.append(event.getLoggerName());
sbuf.append(" - ");
sbuf.append(event.;getFormattedMessage(;));
sbuf.append(event.getFormattedMessage());
sbuf.append(LINE_SEP);
return sbuf.toString();
}
Expand Down Expand Up @@ -357,31 +357,31 @@ <h2 class="doAnchor" name="ClassicPatternLayout">PatternLayout</h2>

import org.slf4j.LoggerFactory;

import ch.qos.logback.classic.;Logger;
import ch.qos.logback.classic.;LoggerContext;
import ch.qos.logback.classic.;encoder.PatternLayoutEncoder;
import ch.qos.logback.classic.;spi.ILoggingEvent;
import ch.qos.logback.core.;ConsoleAppender;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.encoder.PatternLayoutEncoder;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.ConsoleAppender;

public class PatternSample {

static public void main(String[] args) throws Exception {
Logger rootLogger = (Logger)LoggerFactory.;getLogger(Logger.;ROOT_LOGGER_NAME);
LoggerContext loggerContext = rootLogger.getLoggerContext(;);
Logger rootLogger = (Logger)LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
LoggerContext loggerContext = rootLogger.getLoggerContext();
// we are not interested in auto-configuration
loggerContext.reset();

<b>PatternLayoutEncoder encoder = new PatternLayoutEncoder();</b>
<b>encoder.setContext(;loggerContext);</b>
<b>encoder.setPattern(;"%-5level [%thread]: %message%n");</b>
<b>encoder.setContext(loggerContext);</b>
<b>encoder.setPattern("%-5level [%thread]: %message%n");</b>
<b>encoder.start();</b>

ConsoleAppender&lt;ILoggingEvent> appender = new ConsoleAppender&lt;ILoggingEvent>();
appender.setContext(;loggerContext);
appender.setEncoder(;encoder);
appender.setContext(loggerContext);
appender.setEncoder(encoder);
appender.start();

rootLogger.addAppender(;appender);
rootLogger.addAppender(appender);

rootLogger.debug("Message 1");
rootLogger.warn("Message 2");
Expand Down Expand Up @@ -702,15 +702,15 @@ <h2 class="doAnchor" name="ClassicPatternLayout">PatternLayout</h2>
following excerpt:</p>

<pre class="source white_bg">0 [main] DEBUG - logging statement
Caller+0 at mainPackage.sub.;sample.Bar.sampleMethodName(;Bar.java:22)
Caller+1 at mainPackage.sub.;sample.Bar.createLoggingRequest(;Bar.java:17)</pre>
Caller+0 at mainPackage.sub.sample.Bar.sampleMethodName(Bar.java:22)
Caller+1 at mainPackage.sub.sample.Bar.createLoggingRequest(Bar.java:17)</pre>

<p>And <b>%caller{3}</b> would display this other excerpt:</p>

<pre class="source white_bg">16 [main] DEBUG - logging statement
Caller+0 at mainPackage.sub.;sample.Bar.sampleMethodName(;Bar.java:22)
Caller+1 at mainPackage.sub.;sample.Bar.createLoggingRequest(;Bar.java:17)
Caller+2 at mainPackage.ConfigTester.;main(ConfigTester.;java:38)</pre>
Caller+0 at mainPackage.sub.sample.Bar.sampleMethodName(Bar.java:22)
Caller+1 at mainPackage.sub.sample.Bar.createLoggingRequest(Bar.java:17)
Caller+2 at mainPackage.ConfigTester.main(ConfigTester.java:38)</pre>

<p>A range specifier can be added to the <em>caller</em> conversion specifier's
options to configure the depth range of the information to be displayed.
Expand All @@ -719,7 +719,7 @@ <h2 class="doAnchor" name="ClassicPatternLayout">PatternLayout</h2>
<p>For example, <b>%caller{1..2}</b> would display the following excerpt:</p>

<pre class="source white_bg">0 [main] DEBUG - logging statement
Caller+0 at mainPackage.sub.;sample.Bar.createLoggingRequest(;Bar.java:17)</pre>
Caller+0 at mainPackage.sub.sample.Bar.createLoggingRequest(Bar.java:17)</pre>

<p>This conversion word can also use evaluators to test
logging events against a given criterion before computing
Expand Down Expand Up @@ -1003,14 +1003,14 @@ <h2 class="doAnchor" name="ClassicPatternLayout">PatternLayout</h2>
<p>Here is an example:</p>

<p class="source small">java.lang.NullPointerException
at com.xyz.Wombat(Wombat.;java:57) <b><span class="red">~</span>[wombat-1.3.jar:1.3]</b>
at com.xyz.Wombat(Wombat.;java:76) ~[wombat-1.3.jar:1.3]
at sun.reflect.NativeMethodAccessorImpl.;invoke0(Native Method) ~[na:1.5.0_06]
at sun.reflect.NativeMethodAccessorImpl.;invoke(NativeMethodAccessorImpl.;java:39) ~[na:1.5.0_06]
at sun.reflect.DelegatingMethodAccessorImpl.;invoke(DelegatingMethodAccessorImpl.;java:25) ~[na:1.5.0_06]
at java.lang.reflect.;Method.invoke(Method.;java:585) ~[na:1.5.0_06]
at org.junit.internal.;runners.TestMethod.;invoke(TestMethod.;java:59) [junit-4.4.jar:na]
at org.junit.internal.;runners.MethodRoadie.;runTestMethod(MethodRoadie.;java:98) [junit-4.4.jar:na]
at com.xyz.Wombat(Wombat.java:57) <b><span class="red">~</span>[wombat-1.3.jar:1.3]</b>
at com.xyz.Wombat(Wombat.java:76) ~[wombat-1.3.jar:1.3]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.5.0_06]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[na:1.5.0_06]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[na:1.5.0_06]
at java.lang.reflect.Method.invoke(Method.java:585) ~[na:1.5.0_06]
at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59) [junit-4.4.jar:na]
at org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98) [junit-4.4.jar:na]
...etc </p>

<p>Logback goes to great lengths to ensure that the class
Expand Down Expand Up @@ -1177,12 +1177,12 @@ <h2 class="doAnchor" name="ClassicPatternLayout">PatternLayout</h2>
</p>

<pre class="small">java.lang.NullPointerException
at com.xyz.Wombat(Wombat.;java:57) ~[wombat-1.3.jar:1.3]
at com.xyz.Wombat(Wombat.;java:76) ~[wombat-1.3.jar:1.3]
Wrapped by: org.springframework.;BeanCreationException: Error creating bean with name 'wombat':
at org.springframework.;AbstractBeanFactory.;getBean(AbstractBeanFactory.;java:248) [spring-2.0.jar:2.0]
at org.springframework.;AbstractBeanFactory.;getBean(AbstractBeanFactory.;java:170) [spring-2.0.jar:2.0]
at org.apache.catalina.;StandardContext.;listenerStart(StandardContext.;java:3934) [tomcat-6.0.26.jar:6.0.26]
at com.xyz.Wombat(Wombat.java:57) ~[wombat-1.3.jar:1.3]
at com.xyz.Wombat(Wombat.java:76) ~[wombat-1.3.jar:1.3]
Wrapped by: org.springframework.BeanCreationException: Error creating bean with name 'wombat':
at org.springframework.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248) [spring-2.0.jar:2.0]
at org.springframework.AbstractBeanFactory.getBean(AbstractBeanFactory.java:170) [spring-2.0.jar:2.0]
at org.apache.catalina.StandardContext.listenerStart(StandardContext.java:3934) [tomcat-6.0.26.jar:6.0.26]
</pre>

<p>The %rootException converter admits the same optional
Expand Down Expand Up @@ -1449,23 +1449,23 @@ <h2 class="doAnchor" name="grouping">Grouping with

<p>Assuming without the grouping the output was</p>

<p class="source">13:09:30 [main] DEBUG c.q.logback.demo.;ContextListener - Classload hashcode is 13995234
13:09:30 [main] DEBUG c.q.logback.demo.;ContextListener - Initializing for ServletContext
13:09:30 [main] DEBUG c.q.logback.demo.;ContextListener - Trying platform Mbean server
13:09:30 [pool-1-thread-1] INFO ch.qos.logback.demo.;LoggingTask - Howdydy-diddly-ho - 0
13:09:38 [btpool0-7] INFO c.q.l.demo.lottery.;LotteryAction - Number: 50 was tried.
<p class="source">13:09:30 [main] DEBUG c.q.logback.demo.ContextListener - Classload hashcode is 13995234
13:09:30 [main] DEBUG c.q.logback.demo.ContextListener - Initializing for ServletContext
13:09:30 [main] DEBUG c.q.logback.demo.ContextListener - Trying platform Mbean server
13:09:30 [pool-1-thread-1] INFO ch.qos.logback.demo.LoggingTask - Howdydy-diddly-ho - 0
13:09:38 [btpool0-7] INFO c.q.l.demo.lottery.LotteryAction - Number: 50 was tried.
13:09:40 [btpool0-7] INFO c.q.l.d.prime.NumberCruncherImpl - Beginning to factor.
13:09:40 [btpool0-7] DEBUG c.q.l.d.prime.NumberCruncherImpl - Trying 2 as a factor.
13:09:40 [btpool0-7] INFO c.q.l.d.prime.NumberCruncherImpl - Found factor 2
</p>

<p>with the "%-30()" grouping it would be</p>

<p class="source">13:09:30 [main] DEBUG c.q.logback.demo.;ContextListener - Classload hashcode is 13995234
13:09:30 [main] DEBUG c.q.logback.demo.;ContextListener - Initializing for ServletContext
13:09:30 [main] DEBUG c.q.logback.demo.;ContextListener - Trying platform Mbean server
13:09:30 [pool-1-thread-1] INFO ch.qos.logback.demo.;LoggingTask - Howdydy-diddly-ho - 0
13:09:38 [btpool0-7] INFO c.q.l.demo.lottery.;LotteryAction - Number: 50 was tried.
<p class="source">13:09:30 [main] DEBUG c.q.logback.demo.ContextListener - Classload hashcode is 13995234
13:09:30 [main] DEBUG c.q.logback.demo.ContextListener - Initializing for ServletContext
13:09:30 [main] DEBUG c.q.logback.demo.ContextListener - Trying platform Mbean server
13:09:30 [pool-1-thread-1] INFO ch.qos.logback.demo.LoggingTask - Howdydy-diddly-ho - 0
13:09:38 [btpool0-7] INFO c.q.l.demo.lottery.LotteryAction - Number: 50 was tried.
13:09:40 [btpool0-7] INFO c.q.l.d.prime.NumberCruncherImpl - Beginning to factor.
13:09:40 [btpool0-7] DEBUG c.q.l.d.prime.NumberCruncherImpl - Trying 2 as a factor.
13:09:40 [btpool0-7] INFO c.q.l.d.prime.NumberCruncherImpl - Found factor 2
Expand Down Expand Up @@ -1615,7 +1615,7 @@ <h2 class="doAnchor" name="Evaluators">Evaluators</h2>
message.contains("who calls thee")&lt;/expression>
&lt;/evaluator></b>

&lt;appender name="STDOUT" class="ch.qos.logback.;core.ConsoleAppender">
&lt;appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
&lt;encoder>
&lt;pattern>
%-4relative [%thread] %-5level -%kvp -%msg%n<b>%caller{2, DISP_CALLER_EVAL}</b>
Expand Down Expand Up @@ -1653,25 +1653,25 @@ <h2 class="doAnchor" name="Evaluators">Evaluators</h2>
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import ch.qos.logback.classic.;LoggerContext;
import ch.qos.logback.classic.;joran.JoranConfigurator;
import ch.qos.logback.core.;joran.spi.JoranException;
import ch.qos.logback.core.;util.StatusPrinter;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.core.joran.spi.JoranException;
import ch.qos.logback.core.util.StatusPrinter;

public class CallerEvaluatorExample {

public static void main(String[] args) {
Logger logger = LoggerFactory.getLogger(;CallerEvaluatorExample.;class);
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(;);
Logger logger = LoggerFactory.getLogger(CallerEvaluatorExample.class);
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();

try {
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(;lc);
configurator.doConfigure(;args[0]);
configurator.setContext(lc);
configurator.doConfigure(args[0]);
} catch (JoranException je) {
// StatusPrinter will handle this
}
StatusPrinter.printInCaseOfErrorsOrWarnings(;lc);
StatusPrinter.printInCaseOfErrorsOrWarnings(lc);

for (int i = 0; i &lt; 5; i++) {
if (i == 3) {
Expand All @@ -1690,15 +1690,15 @@ <h2 class="doAnchor" name="Evaluators">Evaluators</h2>

<p>The command</p>

<p class="source">java chapters.layouts.;CallerEvaluatorExample src/main/java/chapters/&#8203;layouts/callerEvaluatorConfig.&#8203;xml</p>
<p class="source">java chapters.layouts.CallerEvaluatorExample src/main/java/chapters/&#8203;layouts/callerEvaluatorConfig.&#8203;xml</p>

<p>will yield</p>

<div class="source"><pre>0 [main] DEBUG - I know me 0
0 [main] DEBUG - I know me 1
0 [main] DEBUG - I know me 2
0 [main] DEBUG - who calls thee?
Caller+0 at chapters.layouts.;CallerEvaluatorExample.&#8203;main(CallerEvaluatorExample.&#8203;java:28)
Caller+0 at chapters.layouts.CallerEvaluatorExample.&#8203;main(CallerEvaluatorExample.&#8203;java:28)
0 [main] DEBUG - I know me 4</pre></div>


Expand Down Expand Up @@ -1746,26 +1746,26 @@ <h2 class="doAnchor" name="Evaluators">Evaluators</h2>
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import ch.qos.logback.classic.;LoggerContext;
import ch.qos.logback.classic.;joran.JoranConfigurator;
import ch.qos.logback.core.;joran.spi.JoranException;
import ch.qos.logback.core.;util.StatusPrinter;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.core.joran.spi.JoranException;
import ch.qos.logback.core.util.StatusPrinter;

public class ExceptionEvaluatorExample {

public static void main(String[] args) {
Logger logger = LoggerFactory.getLogger(;ExceptionEvaluatorExample.;class);
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(;);
Logger logger = LoggerFactory.getLogger(ExceptionEvaluatorExample.class);
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();

try {
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(;lc);
configurator.setContext(lc);
lc.reset();
configurator.doConfigure(;args[0]);
configurator.doConfigure(args[0]);
} catch (JoranException je) {
// StatusPrinter will handle this
}
StatusPrinter.printInCaseOfErrorsOrWarnings(;lc);
StatusPrinter.printInCaseOfErrorsOrWarnings(lc);

for (int i = 0; i &lt; 3; i++) {
if (i == 1) {
Expand Down Expand Up @@ -1833,11 +1833,11 @@ <h2 class="doAnchor" name="Evaluators">Evaluators</h2>

<p class="source">logging statement 0
java.lang.Exception: display
at chapters.layouts.;ExceptionEvaluatorExample.;main(ExceptionEvaluatorExample.;java:43) [logback-examples-0.;9.19.jar:na]
at chapters.layouts.ExceptionEvaluatorExample.main(ExceptionEvaluatorExample.java:43) [logback-examples-0.9.19.jar:na]
logging statement 1
logging statement 2
java.lang.Exception: display
at chapters.layouts.;ExceptionEvaluatorExample.;main(ExceptionEvaluatorExample.;java:43) [logback-examples-0.;9.19.jar:na]</p>
at chapters.layouts.ExceptionEvaluatorExample.main(ExceptionEvaluatorExample.java:43) [logback-examples-0.9.19.jar:na]</p>


<p>Notice how the second log statement has no stack trace. We
Expand Down Expand Up @@ -1919,9 +1919,9 @@ <h4>Step 2</h4>
<pre><code>&lt;configuration>

<b>&lt;conversionRule conversionWord="nanos"
converterClass="chapters.;layouts.MySampleConverter" /></b>
converterClass="chapters.layouts.MySampleConverter" /></b>

&lt;appender name="STDOUT" class="ch.qos.logback.;core.ConsoleAppender">
&lt;appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
&lt;encoder>
&lt;pattern><b>%-6nanos</b> [%thread] -%kvp -%msg%n&lt;/pattern>
&lt;/encoder>
Expand Down Expand Up @@ -2010,9 +2010,9 @@ <h2 class="doAnchor" name="ClassicHTMLLayout">HTMLLayout</h2>

<div id="htmlLayoutConfig1_legacy" class="tabcontent">
<pre><code>&lt;configuration debug="true"&gt;
&lt;appender name="FILE" class="ch.qos.logback.;core.FileAppender"&gt;
&lt;encoder class="ch.qos.logback.;core.encoder.LayoutWrappingEncoder">
&lt;layout class="ch.qos.logback.;classic.html.HTMLLayout">
&lt;appender name="FILE" class="ch.qos.logback.core.FileAppender"&gt;
&lt;encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
&lt;layout class="ch.qos.logback.classic.html.HTMLLayout">
<b>&lt;pattern&gt;%relative%thread%mdc%level%logger%msg&lt;/pattern&gt;</b>
&lt;/layout&gt;
&lt;/encoder>
Expand Down Expand Up @@ -2084,9 +2084,9 @@ <h3>CSS</h3>
<code>&lt;layout&gt;</code> element, as shown below.
</p>

<pre><code>&lt;layout class="ch.qos.logback.;classic.html.HTMLLayout">
<pre><code>&lt;layout class="ch.qos.logback.classic.html.HTMLLayout">
&lt;pattern>%relative...%msg&lt;/;pattern>
&lt;cssBuilder class="ch.qos.logback.;classic.html.UrlCssBuilder">
&lt;cssBuilder class="ch.qos.logback.classic.html.UrlCssBuilder">
&lt;!-- url where the css file is located --&gt;
&lt;url>http://...&lt;/url>
&lt;/cssBuilder>
Expand Down Expand Up @@ -2135,10 +2135,10 @@ <h2 class="doAnchor" name="log4jXMLLayout">Log4j XMLLayout</h2>

<div id="log4jXMLLayout_legacy" class="tabcontent">
<pre><code>&lt;configuration>
&lt;appender name="FILE" class="ch.qos.logback.;core.FileAppender">
&lt;appender name="FILE" class="ch.qos.logback.core.FileAppender">
&lt;file>test.xml&lt;/file>
&lt;encoder class="ch.qos.logback.;core.encoder.LayoutWrappingEncoder">
&lt;layout class="ch.qos.logback.;classic.log4j.XMLLayout">
&lt;encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
&lt;layout class="ch.qos.logback.classic.log4j.XMLLayout">
&lt;locationInfo>true&lt;/locationInfo>
&lt;/layout>
&lt;/encoder>
Expand Down

0 comments on commit 64b8752

Please sign in to comment.