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