[logback-dev] svn commit: r739 - logback/trunk/logback-site/src/site/xdocTemplates
noreply.seb at qos.ch
noreply.seb at qos.ch
Mon Oct 23 11:40:02 CEST 2006
Author: seb
Date: Mon Oct 23 11:40:01 2006
New Revision: 739
Modified:
logback/trunk/logback-site/src/site/xdocTemplates/accessLogJetty.xml
logback/trunk/logback-site/src/site/xdocTemplates/joran.xml
logback/trunk/logback-site/src/site/xdocTemplates/shortIntro.xml
Log:
Modified existing source excerpt to use the new css rules.
Unfortunately, we cannot use the rule with the old way of declaring
source excerpts because the <pre> tag must be present.
Modified: logback/trunk/logback-site/src/site/xdocTemplates/accessLogJetty.xml
==============================================================================
--- logback/trunk/logback-site/src/site/xdocTemplates/accessLogJetty.xml (original)
+++ logback/trunk/logback-site/src/site/xdocTemplates/accessLogJetty.xml Mon Oct 23 11:40:01 2006
@@ -92,15 +92,13 @@
<code>RequestLogImpl</code>, add the following lines
to the jetty configuration file, namely <em>$JETTY_HOME/etc/jetty.xml</em>:
</p>
- <pre>
-<Ref id="requestLog">
+ <div class="source"><pre><Ref id="requestLog">
<Set name="requestLog">
<New id="requestLogImpl"
class="ch.qos.logback.access.jetty.RequestLogImpl">
</New>
</Set>
-</Ref>
- </pre>
+</Ref></pre></div>
<p>
These lines reference the requestLog functionnality of Jetty, setting
the actual class that will be called at each logging request.
@@ -127,24 +125,21 @@
jetty configuration file, with a path to the logback access
configuration file.
</p>
- <pre>
-<Ref id="requestLog">
+ <div class="source"><pre><Ref id="requestLog">
<Set name="requestLog">
<New id="requestLogImpl"
class="ch.qos.logback.access.jetty.RequestLogImpl">
</New>
<Set name="fileName">path/to/myaccess.xml</Set>
</Set>
-</Ref>
- </pre>
+</Ref></pre></div>
<h2>Example 1: logback-access configuration</h2>
<p>
Here is a sample <em>logback-access.xml</em> file that you can
immediately put to use:
</p>
- <pre>
-<configuration>
+<div class="source"><pre><configuration>
<appender name="STDOUT"
class="ch.qos.logback.core.ConsoleAppender">
<layout
@@ -154,8 +149,7 @@
</appender>
<appender-ref ref="STDOUT" />
-</configuration>
- </pre>
+</configuration></pre></div>
<p>
It declares a <code>ConsoleAppender</code> which directs its
output at the console. The <code>ConsoleAppender</code> contains
@@ -171,9 +165,9 @@
equivalent
</p>
- <div class="source"><Pattern>%h %l %u %user %date "%r" %s %b</Pattern>
+ <div class="source"><pre><Pattern>%h %l %u %user %date "%r" %s %b</Pattern>
<Pattern>common</Pattern>
-<Pattern>clf</Pattern></div>
+<Pattern>clf</Pattern></pre></div>
<p>The so called "combined" format is also widely recognized. It is
defined as the '%h %l %u %t "%r" %s %b "%i{Referer}"
@@ -181,24 +175,22 @@
"combined" as a shorthand. Thus, the following directive
</p>
- <div class="source"><layout class="ch.qos.logback.access.PatternLayout">
+ <div class="source"><pre><layout class="ch.qos.logback.access.PatternLayout">
<Pattern>%h %l %u %t "%r" %s %b "%i{Referer}" "%i{User-Agent}"</Pattern>
-</layout></div>
+</layout></pre></div>
<p>is equivalent to:</p>
- <div class="source"><layout class="ch.qos.logback.access.PatternLayout">
+ <div class="source"><pre><layout class="ch.qos.logback.access.PatternLayout">
<Pattern>combined</Pattern>
-</layout>
- </div>
+</layout></pre></div>
<h2>Example 2: RollingFileAppender</h2>
<p>Another configuration file, using logback'
<code>RollingFileAppender</code>, could be:</p>
- <pre>
-<configuration>
+<div class="source"><pre><configuration>
<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy
@@ -213,8 +205,7 @@
</appender>
<appender-ref ref="FILE" />
-</configuration>
- </pre>
+</configuration></pre></div>
<p>
Here, there is no output to the console. Instead, logback access
Modified: logback/trunk/logback-site/src/site/xdocTemplates/joran.xml
==============================================================================
--- logback/trunk/logback-site/src/site/xdocTemplates/joran.xml (original)
+++ logback/trunk/logback-site/src/site/xdocTemplates/joran.xml Mon Oct 23 11:40:01 2006
@@ -119,7 +119,7 @@
</p>
-<div class="source">package ch.qos.logback.core.joran.action;
+<div class="source"><pre>package ch.qos.logback.core.joran.action;
import org.xml.sax.Attributes;
import ch.qos.logback.core.joran.spi.ExecutionContext;
@@ -140,8 +140,7 @@
* have been processed.
*/
public abstract void end(ExecutionContext ec, String name);
-}
-</div>
+}</pre></div>
<p>Thus, every action must implement the begin and end methods.</p>
@@ -243,13 +242,13 @@
</p>
<p>The <em>calculator2.xml</em> file is a bit more complex, and much more interesting.</p>
<p>It contains the following elements:</p>
-<source><computation name="toto">
+<div class="source"><pre><computation name="toto">
<literal value="7"/>
<literal value="3"/>
<add/>
<literal value="3"/>
<multiply/>
-</computation></source>
+</computation></pre></div>
<p>
Here, there are obviously more actions that will be part of the computation.
</p>
@@ -265,7 +264,7 @@
<p>Finally, a <em>calculator3.xml</em> is also provided, to demonstrate the possibility
elements that contain instances of the same element. Here's the content of
<em>calculator3.xml</em>:</p>
-<source><computation name="toto">
+<div class="source"><pre><computation name="toto">
<computation>
<literal value="7"/>
<literal value="3"/>
@@ -274,7 +273,7 @@
<literal value="3"/>
<multiply/>
-</computation></source>
+</computation></pre></div>
<p>Much like the use of parentheses in an algebrical equation, the presence of
a <code>computation</code> element nested in another is managed by the
@@ -305,12 +304,12 @@
<p>Here is how new rules can be declared in an xml file:</p>
-<div class="source"><new-rule pattern="*/computation/literal" actionClass="joran.calculator.LiteralAction"/></div>
+<div class="source"><pre><new-rule pattern="*/computation/literal" actionClass="joran.calculator.LiteralAction"/></pre></div>
<p>Using new rule declarations, the preceding example, involving the calculation, could be
expressed this way:</p>
-<div class="source"><computation name="toto">
+<div class="source"><pre><computation name="toto">
<new-rule pattern="*/computation/literal"
actionClass="joran.calculator.LiteralAction"/>
<new-rule pattern="*/computation/add"
@@ -326,7 +325,7 @@
<literal value="3"/>
<multiply/>
-</computation></div>
+</computation></pre></div>
<a name="implicit" />
<h3>Implicit actions </h3>
@@ -402,7 +401,7 @@
<p>The <em>implicit1.xml</em> file contains the following lines:</p>
-<source><foo>
+<div class="source"><pre><foo>
<xyz printme="true">
<abc printme="true"/>
@@ -412,7 +411,7 @@
<foo printme="true"/>
-</foo></source>
+</foo></pre></div>
<p>As one can see, the first element will be printed, since it has a <em>printme</em>
attribute, which bears the value <code>true</code>.</p>
@@ -426,10 +425,10 @@
<p>Running the example yields the following output:</p>
-<div class="source">Element <xyz> asked to be printed.
+<div class="source"><pre>Element <xyz> asked to be printed.
Element <abc> asked to be printed.
ERROR in ch.qos.logback.core.joran.spi.ExecutionContext at 1c5c1 - no applicable action \
-for <xyz>, current pattern is [/foo/xyz]</div>
+for <xyz>, current pattern is [/foo/xyz]</pre></div>
<p>The last line was printed because of a call to <code>StatusPrinter</code> at the end
of the main class.</p>
Modified: logback/trunk/logback-site/src/site/xdocTemplates/shortIntro.xml
==============================================================================
--- logback/trunk/logback-site/src/site/xdocTemplates/shortIntro.xml (original)
+++ logback/trunk/logback-site/src/site/xdocTemplates/shortIntro.xml Mon Oct 23 11:40:01 2006
@@ -97,7 +97,7 @@
</p>
<em>Example 1.1: Basic template for logging (examples/chapter1/HelloWorld1.java)</em>
-<div class="source">package chapter1;
+<div class="source"><pre>package chapter1;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -110,7 +110,7 @@
logger.debug("Hello world.");
}
-}</div>
+}</pre></div>
<p>
The <code>HelloWorld</code> class is defined in the
@@ -147,7 +147,7 @@
Once you're in the <em>examples/classes</em> directory of the logback distribution, you can run this class with the command:
</p>
- <div class="source">java chapter1.HelloWorld1</div>
+ <div class="source"><pre>java chapter1.HelloWorld1</pre></div>
<p>
Suprisingly enough, launching the <code>HelloWorld1</code>
@@ -167,7 +167,7 @@
</p>
<em>Example 1.2: Printing Logger Status (examples/chapter1/HelloWorld2.java)</em>
-<div class="source">package chapter1;
+<div class="source"><pre>package chapter1;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -180,14 +180,14 @@
logger.debug("Hello world.");
<b>LoggerStatusPrinter.printStatusInDefaultContext();</b>
}
-}</div>
+}</pre></div>
<p>Running the <code>HelloWorld2</code> application will produce
the following output:</p>
-<div class="source">ERROR in Logger[chapter1.HelloWorld2] - No appenders present in \
-context [default] for logger [chapter1.HelloWorld2].</div>
+<div class="source"><pre>ERROR in Logger[chapter1.HelloWorld2] - No appenders present in \
+context [default] for logger [chapter1.HelloWorld2].</pre></div>
<!-- ========= CEKI: STOPPED HERE =================== -->
@@ -207,7 +207,7 @@
<code>BasicConfigurator</code> class, like in the following code snippet.
</p>
<em>Example 1.3: Configuring before logging (examples/chapter1/HelloWorld3.java)</em>
- <div class="source">package chapter1;
+ <div class="source"><pre>package chapter1;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -224,7 +224,7 @@
LoggerStatusPrinter.printStatusInDefaultContext();
}
-}</div>
+}</pre></div>
<p>
Let's run the <code>HelloWorld3</code>
@@ -233,7 +233,7 @@
The logging request will then be propagated to the
<code>Appender</code> and the console will output the following:
</p>
-<div class="source">0 [main] DEBUG chapter1.HelloWorld3 - Hello world.</div>
+<div class="source"><pre>0 [main] DEBUG chapter1.HelloWorld3 - Hello world.</pre></div>
<p>
This example is rather simple. However, actual logging in a larger
@@ -317,7 +317,7 @@
It is exceptional in that it always exists. Like every
logger, it can be retrieved by its name, like this:
</p>
- <div class="source">Logger rootLogger = LoggerFactory.getLogger(LoggerContext.<em>ROOT_NAME</em>);</div>
+ <div class="source"><pre>Logger rootLogger = LoggerFactory.getLogger(LoggerContext.<em>ROOT_NAME</em>);</pre></div>
<p>
All other loggers are also retrieved with the class static
@@ -326,7 +326,7 @@
methods in the <code>Logger</code> interface are listed below.
</p>
- <div class="source">package org.slf4j;
+ <div class="source"><pre>package org.slf4j;
public interface Logger {
// Printing methods:
@@ -335,7 +335,7 @@
public void warn(String message);
public void error(String message);
public void fatal(String message);
-}</div>
+}</pre></div>
<p>
Loggers may be assigned levels. The set of possible levels,
@@ -646,7 +646,7 @@
<p>Here is an example of the basic selection rule.</p>
- <div class="source">// get a logger instance named "com.foo", with an <span class="blue">INFO</span> level.
+ <div class="source"><pre>// get a logger instance named "com.foo", with an <span class="blue">INFO</span> level.
Logger logger = LoggerFactory.getLogger("com.foo");
//set its Level to <span class="blue">INFO</span>
logger.setLevel(Level.INFO);
@@ -665,7 +665,7 @@
barlogger.<span class="green">info</span>("Located nearest gas station.");
// This request is disabled, because<span class="green">DEBUG</span> < <span class="blue">INFO</span>.
-barlogger.<span class="green">debug</span>("Exiting gas station search");</div>
+barlogger.<span class="green">debug</span>("Exiting gas station search");</pre></div>
<h3>Retrieving Loggers</h3>
<p>
@@ -675,8 +675,8 @@
</p>
<p>For example, in</p>
- <div class="source">Logger x = LoggerFactory.getLogger("wombat");
-Logger y = LoggerFactory.getLogger("wombat");</div>
+ <div class="source"><pre>Logger x = LoggerFactory.getLogger("wombat");
+Logger y = LoggerFactory.getLogger("wombat");</pre></div>
<p>
<code>x</code> and <code>y</code> refer to
@@ -862,7 +862,7 @@
"%-4relative [%thread] %-5level %class - %msg%n" will output something akin to:
</p>
- <div class="source">176 [main] DEBUG chapter1.HelloWorld3 - Hello world.</div>
+ <div class="source"><pre>176 [main] DEBUG chapter1.HelloWorld3 - Hello world.</pre></div>
<p>
The first field is the number of milliseconds elapsed since
@@ -885,7 +885,7 @@
For some Logger <code>logger</code>, writing,
</p>
- <div class="source">logger.debug("Entry number: " + i + " is " + String.valueOf(entry[i]));</div>
+ <div class="source"><pre>logger.debug("Entry number: " + i + " is " + String.valueOf(entry[i]));</pre></div>
<p>
incurs the cost of constructing the message parameter, that
@@ -900,9 +900,9 @@
example.
</p>
- <div class="source">if(logger.isDebugEnabled()) {
+ <div class="source"><pre>if(logger.isDebugEnabled()) {
logger.debug("Entry number: " + i + " is " + String.valueOf(entry[i]));
-}</div>
+}</pre></div>
<p>
@@ -925,8 +925,8 @@
</p>
- <div class="source">Object entry = new SomeObject();
-logger.debug("The entry is {}.", entry);</div>
+ <div class="source"><pre>Object entry = new SomeObject();
+logger.debug("The entry is {}.", entry);</pre></div>
<p>
After evaluting whether to log or not, and only if the
@@ -946,8 +946,8 @@
factor of at least 30.
</p>
- <div class="source">logger.debug("The new entry is "+entry+".");
-logger.debug("The new entry is {}.", entry);</div>
+ <div class="source"><pre>logger.debug("The new entry is "+entry+".");
+logger.debug("The new entry is {}.", entry);</pre></div>
<p>
@@ -955,7 +955,7 @@
can write:
</p>
- <div class="source">logger.debug("The new entry is {}. It replaces {}.", entry, oldEntry);</div>
+ <div class="source"><pre>logger.debug("The new entry is {}. It replaces {}.", entry, oldEntry);</pre></div>
<p>
If three or more arguments need to be passed, an <code>Object[]</code>
@@ -963,8 +963,8 @@
</p>
- <div class="source">Object[] paramArray = {newVal, below, above};
-logger.debug("Value {} was inserted between {} and {}.", paramArray);</div>
+ <div class="source"><pre>Object[] paramArray = {newVal, below, above};
+logger.debug("Value {} was inserted between {} and {}.", paramArray);</pre></div>
<h3>Configuration</h3>
@@ -992,7 +992,7 @@
imaginary application MyApp that uses logback.
</p>
<em>Example 1.4: Basic configuration (examples/chapter1/MyApp.java)</em>
-<div class="source">package chapter1;
+<div class="source"><pre>package chapter1;
// Import SLF4J classes.
import org.slf4j.LoggerFactory;
@@ -1014,20 +1014,20 @@
bar.doIt();
logger.info("Exiting application.");
}
-}</div>
+}</pre></div>
<p>
This class defines a logger instance variable
with the name MyApp. It then uses the Bar class, defined as shown below:
</p>
<em>Example 1.4: Basic configuration (examples/chapter1/Bar.java)</em>
-<div class="source">class Bar {
+<div class="source"><pre>class Bar {
Logger logger = LoggerFactory.getLogger(Bar.class);
public void doIt() {
logger.debug("doing my job");
}
-}</div>
+}</pre></div>
<p>
The invocation of the BasicConfigurator create, as we have seen,
a simple yet sufficient logback setup. By default,
@@ -1038,14 +1038,14 @@
<p>
The output of MyApp is:
</p>
-<div class="source">0 [main] INFO ch.qos.logback.classic.examples.MyApp - Entering application.
+<div class="source"><pre>0 [main] INFO ch.qos.logback.classic.examples.MyApp - Entering application.
0 [main] DEBUG ch.qos.logback.classic.examples.Bar - doing my job
-0 [main] INFO ch.qos.logback.classic.examples.MyApp - Exiting application.</div>
+0 [main] INFO ch.qos.logback.classic.examples.MyApp - Exiting application.</pre></div>
<p>Let's configure logback to do exactly the same output, this time
with an XML configuration file.</p>
<em>Example 1.4: Basic configuration (examples/chapter1/sample-config-1.xml)</em>
-<div class="source"><?xml version="1.0" encoding="UTF-8" ?>
+<div class="source"><pre><?xml version="1.0" encoding="UTF-8" ?>
<configuration>
@@ -1061,7 +1061,7 @@
<level value="debug" />
<appender-ref ref="STDOUT" />
</root>
-</configuration></div>
+</configuration></pre></div>
<p>We first created an <code>Appender</code>, named <em>STDOUT</em> that is of <code>ConsoleAppender</code> tye. Its layout
is managed by a PatternLayout, that uses the value of the "pattern" parameter to generate
@@ -1072,13 +1072,13 @@
<p>To run this examle, use this command:</p>
-<div class="source">java chapter1.MyApp sample-config-1.xml</div>
+<div class="source"><pre>java chapter1.MyApp sample-config-1.xml</pre></div>
<p>The console output will be exactly the same as before. However, this time, we didn't need
to import and call the BasicConfigurator class, as you can see in the following code section:
</p>
<em>Example 1.5: Logback configuration from file (examples/chapter1/MyAppWithConfigFile.java)</em>
-<div class="source">package chapter1;
+<div class="source"><pre>package chapter1;
//Import SLF4J classes.
import org.slf4j.Logger;
@@ -1105,7 +1105,7 @@
StatusPrinter.print(lc.getStatusManager());
}
-}</div>
+}</pre></div>
<p>
We used the JoranConfigurator class to parse the configuration file we just created.
Joran is a XML interpreter, similar to the commons-digester API, but offering several
@@ -1119,7 +1119,7 @@
<p>Logging to the console is a rather simple example. Let's now configure logback
so that it logs to the console, but also to a custom file.</p>
<em>Example 1.5: Logback configuration from file (examples/chapter1/sample-config-2.xml)</em>
-<div class="source"><?xml version="1.0" encoding="UTF-8" ?>
+<div class="source"><pre><?xml version="1.0" encoding="UTF-8" ?>
<configuration>
@@ -1146,7 +1146,7 @@
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
-</configuration></div>
+</configuration></pre></div>
<p>Now, all the logging statements are directed to the console and to a file named <em>sample-log.txt</em>.
As you can see, the configuration needed to add an Appender is rather small. The param element, in either
@@ -1158,7 +1158,7 @@
This is done by adding the following xml snippet to the configuration file, right before
the <code><root></code> element.</p>
<em>Example 1.5: Logback configuration from file (examples/chapter1/sample-config-3.xml)</em>
-<div class="source"><?xml version="1.0" encoding="UTF-8" ?>
+<div class="source"><pre><?xml version="1.0" encoding="UTF-8" ?>
<configuration>
@@ -1190,12 +1190,12 @@
<appender-ref ref="FILE" />
</root>
</configuration>
-</div>
+</pre></div>
<p>This done, the output is modified to show only statements of level INFO and higher.</p>
-<div class="source">0 [main] INFO chapter1.MyAppWithConfigFile - Entering application.
-0 [main] INFO chapter1.MyAppWithConfigFile - Exiting application.</div>
+<div class="source"><pre>0 [main] INFO chapter1.MyAppWithConfigFile - Entering application.
+0 [main] INFO chapter1.MyAppWithConfigFile - Exiting application.</pre></div>
<p>Note that to obtain these different logging behaviors we did not need to recompile code.
We could just as easily have logged to a UNIX Syslog daemon, redirected all chapter1 output
More information about the logback-dev
mailing list