
Author: seb Date: Mon Aug 7 21:06:09 2006 New Revision: 410 Modified: logback/classic/trunk/src/site/xdocTemplates/shortIntro.xml Log: minor fixes 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 Mon Aug 7 21:06:09 2006 @@ -217,10 +217,8 @@ public class HelloWorld3 { - final static Logger logger = LoggerFactory.getLogger(HelloWorld3.class); - public static void main(String[] args) { - + Logger logger = LoggerFactory.getLogger(HelloWorld3.class); <b>BasicConfigurator.configureDefaultContext();</b> logger.debug("Hello world."); LoggerStatusPrinter.printStatusInDefaultContext(); @@ -953,15 +951,13 @@ public class MyApp { - // Define a static logger variable so that it references the - // Logger instance named "MyApp". - static Logger logger = LoggerFactory.getLogger(MyApp.class); - 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(); @@ -975,7 +971,8 @@ </p> <div class="source"> class Bar { - static Logger logger = LoggerFactory.getLogger(Bar.class); + + Logger logger = LoggerFactory.getLogger(Bar.class); public void doIt() { logger.debug("doing my job"); @@ -1046,11 +1043,9 @@ public class MyAppWithConfigFile { - // Define a static logger variable so that it references the - // Logger instance named "MyAppWithConfigFile". - static Logger logger = (Logger) LoggerFactory.getLogger(MyAppWithConfigFile.class); - public static void main(String[] args) throws Exception { + Logger logger = (Logger) LoggerFactory.getLogger(MyAppWithConfigFile.class); + JoranConfigurator configurator = new JoranConfigurator(); configurator.setContext(logger.getLoggerContext()); configurator.doConfigure(args[0]); @@ -1111,5 +1106,18 @@ <p>Suppose that we do not want to see the DEBUG level statements in the chapter1 package anymore. This is done by adding a <em>logger</em> element, with a nested element specifying its level value.</p> + <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> + + <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 + to an NT Event logger, or forwarded logging events to a remote logback server, + which would log according to local server policy, for example by forwarding the log event + to a second logback server.</p> + </body> </document>