In ASP.NET 5.0, we can now define a factory method for controlling the activation of the Startup class.
In the demo example provided by Microsoft, they create a logger and then pass this into the Startup class:
public class Program
{
public static async Task Main(string[] args)
{
var logger = CreateLogger(); // <--- HERE !!!!
var host = Host.CreateDefaultBuilder()
.ConfigureWebHost(builder =>
{
builder.UseStartup(context => new Startup(logger)); // Logger passed into the ctor
})
.Build();
await host.RunAsync();
}
}
However, I am not sure how the author created the Logger (ie. the code in that method), which hopefully will be an ILogger.