1
2
3
4
5
6
7
8
9
10
11 package ch.qos.logback.classic.joran.action;
12
13 import org.xml.sax.Attributes;
14
15 import ch.qos.logback.core.joran.action.Action;
16 import ch.qos.logback.core.joran.spi.InterpretationContext;
17
18 public class ContextNameAction extends Action {
19
20 public void begin(InterpretationContext ec, String name, Attributes attributes) {
21 }
22
23 public void body(InterpretationContext ec, String body) {
24
25 String finalBody = ec.subst(body);
26 addInfo("Setting logger context name as [" + finalBody + "]");
27 try {
28 context.setName(finalBody);
29 } catch (IllegalStateException e) {
30 addError("Failed to rename context [" + context.getName() + "] as ["
31 + finalBody + "]", e);
32 }
33 }
34
35 public void end(InterpretationContext ec, String name) {
36 }
37 }