On 2023-02-17 03:20, Sébastien Philippon wrote: Hello, I believe the issue is caused by nesting a sift appender inside a conditional <if> tag, as shown in the following example:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<variable name="test" value="true" />
<if condition="isDefined("test")">
<appender name="SIFT" class="ch.qos.logback.classic.sift.SiftingAppender">
<discriminator>
<key>logCategory</key>
<defaultValue>unknown</defaultValue>
</discriminator>
<sift>
<appender name="FILE-${logCategory}" class="ch.qos.logback.core.FileAppender">
<file>logs/category-${logCategory}.log</file>
<encoder>
<pattern>%d [%X\{logCategory}] %msg%n</pattern>
</encoder>
</appender>
</sift>
</appender>
<logger name="com.github.sebphil.Application" level="INFO" additivity="false">
<appender-ref ref="SIFT" />
</logger>
</if>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d [%X\{logCategory}] %msg%n</pattern>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="CONSOLE" />
</root>
</configuration>
No inclusion nor custom Spring Boot tag are required. The startup log reports the following errors: monospaced text 12:09:18,600 |-ERROR in ch.qos.logback.core.joran.action.AppenderAction - Missing attribute [class] in element [sift] near line 12 12:09:18,600 |-ERROR in ch.qos.logback.core.joran.action.AppenderAction - Missing attribute [name] in element [sift] near line 12 12:09:18,749 |-INFO in ch.qos.logback.core.model.processor.conditional.IfModelHandler - Condition [isDefined("test")] evaluated to true on line 6 12:09:18,750 |-INFO in ch.qos.logback.core.model.processor.AppenderModelHandler
- Processing appender named [SIFT] 12:09:18,750 |-INFO in ch.qos.logback.core.model.processor.AppenderModelHandler
- About to instantiate appender of type
[ch.qos.logback.classic.sift.SiftingAppender] 12:09:18,754 |-INFO in ch.qos.logback.core.model.processor.ImplicitModelHandler
- Assuming default type [ch.qos.logback.classic.sift.MDCBasedDiscriminator] for
[discriminator] property 12:09:18,755 |-WARN in ch.qos.logback.core.model.processor.AppenderModelHandler
- Appender named [FILE-logCategory_IS_UNDEFINED] not referenced. Skipping
further processing. 12:09:18,755 |-ERROR in ch.qos.logback.classic.sift.SiftingAppender[SIFT] - AppenderFactory has not been set. Aborting monospaced text
I made a sample project that demonstrates the issue |