Hi,

I'm trying to remove redundant logback config files by using janino's
conditional processing.

Below is the conditional logic which I had added within the configuration
tag (along with the appender details)

<root level="INFO">
    <appender-ref ref="ROLLING" />
    <!-- use console appender on windows, email appender on linux -->
    <if condition='property("os.name").contains("win")'>
        <then>
            <appender-ref ref="CONSOLE" />
        </then>
        <else>
            <appender-ref ref="EMAIL" />
        </else>
    </if>
</root>

but this throws the below errors when logback is initialized

12:30:34,877 |-ERROR in
ch.qos.logback.core.joran.spi.Interpreter@90:55 - no applicable action
for [if], current pattern is [[configuration][root][if]]
12:30:34,877 |-ERROR in
ch.qos.logback.core.joran.spi.Interpreter@91:10 - no applicable action
for [then], current pattern is [[configuration][root][if][then]]
12:30:34,877 |-ERROR in
ch.qos.logback.core.joran.spi.Interpreter@92:35 - no applicable action
for [appender-ref], current pattern is
[[configuration][root][if][then][appender-ref]]
12:30:34,877 |-ERROR in
ch.qos.logback.core.joran.spi.Interpreter@94:10 - no applicable action
for [else], current pattern is [[configuration][root][if][else]]
12:30:34,877 |-ERROR in
ch.qos.logback.core.joran.spi.Interpreter@95:35 - no applicable action
for [appender-ref], current pattern is
[[configuration][root][if][else][appender-ref]]

The configuration works fine if I remove the conditional logic and use
something like

<root level="INFO">
    <appender-ref ref="ROLLING" />
    <appender-ref ref="CONSOLE" />
    <appender-ref ref="EMAIL" />
</root>

I have already added janino as a Maven dependency. How can I configure this
correctly in such a way that the CONSOLE appender is used only on Windows
and the EMAIL appender everywhere else?


Thanks,

Aneesh
_______________________________________________
Logback-user mailing list
[email protected]
http://mailman.qos.ch/mailman/listinfo/logback-user

Reply via email to