[logback-dev] [JIRA] Commented: (LBCORE-230) System Properties should override properties in logback.xml (not the other way around)
Ceki Gulcu (JIRA)
noreply-jira at qos.ch
Thu Oct 27 22:20:13 CEST 2011
[ http://jira.qos.ch/browse/LBCORE-230?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12235#action_12235 ]
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
More information about the logback-dev
mailing list