[LOGBack-dev] svn commit: r416 - in logback/classic/trunk: examples/src/chapter1 src/site/xdocTemplates

noreply.seb at qos.ch noreply.seb at qos.ch
Tue Aug 8 15:59:12 CEST 2006


Author: seb
Date: Tue Aug  8 15:59:11 2006
New Revision: 416

Added:
   logback/classic/trunk/examples/src/chapter1/Bar.java
   logback/classic/trunk/examples/src/chapter1/HelloWorld1.java
   logback/classic/trunk/examples/src/chapter1/HelloWorld2.java
   logback/classic/trunk/examples/src/chapter1/HelloWorld3.java
   logback/classic/trunk/examples/src/chapter1/MyApp.java
   logback/classic/trunk/examples/src/chapter1/MyAppWithConfigFile.java
   logback/classic/trunk/examples/src/chapter1/sample-config-1.xml
   logback/classic/trunk/examples/src/chapter1/sample-config-2.xml
   logback/classic/trunk/examples/src/chapter1/sample-config-3.xml
Modified:
   logback/classic/trunk/src/site/xdocTemplates/shortIntro.xml
Log:
modified examples, updated documentation and css styles accordingly

Added: logback/classic/trunk/examples/src/chapter1/Bar.java
==============================================================================
--- (empty file)
+++ logback/classic/trunk/examples/src/chapter1/Bar.java	Tue Aug  8 15:59:11 2006
@@ -0,0 +1,11 @@
+package chapter1;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+class Bar {
+	Logger logger = LoggerFactory.getLogger(Bar.class);
+	public void doIt() {
+		logger.debug("doing my job");
+	}
+}
\ No newline at end of file

Added: logback/classic/trunk/examples/src/chapter1/HelloWorld1.java
==============================================================================
--- (empty file)
+++ logback/classic/trunk/examples/src/chapter1/HelloWorld1.java	Tue Aug  8 15:59:11 2006
@@ -0,0 +1,13 @@
+package chapter1;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class HelloWorld1 {
+
+	public static void main(String[] args) {
+
+    Logger logger = LoggerFactory.getLogger(HelloWorld1.class);
+		logger.debug("Hello world.");
+	}
+}

Added: logback/classic/trunk/examples/src/chapter1/HelloWorld2.java
==============================================================================
--- (empty file)
+++ logback/classic/trunk/examples/src/chapter1/HelloWorld2.java	Tue Aug  8 15:59:11 2006
@@ -0,0 +1,15 @@
+package chapter1;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import ch.qos.logback.classic.util.LoggerStatusPrinter;
+
+public class HelloWorld2 {
+
+	public static void main(String[] args) {
+    Logger logger = LoggerFactory.getLogger(HelloWorld2.class);
+		logger.debug("Hello world.");
+		LoggerStatusPrinter.printStatusInDefaultContext();
+	}
+}

Added: logback/classic/trunk/examples/src/chapter1/HelloWorld3.java
==============================================================================
--- (empty file)
+++ logback/classic/trunk/examples/src/chapter1/HelloWorld3.java	Tue Aug  8 15:59:11 2006
@@ -0,0 +1,18 @@
+package chapter1;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import ch.qos.logback.BasicConfigurator;
+import ch.qos.logback.classic.util.LoggerStatusPrinter;
+
+public class HelloWorld3 {
+
+  public static void main(String[] args) {
+    Logger logger = LoggerFactory.getLogger(HelloWorld3.class);
+
+		BasicConfigurator.configureDefaultContext();
+		logger.debug("Hello world.");
+		LoggerStatusPrinter.printStatusInDefaultContext();
+	}
+}

Added: logback/classic/trunk/examples/src/chapter1/MyApp.java
==============================================================================
--- (empty file)
+++ logback/classic/trunk/examples/src/chapter1/MyApp.java	Tue Aug  8 15:59:11 2006
@@ -0,0 +1,22 @@
+package chapter1;
+
+// Import SLF4J classes.
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import ch.qos.logback.BasicConfigurator;
+
+public class MyApp {
+
+	public static void main(String[] args) {
+		// Set up a simple configuration that logs on the console.
+		BasicConfigurator.configureDefaultContext();
+
+		Logger logger = LoggerFactory.getLogger(MyApp.class);
+		
+		logger.info("Entering application.");
+		Bar bar = new Bar();
+		bar.doIt();
+		logger.info("Exiting application.");
+	}
+}

Added: logback/classic/trunk/examples/src/chapter1/MyAppWithConfigFile.java
==============================================================================
--- (empty file)
+++ logback/classic/trunk/examples/src/chapter1/MyAppWithConfigFile.java	Tue Aug  8 15:59:11 2006
@@ -0,0 +1,26 @@
+package chapter1;
+
+//Import SLF4J classes.
+import org.slf4j.LoggerFactory;
+
+import ch.qos.logback.classic.Logger;
+import ch.qos.logback.classic.joran.JoranConfigurator;
+import ch.qos.logback.core.util.StatusPrinter;
+
+public class MyAppWithConfigFile {
+	
+	public static void main(String[] args) {
+		Logger logger = (Logger) LoggerFactory.getLogger(MyAppWithConfigFile.class);
+		
+		JoranConfigurator configurator = new JoranConfigurator();
+		configurator.setContext(logger.getLoggerContext());
+		configurator.doConfigure(args[0]);
+
+		logger.info("Entering application.");
+		Bar bar = new Bar();
+		bar.doIt();
+		logger.info("Exiting application.");
+	
+		StatusPrinter.print(logger.getLoggerContext().getStatusManager());
+	}
+}

Added: logback/classic/trunk/examples/src/chapter1/sample-config-1.xml
==============================================================================
--- (empty file)
+++ logback/classic/trunk/examples/src/chapter1/sample-config-1.xml	Tue Aug  8 15:59:11 2006
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<configuration>
+
+	<appender name="STDOUT"
+		class="ch.qos.logback.core.ConsoleAppender">
+		<layout class="ch.qos.logback.classic.PatternLayout">
+			<param name="pattern"
+				value="%-4relative [%thread] %-5level %class - %msg%n" />
+		</layout>
+	</appender>
+
+	<root>
+		<level value="debug" />
+		<appender-ref ref="STDOUT" />
+	</root>
+</configuration>

Added: logback/classic/trunk/examples/src/chapter1/sample-config-2.xml
==============================================================================
--- (empty file)
+++ logback/classic/trunk/examples/src/chapter1/sample-config-2.xml	Tue Aug  8 15:59:11 2006
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<configuration>
+
+	<appender name="STDOUT"
+		class="ch.qos.logback.core.ConsoleAppender">
+		<layout class="ch.qos.logback.classic.PatternLayout">
+			<param name="pattern"
+				value="%-4relative [%thread] %-5level %class - %msg%n" />
+		</layout>
+	</appender>
+
+	<appender name="FILE"
+		class="ch.qos.logback.core.FileAppender">
+		<layout class="ch.qos.logback.classic.PatternLayout">
+			<param name="pattern"
+				value="%-4relative [%thread] %-5level %class - %msg%n" />
+		</layout>
+		<param name="File"
+			value="sample-log.txt" />
+	</appender>
+
+	<root>
+		<level value="debug" />
+		<appender-ref ref="STDOUT" />
+		<appender-ref ref="FILE" />
+	</root>
+</configuration>

