[logback-dev] [GIT] Logback: the generic, reliable, fast and flexible logging framework. branch master updated. v_0.9.30-30-g0ee1873

added by portage for gitosis-gentoo git-noreply at pixie.qos.ch
Mon Oct 17 21:44:24 CEST 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Logback: the generic, reliable, fast and flexible logging framework.".

The branch, master has been updated
       via  0ee187332ad85e5f7fa9422c8c8332d73fb2456c (commit)
       via  e643e9086b76e71db67b24c9990f47c9be3dad2f (commit)
       via  3356c3ef1df6890437dc765872a6605942cbb994 (commit)
      from  e338de8293ab031e545c76757b5406d63ec21ff1 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=0ee187332ad85e5f7fa9422c8c8332d73fb2456c
http://github.com/ceki/logback/commit/0ee187332ad85e5f7fa9422c8c8332d73fb2456c

commit 0ee187332ad85e5f7fa9422c8c8332d73fb2456c
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Mon Oct 17 21:44:15 2011 +0200

    properties now have scope. Fixed LBCORE-212

diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LoggerAction.java b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LoggerAction.java
index 67750ed..85d0aab 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LoggerAction.java
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/LoggerAction.java
@@ -40,7 +40,7 @@ public class LoggerAction extends Action {
     
     LoggerContext loggerContext = (LoggerContext) this.context;
 
-    String loggerName = attributes.getValue(NAME_ATTRIBUTE);
+    String loggerName = ec.subst(attributes.getValue(NAME_ATTRIBUTE));
 
     if (OptionHelper.isEmpty(loggerName)) {
       inError = true;
diff --git a/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java b/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java
index 54c5f63..4884ea6 100644
--- a/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java
+++ b/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java
@@ -404,7 +404,25 @@ public class JoranConfiguratorTest {
     StatusPrinter.print(loggerContext);
     sc.containsException(ScanException.class);
     sc.containsMatch(Status.ERROR, "Expecting RIGHT_PARENTHESIS token but got null");
-    sc.containsMatch(Status.ERROR, "See also "+ Parser.MISSING_RIGHT_PARENTHESIS);
+    sc.containsMatch(Status.ERROR, "See also " + Parser.MISSING_RIGHT_PARENTHESIS);
   }
 
+
+  @Test
+  public void properties() throws JoranException {
+    String configFileAsStr = ClassicTestConstants.JORAN_INPUT_PREFIX
+            + "properties.xml";
+    assertNull(loggerContext.getProperty(CoreConstants.HOSTNAME_KEY));
+    assertNull(System.getProperty("sys"));
+
+    configure(configFileAsStr);
+    assertNotNull(loggerContext.getProperty(CoreConstants.HOSTNAME_KEY));
+    assertNull(loggerContext.getProperty("transientKey1"));
+    assertNull(loggerContext.getProperty("transientKey2"));
+    assertEquals("node0", loggerContext.getProperty("nodeId"));
+    assertEquals("tem", System.getProperty("sys"));
+    assertNotNull(loggerContext.getProperty("path"));
+    assertTrue(sc.isErrorFree(0));
+    StatusPrinter.print(loggerContext);
+  }
 }
diff --git a/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java b/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java
index 0afe865..fcb642f 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/CoreConstants.java
@@ -139,4 +139,5 @@ public class CoreConstants {
   public static final int MILLIS_IN_ONE_DAY = MILLIS_IN_ONE_HOUR*24;
   public static final int MILLIS_IN_ONE_WEEK = MILLIS_IN_ONE_DAY*7;
 
+  public static final String CONTEXT_SCOPE_VALUE = "context";
 }
diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/Action.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/Action.java
index e5defa6..c863e33 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/Action.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/Action.java
@@ -43,6 +43,8 @@ public abstract class Action extends ContextAwareBase {
   public static final String FILE_ATTRIBUTE = "file";
   public static final String CLASS_ATTRIBUTE = "class";
   public static final String PATTERN_ATTRIBUTE = "pattern";
+  public static final String SCOPE_ATTRIBUTE = "scope";
+
 
   public static final String ACTION_CLASS_ATTRIBUTE = "actionClass";
 
diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/action/PropertyAction.java b/logback-core/src/main/java/ch/qos/logback/core/joran/action/PropertyAction.java
index cd9e3be..9531547 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/joran/action/PropertyAction.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/joran/action/PropertyAction.java
@@ -13,6 +13,8 @@
  */
 package ch.qos.logback.core.joran.action;
 
+import ch.qos.logback.core.CoreConstants;
+import ch.qos.logback.core.util.ContextUtil;
 import org.xml.sax.Attributes;
 
 import ch.qos.logback.core.joran.spi.InterpretationContext;
@@ -39,21 +41,41 @@ import java.util.Properties;
  */
 public class PropertyAction extends Action {
 
+  enum Scope {LOCAL, CONTEXT, SYSTEM};
+
   static final String RESOURCE_ATTRIBUTE = "resource";
 
+
   static String INVALID_ATTRIBUTES = "In <property> element, either the \"file\" attribute alone, or "
-      + "the \"resource\" element alone, or both the \"name\" and \"value\" attributes must be set.";
+          + "the \"resource\" element alone, or both the \"name\" and \"value\" attributes must be set.";
 
   /**
    * Add all the properties found in the argument named 'props' to an
    * InterpretationContext.
    */
-  public void setProperties(InterpretationContext ec, Properties props) {
-    ec.addSubstitutionProperties(props);
+  public void setProperties(InterpretationContext ec, Properties props, Scope scope) {
+    switch(scope) {
+      case LOCAL: ec.addSubstitutionProperties(props);
+        break;
+      case CONTEXT:
+        ContextUtil cu = new ContextUtil((context));
+        cu.addProperties(props);
+        break;
+      case SYSTEM:
+        OptionHelper.setSystemProperties(this, props);
+    }
   }
 
-  public void setProperty(InterpretationContext ec, String key, String value) {
-    ec.addSubstitutionProperty(key, value);
+  public void setProperty(InterpretationContext ec, String key, String value,  Scope scope) {
+     switch(scope) {
+      case LOCAL: ec.addSubstitutionProperty(key, value);
+        break;
+      case CONTEXT:
+        context.putProperty(key, value);
+        break;
+      case SYSTEM:
+        OptionHelper.setSystemProperty(this, key, value);
+    }
   }
 
   /**
@@ -70,13 +92,16 @@ public class PropertyAction extends Action {
 
     String name = attributes.getValue(NAME_ATTRIBUTE);
     String value = attributes.getValue(VALUE_ATTRIBUTE);
+    String scopeStr = attributes.getValue(SCOPE_ATTRIBUTE);
+
+    Scope scope = stringToScope(scopeStr);
 
     if (checkFileAttributeSanity(attributes)) {
       String file = attributes.getValue(FILE_ATTRIBUTE);
       file = ec.subst(file);
       try {
         FileInputStream istream = new FileInputStream(file);
-        loadAndSetProperties(ec, istream);
+        loadAndSetProperties(ec, istream, scope);
       } catch (IOException e) {
         addError("Could not read properties file [" + file + "].", e);
       }
@@ -89,7 +114,7 @@ public class PropertyAction extends Action {
       } else {
         try {
           InputStream istream = resourceURL.openStream();
-          loadAndSetProperties(ec, istream);
+          loadAndSetProperties(ec, istream, scope);
         } catch (IOException e) {
           addError("Could not read resource file [" + resource + "].", e);
         }
@@ -99,19 +124,28 @@ public class PropertyAction extends Action {
       // now remove both leading and trailing spaces
       value = value.trim();
       value = ec.subst(value);
-      setProperty(ec, name, value);
+      setProperty(ec, name, value, scope);
 
     } else {
       addError(INVALID_ATTRIBUTES);
     }
   }
 
-  void loadAndSetProperties(InterpretationContext ec, InputStream istream)
+  private Scope stringToScope(String scopeStr) {
+    if(Scope.SYSTEM.toString().equalsIgnoreCase(scopeStr))
+      return Scope.SYSTEM;
+     if(Scope.CONTEXT.toString().equalsIgnoreCase(scopeStr))
+      return Scope.CONTEXT;
+
+    return Scope.LOCAL;
+  }
+
+  void loadAndSetProperties(InterpretationContext ec, InputStream istream, Scope scope)
       throws IOException {
     Properties props = new Properties();
     props.load(istream);
     istream.close();
-    setProperties(ec, props);
+    setProperties(ec, props, scope);
   }
 
   boolean checkFileAttributeSanity(Attributes attributes) {
diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/IfAction.java b/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/IfAction.java
index ba9ca8a..6fcea69 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/IfAction.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/joran/conditional/IfAction.java
@@ -57,7 +57,7 @@ public class IfAction extends Action {
 
 
     if (!OptionHelper.isEmpty(conditionAttribute)) {
-      conditionAttribute = OptionHelper.substVars(conditionAttribute, context);
+      conditionAttribute = OptionHelper.substVars(conditionAttribute, ic, context);
       PropertyEvalScriptBuilder pesb = new PropertyEvalScriptBuilder();
       pesb.setContext(context);
       try {
diff --git a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/InterpretationContext.java b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/InterpretationContext.java
index 7df6306..20a3cca 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/joran/spi/InterpretationContext.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/joran/spi/InterpretationContext.java
@@ -48,7 +48,7 @@ public class InterpretationContext extends ContextAwareBase implements
   Interpreter joranInterpreter;
   final List<InPlayListener> listenerList = new ArrayList<InPlayListener>();
   DefaultNestedComponentRegistry defaultNestedComponentRegistry = new DefaultNestedComponentRegistry();
-  
+
   public InterpretationContext(Context context, Interpreter joranInterpreter) {
     this.context = context;
     this.joranInterpreter = joranInterpreter;
@@ -120,15 +120,9 @@ public class InterpretationContext extends ContextAwareBase implements
     if (key == null || value == null) {
       return;
     }
-    // if (substitutionProperties.contains(key)) {
-    // LogLog.warn(
-    // "key [" + key
-    // + "] already contained in the EC properties. Overwriting.");
-    // }
-
     // values with leading or trailing spaces are bad. We remove them now.
     value = value.trim();
-    context.putProperty(key, value);
+    propertiesMap.put(key, value);
   }
 
   public void addSubstitutionProperties(Properties props) {
@@ -142,17 +136,6 @@ public class InterpretationContext extends ContextAwareBase implements
     }
   }
 
-  public void addSubstitutionProperties(Map<String, String> propertyMap) {
-    if (propertyMap == null) {
-      return;
-    }
-    Iterator i = propertyMap.keySet().iterator();
-    while (i.hasNext()) {
-      String key = (String) i.next();
-      addSubstitutionProperty(key, propertyMap.get(key));
-    }
-  }
-
   /**
    * If a key is found in propertiesMap then return it. Otherwise, delegate to
    * the context.
@@ -170,7 +153,7 @@ public class InterpretationContext extends ContextAwareBase implements
     if (value == null) {
       return null;
     }
-    return OptionHelper.substVars(value, this);
+    return OptionHelper.substVars(value, this, context);
   }
 
 
diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/ContextUtil.java b/logback-core/src/main/java/ch/qos/logback/core/util/ContextUtil.java
index 49e3c2b..8fd2065 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/util/ContextUtil.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/util/ContextUtil.java
@@ -15,6 +15,8 @@ package ch.qos.logback.core.util;
 
 import java.net.InetAddress;
 import java.net.UnknownHostException;
+import java.util.Iterator;
+import java.util.Properties;
 
 import ch.qos.logback.core.Context;
 import ch.qos.logback.core.CoreConstants;
@@ -44,4 +46,15 @@ public class ContextUtil extends ContextAwareBase {
       addError("Failed to get local hostname", e);
     }
   }
+
+   public void addProperties(Properties props) {
+    if (props == null) {
+      return;
+    }
+    Iterator i = props.keySet().iterator();
+    while (i.hasNext()) {
+      String key = (String) i.next();
+      context.putProperty(key, props.getProperty(key));
+    }
+  }
 }
diff --git a/logback-core/src/main/java/ch/qos/logback/core/util/OptionHelper.java b/logback-core/src/main/java/ch/qos/logback/core/util/OptionHelper.java
index cc33aac..cdbf8c6 100644
--- a/logback-core/src/main/java/ch/qos/logback/core/util/OptionHelper.java
+++ b/logback-core/src/main/java/ch/qos/logback/core/util/OptionHelper.java
@@ -17,6 +17,7 @@ import java.util.Properties;
 
 import ch.qos.logback.core.Context;
 import ch.qos.logback.core.CoreConstants;
+import ch.qos.logback.core.spi.ContextAware;
 import ch.qos.logback.core.spi.PropertyContainer;
 
 /**
@@ -80,54 +81,16 @@ public class OptionHelper {
   final static String _IS_UNDEFINED = "_IS_UNDEFINED";
 
   /**
-   * Perform variable substitution in string <code>val</code> from the values
-   * of keys found in context property map, and if that fails, then in the
-   * system properties.
-   * 
-   * <p> The variable substitution delimeters are <b>${</b> and <b>}</b>.
-   * 
-   * <p> For example, if the context property map contains a property "key1" set
-   * as "value1", then the call
-   * 
-   * <pre>
-   * String s = OptionConverter.substituteVars("Value of key is ${key1}.", context);</pre>
-   * 
-   * will set the variable <code>s</code> to "Value of key is value1.".
-   * 
-   * <p> If no value could be found for the specified key in the context map,
-   * then the system properties are searched, if that fails, then substitution
-   * defaults to appending "_IS_UNDEFINED" to the key name.
-   * 
-   * <p> For example, if not the context not the system properties contains no
-   * value for the key "inexistentKey", then the call
-   * 
-   * <pre>
-   * String s = OptionConverter.subsVars(
-   *     "Value of inexistentKey is [${inexistentKey}]", context);</pre>
-   * 
-   * will set <code>s</code> to "Value of inexistentKey is
-   * [inexistentKey_IS_UNDEFINED]".
-   * 
-   * <p> Nevertheless, it is possible to specify a default substitution value
-   * using the ":-" operator. For example, the call
-   * 
-   * <pre>
-   * String s = OptionConverter.subsVars("Value of key is [${key2:-val2}]", context);</pre>
-   * 
-   * will set <code>s</code> to "Value of key is [val2]" even if the "key2"
-   * property is not set.
-   * 
-   * <p> An {@link java.lang.IllegalArgumentException} is thrown if
-   * <code>val</code> contains a start delimeter "${" which is not balanced by
-   * a stop delimeter "}". </p>
-   * 
-   * 
-   * @param val
-   *                The string on which variable substitution is performed.
-   * @throws IllegalArgumentException
-   *                 if <code>val</code> is malformed.
+   * @see  #substVars(String, PropertyContainer, PropertyContainer)
+   */
+   public static String substVars(String val, PropertyContainer pc1) {
+     return substVars(val, pc1, null);
+   }
+
+  /**
+   * See  http://logback.qos.ch/manual/configuration.html#variableSubstitution
    */
-  public static String substVars(String val, PropertyContainer pc) {
+  public static String substVars(String val, PropertyContainer pc1, PropertyContainer pc2) {
 
     StringBuffer sbuf = new StringBuffer();
 
@@ -166,15 +129,7 @@ public class OptionHelper {
           String key = extracted[0];
           String defaultReplacement = extracted[1]; // can be null
 
-          String replacement = null;
-
-          // first try the props passed as parameter
-          replacement = pc.getProperty(key);
-
-          // then try in System properties
-          if (replacement == null) {
-            replacement = getSystemProperty(key, null);
-          }
+          String replacement = lookup(key, pc1, pc2);
 
           // if replacement is still null, use the defaultReplacement which
           // can be null as well
@@ -188,7 +143,7 @@ public class OptionHelper {
             // where the properties are
             // x1=p1
             // x2=${x1}
-            String recursiveReplacement = substVars(replacement, pc);
+            String recursiveReplacement = substVars(replacement, pc1, pc2);
             sbuf.append(recursiveReplacement);
           } else {
             // if we could not find a replacement, then signal the error
@@ -201,6 +156,26 @@ public class OptionHelper {
     }
   }
 
+  private static String lookup(String key, PropertyContainer pc1,
+                               PropertyContainer pc2) {
+    String value = null;
+    // first try the props passed as parameter
+    value = pc1.getProperty(key);
+
+    // then try  the pc2
+    if (value == null && pc2 != null) {
+      value = pc2.getProperty(key);
+    }
+    // then try in System properties
+    if (value == null) {
+      value = getSystemProperty(key, null);
+    }
+    if (value == null) {
+      value = getEnv(key);
+    }
+    return value;
+  }
+
   /**
    * Very similar to <code>System.getProperty</code> except that the
    * {@link SecurityException} is absorbed.
@@ -221,6 +196,20 @@ public class OptionHelper {
   }
 
   /**
+   * Lookup a key from the environment.
+   * @param key
+   * @return value corresponding to key from the OS environment
+   */
+  public static String getEnv(String key) {
+    try {
+      return System.getenv(key);
+    } catch (SecurityException e) {
+      return null;
+    }
+  }
+
+
+  /**
    * Very similar to <code>System.getProperty</code> except that the
    * {@link SecurityException} is absorbed.
    * 
@@ -237,6 +226,22 @@ public class OptionHelper {
     }
   }
 
+  public static void setSystemProperties(ContextAware contextAware, Properties props) {
+    for(Object o: props.keySet()) {
+      String key = (String) o;
+      String value = props.getProperty(key);
+      setSystemProperty(contextAware, key, value);
+    }
+  }
+
+  public static void setSystemProperty(ContextAware contextAware, String key, String value) {
+    try {
+      System.setProperty(key, value);
+    } catch (SecurityException e) {
+      contextAware.addError("Failed to set system property ["+key+"]", e);
+    }
+  }
+
   /**
    * Very similar to {@link System#getProperties()} except that the
    * {@link SecurityException} is absorbed.
@@ -291,4 +296,5 @@ public class OptionHelper {
     return ((val == null) || CoreConstants.EMPTY_STRING.equals(val));
   }
 
+
 }
diff --git a/logback-site/src/site/pages/download.html b/logback-site/src/site/pages/download.html
index 15a40a5..866ec57 100644
--- a/logback-site/src/site/pages/download.html
+++ b/logback-site/src/site/pages/download.html
@@ -82,7 +82,7 @@
 	
     <hr/>
 
-    <h2>Third-party tools, extensions or forks</h2>
+    <h2>Third-party tools, extensions or forks (in chronological order)</h2>
 
     <p>If you are the author of a logback-related project and would
     like us to add your project to the list below please drop a line
@@ -136,6 +136,21 @@
         </p> 
       </dd>
 
+
+    <!-- ============================================================ -->
+      <dt>
+        <a
+        href="http://code.google.com/p/simpledb-appender/">
+        Simpledb-appender</a> by Gabriel Nell
+      </dt>
+
+      <dd>
+        <p>Logback Appender writing to Amazon SimpleDB. See also <a
+        href="http://www.peecho.com/blog/logging-the-cloud-with-simpledb.html">Logging
+        the cloud with SimpleDB</a>.</p>
+      </dd>
+
+
     </dl>
 
     <p/>  
diff --git a/logback-site/src/site/pages/manual/configuration.html b/logback-site/src/site/pages/manual/configuration.html
index b7aa29a..932fd24 100644
--- a/logback-site/src/site/pages/manual/configuration.html
+++ b/logback-site/src/site/pages/manual/configuration.html
@@ -1264,30 +1264,59 @@ public class MyApp3 {
   <!-- =============================================================== -->
  
 
-  <h4><a name="variableSubstitution"
-  href="#variableSubstitution">Variable substitution</a></h4>
+  <h3><a name="variableSubstitution"
+  href="#variableSubstitution">Property substitution</a></h3>
 
-  <p>In principle, variable substitution can occur at any point where
-  a value can be specified. The syntax of variable substitution is
-  similar to that of Unix shells. The string between an opening
-  <em>${</em> and closing <em>}</em> is interpreted as a key.  The
-  value of the substituted variable can be defined in the
-  configuration file itself, in an external properties file or as a
-  system property.  The corresponding value replaces <em>${aKey}</em>
-  sequence. For example, if the <em>java.home.dir</em> system property is
-  set to <em>/home/xyz</em>, then every occurrence of the sequence
-  <em>${java.home.dir}</em> will be interpreted as <em>/home/xyz</em>.
-  As they often come in handy, the ${HOSTNAME} and ${CONTEXT_NAME}
-  variables are automatically defined.</p>
+  <p>As in many scripting langues, logback configuration files support
+  definition and substitution of properties. Properties can be defined
+  within the configuration file itself, in an external file, in an
+  external resource or even computed and <a
+  href="#definingPropsOnTheFly">defined on the fly</a>.
+  </p>
+
+  <p>Property substitution can occur at any point where a value can be
+  specified. The syntax of property substitution is similar to that of
+  Unix shells. The string between an opening <em>${</em> and closing
+  <em>}</em> is interpreted as a reference to the <em>value</em> of
+  the property.  For property <em>aKey</em>, the string "${aKey}" will
+  be replaced the value held by the <em>aKey</em> property.
+  </p>
+
+  <p>A property can be defined in <em>local scope</em> (the default),
+  in <em>context scope</em>, or in <em>system scope</em>. Local scope
+  is the default.  A property with local scope exists from the point
+  of its definition until the end of configuration. A property with
+  context scope is inserted into the context and lasts as long as the
+  context or until it is cleared.  Once definied, a property in
+  context scope is part of the context. As such, it is available in
+  all logging events, including those sent to remote hosts via
+  serialization. A property with system scope is inserted into the
+  JVM's system properties and lasts as long as the JVM or until it is
+  cleared.
+  </p>
 
-  <h4><a name="propsPartOfContext"
-  href="#propsPartOfContext">Properties are inserted into the context</a></h4>
+  <p>As they often come in handy, the HOSTNAME and CONTEXT_NAME
+  properties are automatically defined and have context scope.</p>
 
-  <p>Note that the values defined via <code><property></code>
-  element are actually inserted into the logger context. In other
-  words, they become properties of the logger context.  Consequently,
-  they will be available in all logging events, including those sent
-  to remote hosts via serialization.</p>
+  <p class="highlight">Properrties are looked up in the the local
+  scope first, in the context scope second, in the system properties
+  scope third, and in the OS environment last.
+  </p>
+
+  <p>During substitution, properties are looked up in the local scope
+  first, in the context scope second, in the system properties scope
+  third, and in the <a
+  href="http://download.oracle.com/javase/tutorial/essential/environment/env.html">OS
+  environment</a> fourth and last.
+  </p>
+
+ 
+  <h4><a name="definingProps" href="#definingProps">Defining
+  properties</a></h4>
+
+  <p>Properties can be defined one at a time in the configuration file
+  itself or loaded wholesale from an external properties file or an
+  external resource.</p>
 
   <p>The next example shows a variable, a.k.a. a substitution
   property, declared at the beginning of the configuration file. It is
@@ -1299,8 +1328,7 @@ public class MyApp3 {
   (logback-examples/src/main/java/chapters/configuration/variableSubstitution1.xml)
   </p>
 
-  <span class="asGroovy" onclick="return
-  asGroovy('variableSubstitution1');">View as .groovy</span>
+  <span class="asGroovy" onclick="return asGroovy('variableSubstitution1');">View as .groovy</span>
   <pre id="variableSubstitution1" class="prettyprint source"><configuration>
 
   <b><property name="USER_HOME" value="/home/sebastien" /></b>
@@ -1317,7 +1345,6 @@ public class MyApp3 {
   </root>
 </configuration></pre>
 
-
   <p>The next example shows the use of a System property to achieve
   the same result. The property is not declared in the configuration
   file, thus logback will look for it in the System properties. Java
@@ -1354,8 +1381,8 @@ public class MyApp3 {
   separate file
   (logback-examples/src/main/java/chapters/configuration/variableSubstitution3.xml)
   </p>
-
-  <pre class="prettyprint source"><configuration>
+  <span class="asGroovy" onclick="return asGroovy('variableSubstitution3');">View as .groovy</span>
+  <pre id="variableSubstitution3" class="prettyprint source"><configuration>
 
   <b><property file="src/main/java/chapters/configuration/variables1.properties" /></b>
 
@@ -1402,6 +1429,41 @@ public class MyApp3 {
    </root>
 </configuration></pre>
 
+
+   <h4>Scopes</h4>
+
+   <p>The <span class="attr">scope</span> attribute of the
+   <code><property></code> element can be used to set the scope of
+   properties. The <span class="attr">scope</span> attribute admit the
+   "local", "context" and "system" strings as possible values.
+   </p>
+
+  <p class="example">Example: Simple Variable substitution
+  (logback-examples/src/main/java/chapters/configuration/variableSubstitution4.xml)
+  </p>
+
+  <span class="asGroovy" onclick="return
+  asGroovy('variableSubstitution4');">View as .groovy</span>
+  <pre id="variableSubstitution4" class="prettyprint source"><configuration>
+
+  <property <b class="big">scope="context"</b> name="nodeId" value="node1" />
+
+  <appender name="FILE" class="ch.qos.logback.core.FileAppender">
+    <b><file>/opt/${noteId}/myApp.log</file></b>
+    <encoder>
+      <pattern>%msg%n</pattern>
+    </encoder>
+  </appender>
+
+  <root level="debug">
+    <appender-ref ref="FILE" />
+  </root>
+</configuration></pre>
+
+   <p>In the above example, given that the <em>nodeId</em> property is
+   defined in the context scope, it will be available in every logging
+   event, even those sent to remote hosts via serialization.</p>
+
    <h4>Nested variable substitution</h4>
 
    <p>Nested variable substitution is also supported. By nested, we
diff --git a/logback-site/src/site/pages/manual/index.html b/logback-site/src/site/pages/manual/index.html
index 66abd44..52c7c13 100644
--- a/logback-site/src/site/pages/manual/index.html
+++ b/logback-site/src/site/pages/manual/index.html
@@ -25,15 +25,6 @@
       
     <h2>The logback manual</h2>
 
-   <div class="highlight">
-    <p>
-      If you wish to print chapters in this document, we recommend
-      that you do so using <a
-      href="http://www.getfirefox.com">Firefox 2+</a>, with <em>Adapt to
-      page size</em> enabled, or <a
-      href="http://www.opera.com">Opera</a>.
-    </p>
-    </div>
 
     <p>The complete logback manual documents the latest version of
     logback framework. In over 150 pages and dozens of concrete
diff --git a/logback-site/src/site/pages/news.html b/logback-site/src/site/pages/news.html
index 53060a6..56b66f8 100644
--- a/logback-site/src/site/pages/news.html
+++ b/logback-site/src/site/pages/news.html
@@ -28,13 +28,32 @@
 
     <hr width="80%" align="center" />
 
-    <h3>... .. , 2011 - Release of version 0.9.31</h3>
+    <h3>October 17th, 2011 - Release of version 1.0.0</h3>
 
     <p>The logback-access module now targets Tomcat 7.x and Jetty 7.x
     & 8.x as its servlet container platforms. This fixes <a
     href="http://jira.qos.ch/browse/LBACCESS-17">LBACCESS-17</a>
     reported by Grzegorz Grzybek.</p>
 
+    <div style="border: 1px solid #F44; background-color: #FED; padding-left: 1ex; padding-right: 1ex;">
+
+    <h4>Breaking change: properties are no longer automatically
+    inserted into the context</h4>
+    
+    <p>Properties now have a scope. Previously, the definition of a
+    property added it to the context. As of version 1.0, properties
+    are local, i.e. transient by default. For further details, please
+    refer to the <a
+    href="manual/configuration.html#variableSubstitution">documentation
+    on properties</a>.</p>
+    </div>
+
+    <p>Environment variables are now looke up during property
+    substitution. This feature was requested in <a
+    href="http://jira.qos.ch/browse/LBCORE-212">LBCORE-212</a> by
+    Alexandre Garnier.
+    </p>
+
     <p>Investigation of <a
     href="http://jira.qos.ch/browse/LBCORE-224">LBCORE-224</a>
     reported by Cesar Alvarez Nunez points to bug in the JVM rather

http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=e643e9086b76e71db67b24c9990f47c9be3dad2f
http://github.com/ceki/logback/commit/e643e9086b76e71db67b24c9990f47c9be3dad2f

commit e643e9086b76e71db67b24c9990f47c9be3dad2f
Merge: e338de8 3356c3e
Author: Ceki Gulcu <ceki at qos.ch>
Date:   Mon Oct 17 08:18:37 2011 -0700

    Merge pull request #30 from imaikazuki/master
    
    Fixed a typo in H2 dialect


http://git.qos.ch/gitweb/?p=logback.git;a=commit;h=3356c3ef1df6890437dc765872a6605942cbb994
http://github.com/ceki/logback/commit/3356c3ef1df6890437dc765872a6605942cbb994

commit 3356c3ef1df6890437dc765872a6605942cbb994
Author: IMAI Kazuki <imaikazuki at gmx.com>
Date:   Mon Oct 17 20:07:29 2011 +0900

    Fix typo.

diff --git a/logback-classic/src/main/java/ch/qos/logback/classic/db/dialect/h2.sql b/logback-classic/src/main/java/ch/qos/logback/classic/db/dialect/h2.sql
index 03ffb89..d1bc3a9 100644
--- a/logback-classic/src/main/java/ch/qos/logback/classic/db/dialect/h2.sql
+++ b/logback-classic/src/main/java/ch/qos/logback/classic/db/dialect/h2.sql
@@ -9,7 +9,7 @@
 # It is intended for H2 databases. 
 
 
-DROP TABLE logging_event_exception IF EXISTSu;
+DROP TABLE logging_event_exception IF EXISTS;
 DROP TABLE logging_event_property IF EXISTS;
 DROP TABLE logging_event IF EXISTS;
 

-----------------------------------------------------------------------

Summary of changes:
 .../java/ch/qos/logback/classic/db/dialect/h2.sql  |    2 +-
 .../logback/classic/joran/action/LoggerAction.java |    2 +-
 .../classic/joran/JoranConfiguratorTest.java       |   20 +++-
 .../java/ch/qos/logback/core/CoreConstants.java    |    1 +
 .../ch/qos/logback/core/joran/action/Action.java   |    2 +
 .../logback/core/joran/action/PropertyAction.java  |   54 +++++++--
 .../logback/core/joran/conditional/IfAction.java   |    2 +-
 .../core/joran/spi/InterpretationContext.java      |   23 +----
 .../java/ch/qos/logback/core/util/ContextUtil.java |   13 ++
 .../ch/qos/logback/core/util/OptionHelper.java     |  120 ++++++++++---------
 logback-site/src/site/pages/download.html          |   17 +++-
 .../src/site/pages/manual/configuration.html       |  114 ++++++++++++++----
 logback-site/src/site/pages/manual/index.html      |    9 --
 logback-site/src/site/pages/news.html              |   21 ++++-
 14 files changed, 272 insertions(+), 128 deletions(-)


hooks/post-receive
-- 
Logback: the generic, reliable, fast and flexible logging framework.


More information about the logback-dev mailing list