loggingservicestackfunq

ServiceStack two Log Implementations console and file / eventlog


Is there a way to have have two implementations of Logger which are triggert ?

I'd like to have one for event log and a console logger.

In my code I only use the registered ILog.

Here the code I currently set my logger

 LogManager.LogFactory = new ServiceStack.Logging.EventLog.EventLogFactory("QAServer", "Foo");

Do I have to create a new Factory as a kind of decorator or is there a simpler way for doing this?


Solution

  • Yes, I believe the simplest way is two create a new Logger and its own LogFactory to resolve it. Its pretty easy to implement the ILog and the ILogFactory interfaces.

    Your new logger can be a thin wrapper of the combined EventLogger and Console Logger.

    Take a look at

    src/ServiceStack.Logging.EventLog/EventLogFactory.cs src/ServiceStack.Interfaces/Logging/Support/Logging/ConsoleLogger.cs

    The Console logger is in the main ServiceStack project and the EventLogger is in the ServiceStack.Logging project.