[logback-dev] svn commit: r1755 - logback/trunk/logback-examples/src/main/java/chapter3

noreply.ceki at qos.ch noreply.ceki at qos.ch
Thu Aug 14 18:01:23 CEST 2008


Author: ceki
Date: Thu Aug 14 18:01:22 2008
New Revision: 1755

Added:
   logback/trunk/logback-examples/src/main/java/chapter3/MyApp3.java
Modified:
   logback/trunk/logback-examples/src/main/java/chapter3/MyApp2.java

Log:
working on the docs

Modified: logback/trunk/logback-examples/src/main/java/chapter3/MyApp2.java
==============================================================================
--- logback/trunk/logback-examples/src/main/java/chapter3/MyApp2.java	(original)
+++ logback/trunk/logback-examples/src/main/java/chapter3/MyApp2.java	Thu Aug 14 18:01:22 2008
@@ -14,29 +14,18 @@
 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;
 
 public class MyApp2 {
   final static Logger logger = LoggerFactory.getLogger(MyApp2.class);
 
   public static void main(String[] args) {
-    // assume logback is in use
+    logger.info("Entering application.");
+    
+    // print logback's internal status
     LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
+    StatusPrinter.print(lc);
     
-
-    try {
-      JoranConfigurator configurator = new JoranConfigurator();
-      configurator.setContext(lc);
-      lc.shutdownAndReset();
-      configurator.doConfigure(args[0]);
-    } catch (JoranException je) {
-      StatusPrinter.print(lc);
-    }
-
-    logger.info("Entering application.");
-
     Foo foo = new Foo();
     foo.doIt();
     logger.info("Exiting application.");

Added: logback/trunk/logback-examples/src/main/java/chapter3/MyApp3.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-examples/src/main/java/chapter3/MyApp3.java	Thu Aug 14 18:01:22 2008
@@ -0,0 +1,47 @@
+/**
+ * Logback: the reliable, generic, fast and flexible logging framework.
+ * 
+ * Copyright (C) 1999-2008, QOS.ch
+ * 
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
+
+package chapter3;
+
+/**
+ * Demonstrates programmatic invocation of Joran.
+ * 
+ */
+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;
+
+public class MyApp3 {
+  final static Logger logger = LoggerFactory.getLogger(MyApp3.class);
+
+  public static void main(String[] args) {
+    // assume logback is in use
+    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
+
+    try {
+      JoranConfigurator configurator = new JoranConfigurator();
+      configurator.setContext(lc);
+      lc.shutdownAndReset();
+      configurator.doConfigure(args[0]);
+    } catch (JoranException je) {
+      StatusPrinter.print(lc);
+    }
+
+    logger.info("Entering application.");
+
+    Foo foo = new Foo();
+    foo.doIt();
+    logger.info("Exiting application.");
+  }
+}


More information about the logback-dev mailing list