1
2
3
4
5
6
7
8
9
10
11 package chapter3.helloWorld;
12
13 import java.util.HashMap;
14 import java.util.Map;
15
16 import chapter3.SimpleConfigurator;
17 import ch.qos.logback.core.Context;
18 import ch.qos.logback.core.ContextBase;
19 import ch.qos.logback.core.joran.action.Action;
20 import ch.qos.logback.core.joran.spi.JoranException;
21 import ch.qos.logback.core.joran.spi.Pattern;
22 import ch.qos.logback.core.util.StatusPrinter;
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 public class HelloWorld {
41 public static void main(String[] args) throws Exception {
42 Map<Pattern, Action> ruleMap = new HashMap<Pattern, Action>();
43
44
45 ruleMap.put(new Pattern("hello-world"), new HelloWorldAction());
46
47
48 Context context = new ContextBase();
49 SimpleConfigurator simpleConfigurator = new SimpleConfigurator(ruleMap);
50
51 simpleConfigurator.setContext(context);
52
53 try {
54 simpleConfigurator.doConfigure(args[0]);
55 } catch (JoranException e) {
56
57 StatusPrinter.print(context);
58 }
59 }
60 }