Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] LOGBACK-1673 and conditional appender configuration #743

Open
edudar opened this issue Nov 29, 2023 · 0 comments
Open

[Question] LOGBACK-1673 and conditional appender configuration #743

edudar opened this issue Nov 29, 2023 · 0 comments

Comments

@edudar
Copy link

edudar commented Nov 29, 2023

In LOGBACK-1673 it was mentioned that

One notable change is that, <if>/<then> elements cannot be embedded within "second phase" elements such as <appender>/<root>/<logger>. The<if>/<then> elements must be located under <configuration> or other "first phase elements", i.e. all elements other than <appender>/<root>/<logger>.

In my case, I have a conditional configuration for an appender. There's a chunk of attributes that I don't include when some property is not set. For example,

<appender name="..." class="...">
    <log>...</log>
    <flushLevel>...</flushLevel>
    <if condition='...'>
        <then>
            <partialSuccess>true</partialSuccess>
            <logbackBatchingSettings>
                <elementCountThreshold>...</elementCountThreshold>
                ...
            </logbackBatchingSettings>
        </then>
    </if>
</appender>

With the sanity check in place, I don't see any way to configure this properly without duplicating appenders: one with these settings and the same one but without, then introducing a logic to include only one of them later. That looks like a lot of duplication and exposing properties/logic that I'd rather have in the <include>d xml.

What's the best way to express a conditional configuration for an appender in 1.3/1.4?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant