[logback-user] Custom Appender Substitute Logger issue

Jared Graber Jared.Graber at mindspark.com
Mon Oct 7 19:17:34 CEST 2013

I have a custom appender that needs a backup logger in case there is a network issue or some other common error (see sample code below).
I'm running into the error indicating that my backup logger will not work because it was created during the default configuration phase.  It directed me towards the docs on substituteLogger which suggested to set up my appender in a separate file and then configure it after the default configuration phase.
Are there any other options?

Is there a better way to deal w/ the backup logger?  Is there a more general purpose way to do this?  Maybe a composite appender?

Any help would be appreciated.

My class basically looks like this:

public class FooAppender extends AppenderBase<ILoggingEvent> {
                private final Logger LOGGER = LoggerFactory.getLogger(FooAppender.class);
private Layout<ILoggingEvent> layout;
//A bunch of configuration and constants.
//Some setter methods

Public void append(final ILoggingEvent event) {
String message = this.layout.doLayout(event); //The thrift client will encode it as UTF-8 for us.
                try {
                                //log the event
                } catch (SpecificException e) {

Sample logback.xml snippet:
    <appender name="foo" class="FooAppender">
<!-more configuration -->
    <appender name="fooBackup" class="ch.qos.logback.core.FileAppender">

<logger name="FooAppenderTester" level="INFO" additivity="false">
                <appender-ref ref="foo"/>
<logger name="FooAppender" level="INFO" additivity="false">
                <appender-ref ref="fooBackup"/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20131007/a84d41e3/attachment.html>

More information about the Logback-user mailing list