Skip to content

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