nreco / logging

Generic file logger for .NET Core (FileLoggerProvider) with minimal dependencies
MIT License
296 stars 60 forks source link

How to get an instance of logger without injection? #7

Closed develax closed 5 years ago

develax commented 5 years ago

In ASP.NET Core 3.0 injection is limited for the Startup constructor:

The most significant change from WebHostBuilder to HostBuilder is in dependency injection (DI). When using HostBuilder, you can only inject IConfiguration and IHostingEnvironment into Startup's constructor.

Is it possible to get an instance of logger without injection in cases like this one?

VitaliyMF commented 5 years ago

Sorry, I cannot understand how this change affects logger providers setup? They are configured in 'ConfigureServices' method, and may be injected only to services configured inside DI container.

develax commented 5 years ago

I think you're right, it's not about NReco.Logging.File. It's about getting access to a service from the Startup constructor which doesn't seem to be possible now.