Is it possible to get an ILogger inside Program.cs Main method? I want to pass it on to a service that's created inside that method.
I've only found this on SO How do I write logs from within Startup.cs , but that's logging within Startup.cs.
Is it possible to get an ILogger inside Program.cs Main method? I want to pass it on to a service that's created inside that method.
I've only found this on SO How do I write logs from within Startup.cs , but that's logging within Startup.cs.
This is how I managed to get the
ILogger
interface configured inStartup.cs
(in my case Log4Net) working when insideProgram.cs
:using Microsoft.Extensions.DependencyInjection;
so that the generic type inGetService
works as expected.Accidentally stumbled upon the answer after googling a bit more.
Kudos to https://askguanyu.wordpress.com/2016/09/26/net-core-101-e06-net-core-logging/