Skip to content

Logging :: Implementations :: FallbackLogger

mkloubert edited this page May 14, 2014 · 1 revision

The FallbackLogger class defines a main logger.

Additional you can add one or more fallbacks that are called if previous logging fails.

The execution is done in the same thread.

// this logger is tried to be invoked first
var mainLogger = new MyFileLogger();


var logger = new FallbackLogger(mainLogger);


// fallback #1
var eventLogger = new MyEventLogger();
// second fallback
var consoleLogger = new ConsoleLogger();


// is only called if 'mainLogger' failes
logger.Add(eventLogger);
// is only called if previous logger ('eventLogger') failes
logger.Add(consoleLogger);


allLoggers.Log("That should be logged in DEBUG mode only.",
               LoggerFacadeCategories.Debug | LoggerFacadeCategories.Information);