
Hi I would like to be able to only enable certain appenders if a given condition is true (based on e.g. a property file). Is there a simpe way to do this with logback.xml or must I configure Joran myself? Thanks -- Thorbjørn Ravn Andersen "...plus... Tubular Bells!"

Joran does not come with conditional support. However, it could be added. Assuming the necessary support was there, how would the conditional segments look like? Thorbjørn Ravn Andersen wrote:
Hi
I would like to be able to only enable certain appenders if a given condition is true (based on e.g. a property file).
Is there a simpe way to do this with logback.xml or must I configure Joran myself?
Thanks
-- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch

Ceki Gulcu skrev den 04-06-2009 12:52:
Joran does not come with conditional support. However, it could be added. Assuming the necessary support was there, how would the conditional segments look like?
Well, I would either think an <if test="..."> xml snippet </if> construction, where the snippet was only evaluated if the test was true, or <appender-ref ref="..." if="${enable.appender.FOO}"> would be nice. In any case it would be nice if this mechanism could be used to avoid constructing unreferenced appenders, as I understand that they are created when seen in the configuration process. (Oh, and I found that changes in FileAppender options (changing true to false, etc) are not picked up when reloading default configuration over JMX). -- Thorbjørn Ravn Andersen "...plus... Tubular Bells!"

Hello all, Conditions sounds good. Now I use two different files for standart and debug mode of application and specify usage in start script using -Dlogback.configurationFile. But conditional constructions will allow to make it more simple. Best regards, Aleskey Didik. * * Thorbjørn Ravn Andersen ?????:
Ceki Gulcu skrev den 04-06-2009 12:52:
Joran does not come with conditional support. However, it could be added. Assuming the necessary support was there, how would the conditional segments look like?
Well, I would either think an
<if test="..."> xml snippet </if>
construction, where the snippet was only evaluated if the test was true, or
<appender-ref ref="..." if="${enable.appender.FOO}">
would be nice. In any case it would be nice if this mechanism could be used to avoid constructing unreferenced appenders, as I understand that they are created when seen in the configuration process.
(Oh, and I found that changes in FileAppender options (changing true to false, etc) are not picked up when reloading default configuration over JMX).

Thorbjørn Ravn Andersen wrote:
Ceki Gulcu skrev den 04-06-2009 12:52:
Joran does not come with conditional support. However, it could be added. Assuming the necessary support was there, how would the conditional segments look like?
Well, I would either think an
<if test="..."> xml snippet </if>
construction, where the snippet was only evaluated if the test was true, or
<appender-ref ref="..." if="${enable.appender.FOO}">
would be nice.
The implementation of the <if test="..."> nested xml </if> variant would be quite different then the implementation of <appender-ref ref="..." if="..."> The former would require broader changes than the latter variant. I suggest that you enter a jira issue requesting either or both features. I'll implement the first variant (which is more general) and if that fails, fallback on the second.
(Oh, and I found that changes in FileAppender options (changing true to false, etc) are not picked up when reloading default configuration over JMX).
What do you mean? -- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch
participants (3)
-
Aleksey Didik
-
Ceki Gulcu
-
Thorbjørn Ravn Andersen