View Javadoc

1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2011, QOS.ch. All rights reserved.
4    *
5    * This program and the accompanying materials are dual-licensed under
6    * either the terms of the Eclipse Public License v1.0 as published by
7    * the Eclipse Foundation
8    *
9    *   or (per the licensee's choosing)
10   *
11   * under the terms of the GNU Lesser General Public License version 2.1
12   * as published by the Free Software Foundation.
13   */
14  package ch.qos.logback.access.joran.action;
15  
16  import ch.qos.logback.core.status.OnConsoleStatusListener;
17  import org.xml.sax.Attributes;
18  
19  import ch.qos.logback.core.joran.action.Action;
20  import ch.qos.logback.core.joran.spi.InterpretationContext;
21  import ch.qos.logback.core.util.ContextUtil;
22  import ch.qos.logback.core.util.StatusPrinter;
23  
24  
25  
26  public class ConfigurationAction extends Action {
27    static final String INTERNAL_DEBUG_ATTR = "debug";
28  
29    public void begin(InterpretationContext ec, String name, Attributes attributes) {
30      String debugAttrib = attributes.getValue(INTERNAL_DEBUG_ATTR);
31  
32      if (
33        (debugAttrib == null) || debugAttrib.equals("")
34          || debugAttrib.equals("false") || debugAttrib.equals("null")) {
35        addInfo("Ignoring " + INTERNAL_DEBUG_ATTR + " attribute.");
36      } else {
37        OnConsoleStatusListener.addNewInstanceToContext(context);
38      }
39  
40      new ContextUtil(context).addHostNameAsProperty();
41  
42      // the context is appender attachable, so it is pushed on top of the stack
43      ec.pushObject(getContext());
44    }
45  
46    public void end(InterpretationContext ec, String name) {
47      addInfo("End of configuration.");
48      ec.popObject();
49    }
50  }