Added: logback/classic/trunk/examples/src/chapter1/sample-config-3.xml
==============================================================================
--- (empty file)
+++ logback/classic/trunk/examples/src/chapter1/sample-config-3.xml	Tue Aug  8 15:59:11 2006
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<configuration>
+
+	<appender name="STDOUT"
+		class="ch.qos.logback.core.ConsoleAppender">
+		<layout class="ch.qos.logback.classic.PatternLayout">
+			<param name="pattern"
+				value="%-4relative [%thread] %-5level %class - %msg%n" />
+		</layout>
+	</appender>
+
+	<appender name="FILE"
+		class="ch.qos.logback.core.FileAppender">
+		<layout class="ch.qos.logback.classic.PatternLayout">
+			<param name="pattern"
+				value="%-4relative [%thread] %-5level %class - %msg%n" />
+		</layout>
+		<param name="File"
+			value="sample-log.txt" />
+	</appender>
+
+	<logger name="chapter1">
+		<level value="info" />
+	</logger>
+
+	<root>
+		<level value="debug" />
+		<appender-ref ref="STDOUT" />
+		<appender-ref ref="FILE" />
+	</root>
+</configuration>

Modified: logback/classic/trunk/src/site/xdocTemplates/shortIntro.xml
==============================================================================
--- logback/classic/trunk/src/site/xdocTemplates/shortIntro.xml	(original)
+++ logback/classic/trunk/src/site/xdocTemplates/shortIntro.xml	Tue Aug  8 15:59:11 2006
@@ -83,6 +83,10 @@
     	HTPP-access log functionality. The Access module will be covered
     	in a separate document.
     </p>
+    <p>
+    	In this document, we will use the word logback to refer to the
+    	logback classic module.
+    </p>
 
     <h2>First Baby Step</h2>
 
@@ -94,7 +98,7 @@
     	to your classpath, you can begin experimenting with logback.
     </p>
 
-<div class="source"><em>Example 1.1: Basic template for logging (examples/HelloWorld1.java)</em>
+<div class="source"><em>Example 1.1: Basic template for logging (examples/chapter1/HelloWorld1.java)</em>
 package chapter1;
 
 import org.slf4j.Logger;
@@ -108,8 +112,7 @@
     logger.debug("Hello world.");
 
   }
-}
-</div>
+}</div>
 
 		<p>
 			The <code>HelloWorld</code> class is defined in the
@@ -165,7 +168,7 @@
 			class.
 		</p>
 
-<div class="source"><em>Example 1.2: Printing Logger Status (examples/HelloWorld2.java)</em>
+<div class="source"><em>Example 1.2: Printing Logger Status (examples/chapter1/HelloWorld2.java)</em>
 package chapter1;
 
 import org.slf4j.Logger;
@@ -179,8 +182,7 @@
     logger.debug("Hello world.");
     <b>LoggerStatusPrinter.printStatusInDefaultContext();</b>
   }
-}
-</div>
+}</div>
 
 
    <p>Running the <code>HelloWorld2</code> application will produce
@@ -202,12 +204,12 @@
   </p>
 
   <p>
-  	Configuring logback classic can be done a different ways. The
+  	Configuring logback can be done a different ways. The
   	simplest but less flexible way is by calling the
   	<code>BasicConfigurator</code> class, like in the following code snippet.
   </p>
-  <div class="source"><em>Example 1.3: Configuring before logging (examples/HelloWorld3.java)</em>
-package ch.qos.logback.classic.examples;
+  <div class="source"><em>Example 1.3: Configuring before logging (examples/chapter1/HelloWorld3.java)</em>
+package chapter1;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -224,8 +226,7 @@
     LoggerStatusPrinter.printStatusInDefaultContext();
 
   }
-}
-</div>
+}</div>
 
 		<p>
 			Let's run the <code>HelloWorld3</code>
@@ -234,9 +235,7 @@
 			The logging request will then be propagated to the
 			Appender and the console will output the following:
 		</p>
-<div class="source">
-0    [main] DEBUG ch.qos.logback.classic.examples.HelloWorld3 - Hello world.
-</div>
+<div class="source">0    [main] DEBUG chapter1.HelloWorld3 - Hello world.</div>
 
 		<p>
 			This example is very simple. However, actual logging in a larger
@@ -253,7 +252,7 @@
 		</p>
 
 		<ol>
