1
2
3
4
5
6
7
8
9
10
11
12
13
14 package chapters.configuration;
15
16
17
18
19
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
22
23 import ch.qos.logback.classic.LoggerContext;
24 import ch.qos.logback.classic.joran.JoranConfigurator;
25 import ch.qos.logback.core.joran.spi.JoranException;
26 import ch.qos.logback.core.util.StatusPrinter;
27
28 public class MyApp3 {
29 final static Logger logger = LoggerFactory.getLogger(MyApp3.class);
30
31 public static void main(String[] args) {
32
33 LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
34
35 try {
36 JoranConfigurator configurator = new JoranConfigurator();
37 configurator.setContext(context);
38
39
40 context.reset();
41 configurator.doConfigure(args[0]);
42 } catch (JoranException je) {
43
44 }
45 StatusPrinter.printInCaseOfErrorsOrWarnings(context);
46
47 logger.info("Entering application.");
48
49 Foo foo = new Foo();
50 foo.doIt();
51 logger.info("Exiting application.");
52 }
53 }