I am using NLog as logging provider in my solution, but some projects have migrated to Microsoft.Extensions.Logging. We're still evaluating if migrating also the rest of the code to this, but in the meantime we need somehow to convert our NLog.ILogger
instance to Microsoft.Extensions.Logging.ILogger<T>
instance.
I know it can be quite easily done using NLog.Extensions.Logging package, adding NLog as provider:
ILoggerFactory factory = LoggerFactory.Create(builder =>
{
builder.AddNLog();
});
return factory.CreateLogger<MyClass>();
but this approach actually creates an NLog provider using the static NLog stuff, not the NLog.ILogger
instance I receive from other code parts.
So, is there a way to use this NLog.ILogger
instance in this conversion? Am I missing something?