-			<li>Configure the logback classic environment. You can do it using several 
+			<li>Configure the logback environment. You can do it using several 
 			sophisticated ways. The BasicConfigurator is the simplest but also least flexible.</li>
 			<li>In every class where you wish to perform logging, retrieve a Logger 
 			instance by invoking the LoggerFactory and passing the current class as the parameter.</li>
@@ -266,7 +265,7 @@
 			<h2>Logger, Appenders and Layouts</h2>
 		</div>
 		<p>
-			Logback classic has three main components: Loggers,
+			Logback has three main components: Loggers,
 			Appenders and Layouts. These three types of components work
 			together to enable developers to log messages according to
 			message type and level, and to control at runtime how these
@@ -278,7 +277,7 @@
 			of logback.
 		</p>
 
-    <h3>Logger hierarchy</h3>
+    <h3>Logger context</h3>
 
 		<p>
 			The first and foremost advantage of any logging API over
@@ -287,14 +286,14 @@
 			unhindered. This capability assumes that the logging space,
 			that is, the space of all possible logging statements, is
 			categorized according to some developer-chosen criteria.
-			Loggers are named entities.
 		</p>
+			
 		<p>
-			Logger names are case-sensitive and they follow the
-			hierarchical naming rule:
+			In logback, Loggers are named entities. Their names are case-sensitive and they follow the
+			contextual naming rule:
 		</p>
 		<div class="definition">
-			<div class="deftitle">Named Hierarchy</div>
+			<div class="deftitle">Named Context</div>
 			<p>
 				A logger is said to be an ancestor of another logger if
 				its name followed by a dot is a prefix of the descendant
@@ -313,7 +312,7 @@
 			This naming scheme should be familiar to most developers.
 		</p>
 		<p>
-			The root logger resides at the top of the logger hierarchy.
+			The root logger resides at the top of the logger context.
 			It is exceptional in a way that is always exists. Like every
 			logger, it can be retrieved by its name, like this:
 		</p>
@@ -326,23 +325,21 @@
 			methods in the Logger interface are listed below.
 		</p>
 
