I am consuming a Class Library which is built using .NET Core. The Library has only one public class with a constructor accepting ILoggerFactory and another overloaded constructor accepting ILogger. But I am consuming this library in a console app built using .NET Framework 4.7. My console app uses Log4Net for logging. But I need to inject the instance of ILogger or ILoggerFactory so that the class library log's error based on my log.config settings.
I tried as below
ILogger logger = new LoggerFactory().CreateLogger(); var contentManager = new ContentManager(logger);
But I don't know how to pass the Log4Net instance to the LoggerFactory.
private static ILog _log = LogManager.GetLogger(typeof(Program));
static void Main(string[] args)
{
ILogger logger = new LoggerFactory().CreateLogger<ContentManager>();
var contentManager = new ContentManager(logger);
contentManager.Run();
}
I don't find anything getting logged and ContentManager doesn't throw any exceptions. I know that the ILogger instance doesn't know anything about Log4Net from my console app, how I need to pass the Log4Net instance? Need help on this.