I have a solution with multiple .EXEs, WCF services, Windows Services, etc... I want to use SeriLog for logging in all of these but I don't want these projects to add SeriLog directly. I want them to depend upon a Frameword dll that has various things like email, configuration, etc... To that end I want to create a wrapper class in this Framework dll. All my projects can then just refer to this wrapper class (part of a dll they are already referring to). So, I want something like:
public class TheLogger : Serilog.ILogger
{
private static readonly TheLogger instance = new TheLogger();
/// <summary>
/// Creates the singleton instance of TheLogger class.
/// </summary>
static TheLogger()
{
// Configure SeriLog
var log = new LoggerConfiguration().WriteTo.Console().CreateLogger();
Log.logger = log;
// Need to point the instance to SeriLog's implementation ????
instance = (TheLogger)log;
}
private TheLogger()
{
}
/// <summary>
/// Returns the singleton instance of TheLogger class.
/// </summary>
public static TheLogger Instance
{
get
{
return instance;
}
}
}
And then, I would want the other projects to use syntax like
TheLogger.Instance.Information("I am here");
But obviously, TheLogger doesn't have the implementation provided by the SeriLog's Log.logger static logger. And without the reference to SeriLog I can't refer to Log.logger. To summarize, the question is how do I leverage SeriLog's Log.logger but wrap it in my own class?