-		<div class="source">package org.slf4j; public interface Logger {
+		<div class="source">package org.slf4j; 
+public interface Logger {
 
-// Creation and retrieval method: 
-public static LoggergetLogger(String name);
-
-// Printing methods: 
-public void debug(Object message);
-public void info(Object message); 
-public void warn(Object message); 
-public void error(Object message); 
-public void fatal(Object message); 
+  // Printing methods: 
+  public void debug(Object message);
+  public void info(Object message); 
+  public void warn(Object message); 
+  public void error(Object message); 
+  public void fatal(Object message); 
 }</div>
 
 		<p>
 			Loggers may be assigned levels. The set of possible levels,
 			that is DEBUG, INFO, WARN and ERROR are defined in the
-			ch.qos.logback.classic.Level class. The level class cannot
+			<em>ch.qos.logback.classic.Level</em> class. The level class cannot
 			be sub-classed as a much better approach exist in the form
 			of Marker objects.
 		</p>
@@ -357,8 +354,8 @@
 			<div class="deftitle">Level Inheritance</div>
 			<p>
 				The inherited level for a given logger <em>L</em>, 
-				is equal to the first non-null level in the logger hierarchy, starting at
-				<em>L</em> and proceeding upwards in the hierarchy towards the root logger.
+				is equal to the first non-null level in the logger context, starting at
+				<em>L</em> and proceeding upwards in the context towards the root logger.
 			</p>
 		</div>
 		<p>
@@ -371,7 +368,7 @@
 			rule.
 		</p>
 
-		<table class="exampleTable">
+		<table>
 			<tr>
 				<th>
 					Logger
@@ -392,33 +389,33 @@
 			</tr>
 			<tr>
 				<td>root</td>
-				<td>Proot</td>
-				<td>Proot</td>
+				<td>L<sub>root</sub></td>
+				<td>L<sub>root</sub></td>
 			</tr>
 			<tr>
 				<td>X</td>
 				<td>none</td>
-				<td>Proot</td>
+				<td>L<sub>root</sub></td>
 			</tr>
 
 			<tr>
 				<td>X.Y</td>
 				<td>none</td>
-				<td>Proot</td>
+				<td>L<sub>root</sub></td>
 			</tr>
 			<tr>
 				<td>X.Y.Z</td>
 				<td>none</td>
-				<td>Proot</td>
+				<td>L<sub>root</sub></td>
 			</tr>
 		</table>
 		<p>
 			In example 1 above, only the root logger is assigned a
 			level.
 		</p>
-		This level value, <code>Proot</code>, is inherited by the other loggers
+		This level value, <code>L<sub>root</sub></code>, is inherited by the other loggers
 		<code>X</code>, <code>X.Y</code> and <code>X.Y.Z</code>
-		<table class="exampleTable">
+		<table>
 			<tr>
 				<th>
 					Logger
@@ -439,24 +436,24 @@
 			</tr>
 			<tr align="left">
 				<td>root</td>
-				<td>Proot</td>
-				<td>Proot</td>
+				<td>L<sub>root</sub></td>
+				<td>L<sub>root</sub></td>
 			</tr>
 			<tr align="left">
 				<td>X</td>
-				<td>Px</td>
-				<td>Px</td>
+				<td>P<sub>x</sub></td>
+				<td>P<sub>x</sub></td>
 			</tr>
 
 			<tr align="left">
 				<td>X.Y</td>
-				<td>Pxy</td>
-				<td>Pxy</td>
+				<td>P<sub>xy</sub></td>
+				<td>P<sub>xy</sub></td>
 			</tr>
 			<tr align="left">
 				<td>X.Y.Z</td>
-				<td>Pxyz</td>
-				<td>Pxyz</td>
+				<td>P<sub>xyz</sub></td>
+				<td>P<sub>xyz</sub></td>
 			</tr>
 		</table>
 
@@ -465,7 +462,7 @@
 			There is no need for level inheritence.
 		</p>
 
-		<table class="exampleTable">
+		<table>
 			<tr>
 				<th>
 					Logger
@@ -485,34 +482,34 @@
 			</tr>
 			<tr align="left">
 				<td>root</td>
-				<td>Proot</td>
-				<td>Proot</td>
+				<td>L<sub>root</sub></td>
+				<td>L<sub>root</sub></td>
 			</tr>
 
 			<tr align="left">
 				<td>X</td>
-				<td>Px</td>
-				<td>Px</td>
+				<td>P<sub>x</sub></td>
+				<td>P<sub>x</sub></td>
 			</tr>
 			<tr align="left">
 				<td>X.Y</td>
 				<td>none</td>
-				<td>Px</td>
+				<td>P<sub>x</sub></td>
 			</tr>
 			<tr align="left">
 				<td>X.Y.Z</td>
-				<td>Pxyz</td>
-				<td>Pxyz</td>
+				<td>P<sub>xyz</sub></td>
+				<td>P<sub>xyz</sub></td>
 			</tr>
 		</table>
 		<p>
 			In example 3, the loggers <code>root</code>, <code>X</code>
-			and <code>X.Y.Z</code> are assigned the levels <code>Proot</code>,
-			<code>Px</code> and <code>Pxyz</code>
+			and <code>X.Y.Z</code> are assigned the levels <code>L<sub>root</sub></code>,
+			<code>P<sub>x</sub></code> and <code>P<sub>xyz</sub></code>
 			respectively. The logger <code>X.Y</code>
 			inherits its level value from its parent <code>X</code>.
 		</p>
-		<table class="exampleTable">
+		<table>
 
 			<tr>
 				<th>
@@ -533,45 +530,36 @@
 			</tr>
 			<tr align="left">
 				<td>root</td>
-				<td>Proot</td>
-				<td>Proot</td>
+				<td>L<sub>root</sub></td>
+				<td>L<sub>root</sub></td>
 			</tr>
 
 			<tr align="left">
 				<td>X</td>
-				<td>Px</td>
-				<td>Px</td>
+				<td>P<sub>x</sub></td>
+				<td>P<sub>x</sub></td>
 			</tr>
 			<tr align="left">
 				<td>X.Y</td>
 				<td>none</td>
-				<td>Px</td>
+				<td>P<sub>x</sub></td>
 			</tr>
 			<tr align="left">
 				<td>X.Y.Z</td>
 				<td>none</td>
-				<td>Px</td>
+				<td>P<sub>x</sub></td>
 			</tr>
 		</table>
 
 		<p>
 			In example 4, the loggers <code>root</code> and <code>X</code>
-			and are assigned the levels <code>Proot</code> and
-			<code>Px</code> respectively. The loggers <code>X.Y</code> and
+			and are assigned the levels <code>L<sub>root</sub></code> and
+			<code>P<sub>x</sub></code> respectively. The loggers <code>X.Y</code> and
 			<code>X.Y.Z</code> inherits their level value from their nearest
 			parent <code>X</code> having an assigned level.
 		</p>
 
-		<p>
-			In a more graphic way, here is how you the logger hierarchy
-			works:
-		</p>
-		
-		<img src="images/loggerlevel.jpg" alt="loggerLevelVsMessageLevel" />
-
     <h3>Printing methods</h3>
-
-
 		<p>
 			By definition, the printing method determines the level of a
 			logging request. For example, if <code>L</code>
@@ -583,7 +571,7 @@
 			if its level is higher than or equal to the level of its
 			logger. Otherwise, the request is said to be
 			<em>disabled</em>. A logger without an assigned level will inherit one from
-			the hierarchy. This rule is summarized below.
+			the context. This rule is summarized below.
 		</p>
 		<div class="definition">
 			<div class="deftitle">Basic Selection Rule</div>
@@ -598,10 +586,55 @@
 		</div>
 
 		<p>
-			This rule is at the heart of logback classic. It assumes
+			This rule is at the heart of logback. It assumes
 			that levels are ordered. For the standard levels, we have
 			<code>DEBUG &lt; INFO &lt; WARN &lt; ERROR</code>.
 		</p>
+				
+		<p>
+			In a more graphic way, here is how the selection rule works: in the following
+			table, the horizontal header shows the level of the logging request, while the
+			vertical header shows the level of the logger.
+		</p>
+		
+		<table>
+			<tr>
+				<td></td>
+				<th>DEBUG</th>
+				<th>INFO</th>
+				<th>WARN</th>
+				<th>ERROR</th>				
+			</tr>
+			<tr>
+				<th>DEBUG</th>
+				<td><span class="greenBold">YES</span></td>
+				<td><span class="greenBold">YES</span></td>
+				<td><span class="greenBold">YES</span></td>
+				<td><span class="greenBold">YES</span></td>
+			</tr>
+			<tr>
+				<th>INFO</th>
+				<td><span class="redBold">NO</span></td>
+				<td><span class="greenBold">YES</span></td>
+				<td><span class="greenBold">YES</span></td>
+				<td><span class="greenBold">YES</span></td>
+			</tr>
+			<tr>
+				<th>WARN</th>
+				<td><span class="redBold">NO</span></td>
+				<td><span class="redBold">NO</span></td>
+				<td><span class="greenBold">YES</span></td>
+				<td><span class="greenBold">YES</span></td>
+			</tr>
+			<tr>
+				<th>ERROR</th>
+				<td><span class="redBold">NO</span></td>
+				<td><span class="redBold">NO</span></td>
+				<td><span class="redBold">NO</span></td>
+				<td><span class="greenBold">YES</span></td>
+			</tr>		
+		</table>
+		
 		<p>Here is an example of this rule.</p>
 
 		<div class="source">// get a logger instance named "com.foo", with an <span class="blue">INFO</span>level. 
@@ -621,8 +654,7 @@
 barlogger.<span class="green">info</span>("Located nearest gas station.");
 
 // This request is disabled, because<span class="green">DEBUG</span> &lt; <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");</div>
 
 		<p>
 			Calling the <code>getLogger</code>
@@ -644,7 +676,7 @@
 			retrieve the same instance somewhere else in the code
 			without passing around references. In fundamental
 			contradiction to biological parenthood, where parents always
-			preceed their children, logback classic loggers can be
+			preceed their children, logback loggers can be
 			created and configured in any order. In particular, a
 			"parent" logger will find and link to its descendants even
 			if it is instantiated after them.
@@ -691,8 +723,8 @@
 			The addAppender method adds an appender to a given logger.
 			Each enabled logging request for a given logger will be
 			forwarded to all the appenders in that logger as well as the
-			appenders higher in the hierarchy. In other words, appenders
-			are inherited additively from the logger hierarchy. For
+			appenders higher in the context. In other words, appenders
+			are inherited additively from the logger context. For
 			example, if a console appender is added to the root logger,
 			then all enabled logging requests will at least print on the
 			console. If in addition a file appender is added to a
@@ -941,9 +973,9 @@
 		</p>
 		<p>
 			Let us give a taste of how this is done with the help of an 
-			imaginary application MyApp that uses logback classic. 
+			imaginary application MyApp that uses logback. 
 		</p>
-<div class="source"><em>Example 1.4: Basic configuration (examples/MyApp.java)</em>
+<div class="source"><em>Example 1.4: Basic configuration (examples/chapter1/MyApp.java)</em>
 package chapter1;
 
 // Import SLF4J classes.
@@ -966,25 +998,22 @@
     bar.doIt();
     logger.info("Exiting application.");
   }
