I\'ve configured my console application\'s Main
like so
var services = new ServiceCollection()
.AddLogging(logging => logging.Add
ILogger
is no longer registered by default but ILogger
is. If you still want to use ILogger you can registered it manually with the following (Startup.cs):
public void ConfigureServices(IServiceCollection services)
{
var serviceProvider = services.BuildServiceProvider();
var logger = serviceProvider.GetService>();
services.AddSingleton(typeof(ILogger), logger);
...
}
Where AnyClass can be something generic, such as:
public class ApplicationLogs
{
}
So:
public void ConfigureServices(IServiceCollection services)
{
var serviceProvider = services.BuildServiceProvider();
var logger = serviceProvider.GetService>();
services.AddSingleton(typeof(ILogger), logger);
...
}
ILogger will now resolve via constructor injection