Reputation: 4128
I'm creating a custom logback appender which needs to fall back to another appender in certain situations (typically a failure). What I'm trying to achieve is this :
<configuration>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{HH:mm:ss.SSS} - %msg%n</Pattern>
</layout>
</appender>
<appender name="MYAPPENDER" class="my.appender.class">
<appender-ref ref="CONSOLE" />
</appender>
<root level="trace">
<appender-ref ref="MYAPPENDER" />
</root>
</configuration>
Now, I've implemented AppenderAttachable in MYAPPENDER and it does seem to work, - the frameworks sets a reference to CONSOLE appender during initialization and I use it all right.
Is it a standard way to go about the case? Is there an alternative to this approach? Ideas?
Upvotes: 1
Views: 1319
Reputation: 27460
Yes, support for AppenderAttachable
is likely to be preserved in the future.
Upvotes: 1
Reputation: 27460
Have you printed logback's internal status messages? What does StatusManager say?
Update: After the changes made to the question my answer no longer makes any sense. I am leaving it nonetheless because as an investigation tool about logback, logback's internal status messages can be very helpful.
Upvotes: 0