-}
-</div>
+}</div>
 		<p>
 			This class begins by defining a static logger instance variable 
 			with the name MyApp. It then uses the Bar class, defined as shown below:
 		</p>
-<div class="source">
-class Bar {
+<div class="source">class Bar {
 
   Logger logger = LoggerFactory.getLogger(Bar.class);	
 	
   public void doIt() {
     logger.debug("doing my job");
   }
-}
-</div>
+}</div>
 		<p>
 			The invocation of the BasicConfigurator create, as we have seen, 
-			a simple yet sufficient logback classic setup. By default, 
+			a simple yet sufficient logback setup. By default, 
 			the root Logger is assigned to Level.DEBUG.
 		</p>
 		<p>The BasicConfigurator has to be called only once. Any other class that wishes to
@@ -992,35 +1021,30 @@
 		<p>
 			The output of MyApp is:
 		</p>
-<div class="source"> 
-0    [main] INFO  ch.qos.logback.classic.examples.MyApp - Entering application.
+<div class="source">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.</div>
 		
-	<p>Let's configure logback classic to do exactly the same output, this time 
+	<p>Let's configure logback to do exactly the same output, this time 
 	with an XML configuration file.</p>
 	
-<div class="source">
-&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
-
-&lt;logback:configuration xmlns:logback='http://logback.qos.ch/'&gt;
+<div class="source">&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
 
