[JIRA] Created: (LBCORE-230) System Properties should override properties in logback.xml (not the other way around)

System Properties should override properties in logback.xml (not the other way around) -------------------------------------------------------------------------------------- Key: LBCORE-230 URL: http://jira.qos.ch/browse/LBCORE-230 Project: logback-core Issue Type: Improvement Affects Versions: 0.9.29 Reporter: Eric Sirianni Assignee: Logback dev list Priority: Minor
From the logback configuration guide (http://logback.qos.ch/manual/configuration.html) "The property is not declared in the configuration file, thus logback will look for it in the System properties. Java system properties can be set on the command line. "
I believe the precedence should be reversed. Typically, system properties are used to *override* default values of properties that are specified in XML files or property files (typically checked into source control). Please consider this enhancement. For backwards compatibility you may want to add an option to toggle the precedence ordering. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira

[ http://jira.qos.ch/browse/LBCORE-230?page=com.atlassian.jira.plugin.system.i... ] Ceki Gulcu commented on LBCORE-230: ----------------------------------- Property handling has been expanded considerably in 1.0.0. For full details see http://logback.qos.ch/manual/configuration.html#variableSubstitution . However, the site will be updated when 1.0.0 is released). In the mean time here is an excerpt: BEGIN quote A property can be defined in local scope (the default), in context scope, or in system scope. 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 defined, 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. END quote I think the "nearest scope overrides farther scope" principle is the appropriate one here. Any self-respecting programmer knows and is familiar with it already. Consequently, I don't think it would be wise to reserve the order of precedence nor offer an option to do so. If you can modify the logback configuration file, you can achieve what you are looking for as follows: <if condition='isNull("aProperty")'> <then><property name="aProperty" value="aValue" /></then> </if> If the aProperty system property is not defined, then aProperty will be defined in local scope with the value of your choice.
System Properties should override properties in logback.xml (not the other way around) --------------------------------------------------------------------------------------
Key: LBCORE-230 URL: http://jira.qos.ch/browse/LBCORE-230 Project: logback-core Issue Type: Improvement Affects Versions: 0.9.29 Reporter: Eric Sirianni Assignee: Logback dev list Priority: Minor
From the logback configuration guide (http://logback.qos.ch/manual/configuration.html) "The property is not declared in the configuration file, thus logback will look for it in the System properties. Java system properties can be set on the command line. " I believe the precedence should be reversed. Typically, system properties are used to *override* default values of properties that are specified in XML files or property files (typically checked into source control). Please consider this enhancement. For backwards compatibility you may want to add an option to toggle the precedence ordering.
-- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira

[ http://jira.qos.ch/browse/LBCORE-230?page=com.atlassian.jira.plugin.system.i... ] Eric Sirianni commented on LBCORE-230: -------------------------------------- I guess I see what you're saying from a scoping perspective, but you can look at this another way. With most applications I know, option values specified on the command-line override those specified in config files. By this reasoning, since System properties are specified on the commandline, they should override properties in config files (which are typically checked into source control and embedded in JARs at runtime). See Spring's PropertyPlaceholderConfigurer as an example: Check system properties first, before trying the specified properties. This allows system properties to override any other property source. http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframe...
System Properties should override properties in logback.xml (not the other way around) --------------------------------------------------------------------------------------
Key: LBCORE-230 URL: http://jira.qos.ch/browse/LBCORE-230 Project: logback-core Issue Type: Improvement Affects Versions: 0.9.29 Reporter: Eric Sirianni Assignee: Logback dev list Priority: Minor
From the logback configuration guide (http://logback.qos.ch/manual/configuration.html) "The property is not declared in the configuration file, thus logback will look for it in the System properties. Java system properties can be set on the command line. " I believe the precedence should be reversed. Typically, system properties are used to *override* default values of properties that are specified in XML files or property files (typically checked into source control). Please consider this enhancement. For backwards compatibility you may want to add an option to toggle the precedence ordering.
-- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira

[ http://jira.qos.ch/browse/LBCORE-230?page=com.atlassian.jira.plugin.system.i... ] Ceki Gulcu commented on LBCORE-230: ----------------------------------- Thanks for the link describing PropertyPlaceholderConfigurer. You made a good case for looking up system properties first. Admittedly, I can't as easily make a case for looking up local first. Having said that and on account of simplicity, I would prefer to offer only one order for looking up properties. As I understand it, providing a SYSTEM_PROPERTIES_MODE_OVERRIDE is not a good idea, again on account of simplicity.
System Properties should override properties in logback.xml (not the other way around) --------------------------------------------------------------------------------------
Key: LBCORE-230 URL: http://jira.qos.ch/browse/LBCORE-230 Project: logback-core Issue Type: Improvement Affects Versions: 0.9.29 Reporter: Eric Sirianni Assignee: Logback dev list Priority: Minor
From the logback configuration guide (http://logback.qos.ch/manual/configuration.html) "The property is not declared in the configuration file, thus logback will look for it in the System properties. Java system properties can be set on the command line. " I believe the precedence should be reversed. Typically, system properties are used to *override* default values of properties that are specified in XML files or property files (typically checked into source control). Please consider this enhancement. For backwards compatibility you may want to add an option to toggle the precedence ordering.
-- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira

[ http://jira.qos.ch/browse/LBCORE-230?page=com.atlassian.jira.plugin.system.i... ] Eric Sirianni commented on LBCORE-230: -------------------------------------- I guess I can buy your scoping reasoning from an academic perspective. But these property resolution rules don't seem particularly useful. Take Look at how Ant works for example: "You can also set properties on the command line. This can be done with the -Dproperty=value option, where property is the name of the property, and value is the value for that property. If you specify a property that is also set in the build file (see the property task), **the value specified on the command line will override the value specified in the build file**." http://ant.apache.org/manual/running.html I can't think of any useful reason why you'd want a hardcoded property value in a logback.xml file (local scope as you call it) to override a value for that same property specified in a config file or on the commandline. <property name="USER_HOME" value="/home/sebastien" /> What does that buy me as a developer as opposed to just hardcoding the value "/home/sebastien" everywhere? Is it just defining a named constant for the value? That's not particularly exciting.
System Properties should override properties in logback.xml (not the other way around) --------------------------------------------------------------------------------------
Key: LBCORE-230 URL: http://jira.qos.ch/browse/LBCORE-230 Project: logback-core Issue Type: Improvement Affects Versions: 0.9.29 Reporter: Eric Sirianni Assignee: Logback dev list Priority: Minor
From the logback configuration guide (http://logback.qos.ch/manual/configuration.html) "The property is not declared in the configuration file, thus logback will look for it in the System properties. Java system properties can be set on the command line. " I believe the precedence should be reversed. Typically, system properties are used to *override* default values of properties that are specified in XML files or property files (typically checked into source control). Please consider this enhancement. For backwards compatibility you may want to add an option to toggle the precedence ordering.
-- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
participants (2)
-
Ceki Gulcu (JIRA)
-
Eric Sirianni (JIRA)