[logback-user] Is it possible to set a defined property with a new value?
Ceki Gulcu
ceki at qos.ch
Thu Apr 21 22:40:20 CEST 2011
On 21.04.2011 14:45, LogbackUser wrote:
>
> Below is something what I want to achieve
>
> <insertFromJNDI env-entry-name="LogLocation" as="LOG_LOCATION"/>
>
> <if condition='property("LOG_LOCATION").equals("")'>
> <then>
> <!--how do I reset the LOG_LOCATION property here-->
> </then>
> </if>
>
> Basically I want to set the LOG_LOCATION property to be set to a default
> value if the JNDI entry is not present. What currently happens is - if the
> JNDI property is not defined it assigns the property named "LOG_LOCATION" to
> "LOG_LOCATION_IS_UNDEFINED".
>
> Thank you in advance.
Hello,
You have several options available to you.
You can either set the default value for LOG_LOCATION if it is
undefined. Here is how:
<insertFromJNDI env-entry-name="LogLocation" as="LOG_LOCATION"/>
<if condition='property("LOG_LOCATION").equals("")'>
<then>
<property name="LOG_LOCATION" value="some default" />
</then>
</if>
You can also make use of the Default substitution feature [1]:
<insertFromJNDI env-entry-name="LogLocation" as="LOG_LOCATION"/>
<appender class="ch.qos.logback.core.FileAppender>
<file>${LOG_LOCATION:-some default}/blah.log</file>
....
</appender>
HTH,
[1]
http://logback.qos.ch/manual/configuration.html#defaultValuesForVariables
--
Ceki
More information about the Logback-user
mailing list