-	&lt;appender name="STDOUT"
-		class="ch.qos.logback.core.ConsoleAppender"&gt;
-		&lt;layout class="ch.qos.logback.classic.PatternLayout"&gt;
-			&lt;param name="pattern"
-				value="%-4relative [%thread] %-5level %class - %msg%n" /&gt;
-		&lt;/layout&gt;
-	&lt;/appender&gt;
-
-	&lt;root&gt;
-		&lt;level value="debug" /&gt;
-		&lt;appender-ref ref="STDOUT" /&gt;
-	&lt;/root&gt;
-&lt;/logback:configuration&gt;
+&lt;configuration&gt;
 
-</div>
+  &lt;appender name="STDOUT"
+    class="ch.qos.logback.core.ConsoleAppender"&gt;
+    &lt;layout class="ch.qos.logback.classic.PatternLayout"&gt;
+      &lt;param name="pattern"
+        value="%-4relative [%thread] %-5level %class - %msg%n" /&gt;
+    &lt;/layout&gt;
+  &lt;/appender&gt;
+
+  &lt;root&gt;
+    &lt;level value="debug" /&gt;
+    &lt;appender-ref ref="STDOUT" /&gt;
+  &lt;/root&gt;
+&lt;/configuration&gt;</div>
 	
 	<p>We first created an Appender, named <em>STDOUT</em> that is of ConsoleAppender tye. Its layout
 	is managed by a PatternLayout, that uses the value of the "pattern" parameter to generate 
@@ -1036,7 +1060,8 @@
 	<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>
-<div class="source">package chapter1;
+<div class="source"><em>Example 1.5: Logback configuration from file (examples/chapter1/MyAppWithConfigFile.java)</em>
+package chapter1;
 
 //Import SLF4J classes.
 import org.slf4j.LoggerFactory;
@@ -1058,8 +1083,7 @@
     bar.doIt();
     logger.info("Exiting application.");
   }
-}
-</div>	
+}</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
@@ -1067,38 +1091,37 @@
 	on the tags it finds.
 	</p>
 	
-	<p>Logging to the console is a rather simple example. Let's now configure logback classic
+	<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>
 
 <div class="source">&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
 
-&lt;logback:configuration xmlns:logback='http://logback.qos.ch/'&gt;
+&lt;configuration&gt;
 
-	&lt;appender name="STDOUT"
-		class="ch.qos.logback.core.ConsoleAppender"&gt;
-		&lt;layout class="ch.qos.logback.classic.PatternLayout"&gt;
-			&lt;param name="pattern"
-				value="%-4relative [%thread] %-5level %class - %msg%n" /&gt;
-		&lt;/layout&gt;
-	&lt;/appender&gt;
-
-	&lt;appender name="FILE"
-		class="ch.qos.logback.core.FileAppender"&gt;
-		&lt;layout class="ch.qos.logback.classic.PatternLayout"&gt;
-			&lt;param name="pattern"
-				value="%-4relative [%thread] %-5level %class - %msg%n" /&gt;
-		&lt;/layout&gt;
-		&lt;param name="File"
-			value="sample-log.txt" /&gt;
-	&lt;/appender&gt;
-
-	&lt;root&gt;
-		&lt;level value="debug" /&gt;
-		&lt;appender-ref ref="STDOUT" /&gt;
-		&lt;appender-ref ref="FILE" /&gt;
-	&lt;/root&gt;
-&lt;/logback:configuration&gt;
-</div>
+  &lt;appender name="STDOUT"
+      class="ch.qos.logback.core.ConsoleAppender"&gt;
+    &lt;layout class="ch.qos.logback.classic.PatternLayout"&gt;
+      &lt;param name="pattern"
+        value="%-4relative [%thread] %-5level %class - %msg%n" /&gt;
+    &lt;/layout&gt;
+  &lt;/appender&gt;
+
+  &lt;appender name="FILE"
+      class="ch.qos.logback.core.FileAppender"&gt;
+    &lt;layout class="ch.qos.logback.classic.PatternLayout"&gt;
+      &lt;param name="pattern"
+        value="%-4relative [%thread] %-5level %class - %msg%n" /&gt;
+    &lt;/layout&gt;
+    &lt;param name="File"
+      value="sample-log.txt" /&gt;
+  &lt;/appender&gt;
+
+  &lt;root&gt;
+    &lt;level value="debug" /&gt;
+    &lt;appender-ref ref="STDOUT" /&gt;
+    &lt;appender-ref ref="FILE" /&gt;
+  &lt;/root&gt;
+&lt;/configuration&gt;</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 very small. The param element, in either
@@ -1111,10 +1134,8 @@
 	
 	<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">0    [main] INFO  chapter1.MyAppWithConfigFile - Entering application.
+0    [main] INFO  chapter1.MyAppWithConfigFile - Exiting application.</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