[logback-dev] svn commit: r1749 - in logback/trunk: logback-classic/src/main/java/ch/qos/logback/classic/util logback-classic/src/test/java/ch/qos/logback/classic/util logback-classic/src/test/resources logback-examples/src/main/java/chapter1 logback-site/src/site/pages logback-site/src/site/pages/manual

noreply.ceki at qos.ch noreply.ceki at qos.ch
Sat Aug 9 21:50:33 CEST 2008


Author: ceki
Date: Sat Aug  9 21:50:32 2008
New Revision: 1749

Added:
   logback/trunk/logback-classic/src/test/resources/BOO_logback-test.xml
   logback/trunk/logback-classic/src/test/resources/README.txt
Removed:
   logback/trunk/logback-classic/src/test/resources/logback-test.xml
Modified:
   logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/LoggerStatusPrinter.java
   logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/util/InitializationTest.java
   logback/trunk/logback-examples/src/main/java/chapter1/HelloWorld2.java
   logback/trunk/logback-site/src/site/pages/index.html
   logback/trunk/logback-site/src/site/pages/mailinglist.html
   logback/trunk/logback-site/src/site/pages/manual/introduction.html
   logback/trunk/logback-site/src/site/pages/setup.html
   logback/trunk/logback-site/src/site/pages/team.html

