I'm using Ninject
for my DI and Ninject.Extensions.Logging
(with NLog) for Logger injection. I want to get an instance of Logger in my Main void at the start of the program.
I tried this code:
private static void Main()
{
var logger = new StandardKernel(new NLogModule()).Get<ILogger>();
}
But I get an error Error loading module 'Ninject.Extensions.Logging.NLog2.NLogModule' of type NLogModule
.
How can I get a Logger instance in this method?
Extensions are loaded automatically. You cant load it again manually. Just use
new StandardKernel().Get<ILoggerFactory>().GetCurrentClassLogger();