The simplest solution is to write new ILogWriter
which logs into specified underlying loggers. The source code is here:
public class MultiLogWriter : ILogWriter
{
ILogWriter[] _loggers;
public MultiLogWriter(params ILogWriter[] loggers)
{
if (loggers == null)
throw new ArgumentNullException("loggers");
_loggers = loggers;
}
public LogLevel Level
{
get
{
// return the most informative level
LogLevel level = LogLevel.Off;
foreach (var logger in _loggers)
{
// smaller level means more informative
if (logger.Level < level)
level = logger.Level;
}
return level;
}
set
{
foreach (var logger in _loggers)
{
logger.Level = value;
}
}
}
public void Write(LogLevel level, Type objectType, int objectId, string area, string message, byte[] buffer, int offset, int length)
{
foreach (var logger in _loggers)
{
logger.Write(level, objectType, objectId, area, message, buffer, offset, length);
}
}
public void Write(LogLevel level, Type objectType, int objectId, string area, string message)
{
foreach (var logger in _loggers)
{
logger.Write(level, objectType, objectId, area, message);
}
}
}
You can use it like this:
client.LogWriter = new MultiLogWriter(
new ConsoleLogWriter(LogLevel.Debug),
new FileLogWriter("path", LogLevel.Debug));