Skip to content

Fix appender-ref resolution in complex appenders inside SiftingAppender #938

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vbolshutkin
Copy link

@vbolshutkin vbolshutkin commented May 21, 2025

In my project we had a custom appender that implements AppenderAttachable interface which worked inside a SiftingAppender prior to Logback 1.3.

<appender name="FILE" class="ch.qos.logback.core.FileAppender">
  <file>target/test.log</file>
  ...
</appender>

  
<appender name="SIFT" class="ch.qos.logback.classic.sift.SiftingAppender">
  <discriminator>
    <key>MDC_KEY</key>
    <defaultValue>unknown</defaultValue>
  </discriminator>
  <sift>
    <appender name="CUSTOM-${MDC_KEY}" class="custom.package.CustomAppender">
      <appender-ref ref="FILE" />
    </appender>
  </sift>
</appender>	

In Logback 1.5.18 it's only working in root scope as

    <appender name="CUSTOM" class="custom.package.CustomAppender">
      <appender-ref ref="FILE" />
    </appender>

But when put inside SiftingAppender, the appender-ref behaves as an ImplicitModel and is ignored.

This PR fixes the issue by allowing appender-ref inside appender/sift/appender/appender-ref . Direct usage of appender-ref in sift is still prohibited (as it has no sense)

@vbolshutkin vbolshutkin force-pushed the sift-appender-with-appender-ref branch from 34991e8 to ddf8dd0 Compare May 21, 2025 12:38
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

Successfully merging this pull request may close these issues.

1 participant