[logback-dev] svn commit: r1154 - in logback/trunk: logback-examples/src/main/java/chapter1 logback-site/src/site/xdocTemplates

noreply.seb at qos.ch noreply.seb at qos.ch
Thu Jan 4 10:42:59 CET 2007


Author: seb
Date: Thu Jan  4 10:42:58 2007
New Revision: 1154

Removed:
   logback/trunk/logback-examples/src/main/java/chapter1/HelloWorld3.java
Modified:
   logback/trunk/logback-site/src/site/xdocTemplates/shortIntro.xml

Log:
updated short intro after default configuration policy
removed HelloWorld3 example

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	Thu Jan  4 10:42:58 2007
@@ -167,12 +167,15 @@
      chapter1.HelloWorld1</pre></div>
 
 		<p>
-			Suprisingly enough, launching the <code>HelloWorld1</code>
-			application will not produce <em>any</em> output. 
-			Indeed, logback does not posses a default configuration.
-			Without a valid configuration, logback will be as silent as a grave.
+			Launching the <code>HelloWorld1</code>
+			application will produce a very simple output. This it thanks
+			to logback's default configuration policy. When nothing is found to
+			configure logback explicitly, logback will configure itself with
+			a simple output to the console, as shown below.
 		</p>
 
+<div class="source"><pre>20:49:07.962 [main] DEBUG chapter1.HelloWorld1 - Hello world.</pre></div>
+
 		<p>
 			Logback can report information about its internal state
 			using a built-in status system. Important events occuring
@@ -203,13 +206,14 @@
    <p>Running the <code>HelloWorld2</code> application will produce
    the following output:</p>
 
-<div class="source"><pre>ERROR in Logger[chapter1.HelloWorld2] - No appenders present in \ 
-context [default] for logger [chapter1.HelloWorld2].</pre></div>
+<div class="source"><pre>20:49:07.962 [main] DEBUG chapter1.HelloWorld2 - Hello world.
+|-INFO in ch.qos.logback.classic.BasicConfigurator at 1c1ea29 - Setting up default configuration.</pre></div>
 
 
   <p>
-  	Logback complains that no appenders were configured for the
-  	default context. An <code>Appender</code> is a class that can be
+  	Logback explains it configured itself using its default
+  	configuration, which is a basic <code>ConsoleAppender</code>. 
+  	An <code>Appender</code> is a class that can be
   	seen as an output destination. Appenders exist for many different
   	destinations including the console, files, Syslog, Socket, JMS and
   	many more. Users can also easily create their own Appenders as
@@ -217,56 +221,19 @@
   </p>
 
   <p>
-  	Configuring logback can be done in various ways. The simplest but
-  	least flexible way is by calling the
-  	<code>BasicConfigurator</code> class, like in the following code
-  	snippet.
+  	The previous examples are rather simple. However, actual logging
+  	in a larger application would not be any different. The general
+  	pattern logging statements will not change. Only the configuration
+  	process will be different since you will certainly need a more
+  	specific configuration than what logback provides by default. 
+  	As you will see later on in this document,
+  	configuring logback can be done in different flexible and
+  	powerfull ways. Note that, normally, you won't need to invoke
+  	<code>LoggerStatusPrinter</code>
+  	after your log statements.
   </p>
-  <em>Example 1.3: Configuring before logging (<a href="xref/chapter1/HelloWorld3.html">logback-examples/src/main/java/chapter1/HelloWorld3.java)</a></em>
-  <div class="source"><pre>package chapter1;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-<b>import ch.qos.logback.classic.BasicConfigurator;</b>
-import ch.qos.logback.classic.util.LoggerStatusPrinter;
-
-public class HelloWorld3 {
-
-  public static void main(String[] args) {
-    Logger logger = LoggerFactory.getLogger("chapter1.HelloWorld3");
-    <b>BasicConfigurator.configureDefaultContext();</b>
-    logger.debug("Hello world.");
-    LoggerStatusPrinter.printStatusInDefaultContext();
-
-  }
-}</pre></div>
-
-		<p>
-			Let's run the <code>HelloWorld3</code> application. In this
-			example, the <code><a
-			href="xref/ch/qos/logback/classic/BasicConfigurator.html">BasicConfigurator</a></code>
-			class's <code>configureDefaultContext()</code> method is
-			invoked. It will create a simple <code>ConsoleAppender</code>.
-			The logging request will then be propagated to the
-			<code>Appender</code> and the console will output the following:
-		</p>
-<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 application would not be any different. The general
-			pattern logging statements will not change. Only the
-			configuration process will be different since you don't need
-			(nor should) configure the logging context in each and every
-			class that requires logging. As you will see later on in this
-			document, configuring logback can be done in different flexible
-			and powerfull ways.  Note that, normally, you won't need to
-			invoke <code>LoggerStatusPrinter</code> after your log
-			statements.
-		</p>
 
-		<p>	
+  <p>	
 			Here is a list of the three required steps in order to enable
 			logging in your application.
 		</p>
@@ -865,7 +832,7 @@
 			"%-4relative [%thread] %-5level %logger{32} - %msg%n" will output something akin to:
 		</p>
 
-		<div class="source"><pre>176  [main] DEBUG chapter1.HelloWorld3 - Hello world.</pre></div>
+		<div class="source"><pre>176  [main] DEBUG chapter1.HelloWorld2 - Hello world.</pre></div>
 
 		<p>
 			The first field is the number of milliseconds elapsed since



More information about the logback-dev mailing list