Log:
- logback-examples should work under Eclipse
- simplification of LoggerStatusPrinter
- improvements to documentation

Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/LoggerStatusPrinter.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/LoggerStatusPrinter.java	(original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/util/LoggerStatusPrinter.java	Sat Aug  9 21:50:32 2008
@@ -12,18 +12,14 @@
 
 import org.slf4j.LoggerFactory;
 
-import ch.qos.logback.classic.Logger;
 import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.core.status.StatusManager;
 import ch.qos.logback.core.util.StatusPrinter;
 
 public class LoggerStatusPrinter {
 
   public static void printStatusInDefaultContext() {
-    Logger logger = (Logger) LoggerFactory.getLogger(LoggerStatusPrinter.class);
-    LoggerContext lc = logger.getLoggerContext();
-    StatusManager sm = lc.getStatusManager();
-    StatusPrinter.print(sm);
+    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
+    StatusPrinter.print(lc);
   }
 
 }

Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/util/InitializationTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/util/InitializationTest.java	(original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/util/InitializationTest.java	Sat Aug  9 21:50:32 2008
@@ -10,6 +10,7 @@
 
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.slf4j.LoggerFactory;
 
@@ -40,6 +41,10 @@
   }
 
   @Test
+  @Ignore
+  // this test works only if logback-test.xml or logback.xml files are on the classpath. 
+  // However, this is something we try to avoid in order to simplify the life
+  // of users trying to follows the manual and logback-examples from an IDE
   public void testAutoconfig() {
     Appender appender = root.getAppender("STDOUT");
     assertNotNull(appender);
@@ -47,6 +52,10 @@
   }
 
   @Test
+  @Ignore  
+  // this test works only if logback-test.xml or logback.xml files are on the classpath. 
+  // However, this is something we try to avoid in order to simplify the life
+  // of users trying to follows the manual and logback-examples from an IDE
   public void testReset() throws JoranException {
     {
       ContextInitializer.autoConfig(lc);

Added: logback/trunk/logback-classic/src/test/resources/BOO_logback-test.xml
==============================================================================
--- (empty file)
+++ logback/trunk/logback-classic/src/test/resources/BOO_logback-test.xml	Sat Aug  9 21:50:32 2008
@@ -0,0 +1,15 @@
+<configuration>
+
+  <appender name="STDOUT"
+    class="ch.qos.logback.core.ConsoleAppender">
+    <layout class="ch.qos.logback.classic.PatternLayout">
+      <param name="Pattern"
+        value="TEST %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n" />
+    </layout>
+  </appender>
+
+  <root>
+    <level value="ERROR" />
+    <appender-ref ref="STDOUT" />
+  </root>
+</configuration>
\ No newline at end of file

Added: logback/trunk/logback-classic/src/test/resources/README.txt
==============================================================================
--- (empty file)
+++ logback/trunk/logback-classic/src/test/resources/README.txt	Sat Aug  9 21:50:32 2008
@@ -0,0 +1,5 @@
+
+Few test cases InitializationTest requite the presence of logback.xml or logback-test.xml
+to be present in the classpath. However, this conflict with the logback-examples module. 
+In particular, when users attempt to follow the manual by importing the project in an IDE 
+such as Eclipse.
\ No newline at end of file

Modified: logback/trunk/logback-examples/src/main/java/chapter1/HelloWorld2.java
==============================================================================
--- logback/trunk/logback-examples/src/main/java/chapter1/HelloWorld2.java	(original)
+++ logback/trunk/logback-examples/src/main/java/chapter1/HelloWorld2.java	Sat Aug  9 21:50:32 2008
@@ -11,14 +11,17 @@
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
-import ch.qos.logback.classic.util.LoggerStatusPrinter;
+import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.core.util.StatusPrinter;
 
 public class HelloWorld2 {
 
   public static void main(String[] args) {
     Logger logger = LoggerFactory.getLogger("chapter1.HelloWorld2");
     logger.debug("Hello world.");
-    LoggerStatusPrinter.printStatusInDefaultContext();
+
+    // print internal state
+    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
+    StatusPrinter.print(lc);
   }
 }

Modified: logback/trunk/logback-site/src/site/pages/index.html
==============================================================================
--- logback/trunk/logback-site/src/site/pages/index.html	(original)
+++ logback/trunk/logback-site/src/site/pages/index.html	Sat Aug  9 21:50:32 2008
@@ -39,7 +39,8 @@
 		significantly improved version of log4j. Moreover, logback-classic
 		natively implements the <a href="http://www.slf4j.org">SLF4J
 		API</a> so that you can readily switch back and forth between
-		logback and other logging systems such as log4j or JDK14 Logging.
+		logback and other logging systems such as log4j or
+		java.util.logging (JUL).
     </p>
 
     <p>The logback-access module integrates with Servlet containers,
@@ -48,7 +49,14 @@
     on top of logback-core.
 		</p>
 
-	
+    <h3>Sister projects</h3>
+
+    <p>The <a href="http://audit.qos.ch">logback-audit</a> project is
+    designed for processing logging events having long-term business
+    significance. Logback-audit is commercial software based on
+    logback-core.
+    </p>
+    	
 <script src="templates/footer.js"></script>	
 </div>
 </body>

Modified: logback/trunk/logback-site/src/site/pages/mailinglist.html
==============================================================================
--- logback/trunk/logback-site/src/site/pages/mailinglist.html	(original)
+++ logback/trunk/logback-site/src/site/pages/mailinglist.html	Sat Aug  9 21:50:32 2008
@@ -162,7 +162,7 @@
    <h2>On IRC</h2>
 
    <p>We can also be reached by IRC at <span
-      class="big"><code>irc.freenode.net#logback</code></span>. </p>
+      class="big"><code>irc.freenode.net#qos.ch</code></span>. </p>
    
    <p>&nbsp;</p>
 	

Modified: logback/trunk/logback-site/src/site/pages/manual/introduction.html
==============================================================================
--- logback/trunk/logback-site/src/site/pages/manual/introduction.html	(original)
+++ logback/trunk/logback-site/src/site/pages/manual/introduction.html	Sat Aug  9 21:50:32 2008
@@ -98,24 +98,21 @@
 
 
     <p>
-      On the first line of the main() method, the variable named <code>logger</code>
-      is assigned a <code>Logger</code>
-      instance retreived by invoking the static method <code>getLogger</code>
-      in the <code>LoggerFactory</code> class. 
-      This logger is named "chapter1.HelloWorld1". The main method proceeds to call the
-      <code>debug</code> method of this logger passing "Hello World" as an argument. 
-      We say that the main
-      method contains a logging statement of level debug with the message "Hello world".
+      On the first line of the main() method, the variable named
+      <code>logger</code> is assigned a <code>Logger</code> instance
+      retrieved by invoking the static <code>getLogger</code> method
+      from the <code>LoggerFactory</code> class.  This logger is named
+      "chapter1.HelloWorld1". The main method proceeds to call the
+      <code>debug</code> method of this logger passing "Hello World"
+      as an argument.  We say that the main method contains a logging
+      statement of level DEBUG with the message "Hello world".
     </p>
 
-    <p>
-      You will note that the above example does not reference any
-      logback classes. In most cases, as far as logging is
-      concerned, your classes will need to import only SLF4J
-      classes. In principle, you will have to import logback
-      classes only for configuring logback. Thus, the vast
-      majority of your classes will only be cognizant of SLF4J API
-      and oblivious to the existence of logback.
+    <p>Note that the above example does not reference any logback
+    classes. In most cases, as far as logging is concerned, your
+    classes will only need to import SLF4J classes. Thus, the vast
+    majority, if not all, of your classes will be cognizant of SLF4J
+    API and oblivious to the existence of logback.
     </p>
 
 
@@ -124,12 +121,11 @@
     </p>
     <div class="source"><pre>java chapter1.HelloWorld1</pre></div>
 
-    <p>
-      Launching the <code>HelloWorld1</code>
-      application will output a single line on the console. By virtue of
-      to logback's default configuration policy, when no default file 
-      is found to configure logback explicitely, logback will add a 
-      <code>ConsoleAppender</code> to the root logger.
+    <p>Launching the <code>HelloWorld1</code> application will output
+    a single line on the console. By virtue of to logback's default
+    configuration policy, when no default configuration file is found,
+    logback will add a <code>ConsoleAppender</code> to the root
+    logger.
     </p>
 
 <div class="source"><pre>20:49:07.962 [main] DEBUG chapter1.HelloWorld1 - Hello world.</pre></div>
@@ -149,14 +145,18 @@
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-<b>import ch.qos.logback.classic.util.LoggerStatusPrinter;</b>
+<b>import ch.qos.logback.classic.LoggerContext;
+import ch.qos.logback.core.util.StatusPrinter;</b>
 
 public class HelloWorld2 {
 
   public static void main(String[] args) {
     Logger logger = LoggerFactory.getLogger("chapter1.HelloWorld2");
     logger.debug("Hello world.");
-    <b>LoggerStatusPrinter.printStatusInDefaultContext();</b>
+
+    // print internal state
+    <b>LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
+    StatusPrinter.print(lc);</b>
   }
 }</pre></div>
 

Modified: logback/trunk/logback-site/src/site/pages/setup.html
==============================================================================
--- logback/trunk/logback-site/src/site/pages/setup.html	(original)
+++ logback/trunk/logback-site/src/site/pages/setup.html	Sat Aug  9 21:50:32 2008
@@ -20,59 +20,61 @@
 <div id="content">
 	
 	
-<h2>Classpath Setup</h2>
+  <h2>Classpath Setup</h2>
 
-<p>
-In order to run the examples provided in the documentation,
-you need to add the following jars to your class path:
-</p>
-
-<ul>
-	<p>logback-core-${version}.jar</p>
-	<p>logback-classic-${version}.jar</p>
-	<p>logback-examples-${version}.jar</p>
-	<p>slf4j-api-${slf4j.version}.jar</p>
-</ul>
-
-<h3>Example</h3>
-
-<p>
-Assuming your current directory is
-<em>$LOGBACK_HOME/logback-examples</em>, where <em>$LOGBACK_HOME</em> stands
-for the directory where you installed logback, you can launch the first
-sample application, <em>chapter1.HelloWord1</em> with the following command:
-</p>
+  <p>In order to run the examples provided in the documentation, you
+  need to add the following jars to your class path:
+  </p>
+
+  <ul>
+    <li>logback-core-${version}.jar</li>
+    <li>logback-classic-${version}.jar</li>
+    <li>logback-examples-${version}.jar</li>
+    <li>slf4j-api-${slf4j.version}.jar</li>
+  </ul>
+
+  <h3>Running from the command line</h3>
+
+  <p>Assuming your current directory is
+  <em>$LOGBACK_HOME/logback-examples</em>, where
+  <em>$LOGBACK_HOME</em> stands for the directory where you installed
+  logback, you can launch the first sample application,
+  <em>chapter1.HelloWord1</em> with the following command:
+  </p>
 
 <div class="source"><pre>java -cp
  lib/slf4j-api-${slf4j.version}.jar;../logback-core-${version}.jar;\
  ../logback-classic-${version}.jar;logback-examples-${version}.jar\
  chapter1.HelloWorld1</pre></div>
 
-<p>
-It is more convenient to set the CLASSPATH environment variable
-once and for all before running the examples.
-</p>
-<p>The <em>setClasspath.cmd</em> script located in the $LOGBACK_HOME/logback-examples 
-folder will configure the class path for the MS Windows platform. For Unix, you can
-use <em>setClasspath.sh</em>.
-</p>
-
-<p>Please edit the script in order to adapt the <em>LB_HOME</em> variable 
-to match your local environment.</p>
-
-<p>
-Please be aware that many examples will launch java classes along
-with configuration files. To access these files by using
-the same commands as written in the documentation, you will need to
-issue the commands from within the <em>$LOGBACK_HOME/logback-examples</em> 
-directory.
-</p>
+ <p>It is more convenient to set the CLASSPATH environment variable
+ once and for all before running the examples.
+ </p>
+
+ <p>The <em>setClasspath.cmd</em> script located in the
+ $LOGBACK_HOME/logback-examples folder will configure the class path
+ for the MS Windows platform. For Unix, you can use
+ <em>setClasspath.sh</em>.
+ </p>
+
+ <p>Please edit the script in order to adapt the <em>LB_HOME</em> variable 
+ to match your local environment.</p>
+
+ <p>Please be aware that many examples will launch java classes along
+ with configuration files. To access these files by using the same
+ commands as written in the documentation, you will need to issue the
+ commands from within the <em>$LOGBACK_HOME/logback-examples</em>
+ directory.
+ </p>
+
+ <h3>Using an IDE, e.g. Eclipse</h3>
+
+ <p>You can import the logback project into Eclipse. Since logback
+ uses maven as its build system, the "maven eclipse:eclipse" command
+ will create the <em>.classpath</em> and <em>.project</em> files for
+ Eclipse. You can then import the logback project into Eclipse in one
+ or two clicks.</p>
 
-
-	
-	
-	
-	
 	
 	
 	

Modified: logback/trunk/logback-site/src/site/pages/team.html
==============================================================================
--- logback/trunk/logback-site/src/site/pages/team.html	(original)
+++ logback/trunk/logback-site/src/site/pages/team.html	Sat Aug  9 21:50:32 2008
@@ -48,14 +48,6 @@
           first sight.  His interests range from cryptography, system
           monitoring and testing to application interoperability.
           </p>
-
-          <p>One of the core lessons he has learned over the years is
-          that unit tests lie at the heart of maintainable
-          software. Adding tests at the end of development cycle
-          yields poor results. Tests must be part of development right
-          from the beginning.
-          </p>         
-
 				</td>
 			</tr>
 			<tr class="a">


More information about the logback-dev mailing list