View Javadoc

1   /**
2    * Logback: the generic, reliable, fast and flexible logging framework.
3    * 
4    * Copyright (C) 2000-2008, QOS.ch
5    * 
6    * This library is free software, you can redistribute it and/or modify it under
7    * the terms of the GNU Lesser General Public License as published by the Free
8    * Software Foundation.
9    */
10  
11  package chapter3;
12  
13  import org.slf4j.Logger;
14  import org.slf4j.LoggerFactory;
15  
16  import ch.qos.logback.classic.LoggerContext;
17  import ch.qos.logback.core.util.StatusPrinter;
18  
19  public class MyApp2 {
20    final static Logger logger = LoggerFactory.getLogger(MyApp2.class);
21  
22    public static void main(String[] args) {
23      // assume SLF4J is bound to logback in the current environment
24      LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
25      // print logback's internal status
26      StatusPrinter.print(lc);
27      
28      logger.info("Entering application.");
29      Foo foo = new Foo();
30      foo.doIt();
31      logger.info("Exiting application.");
32    }
33  }