I have a .NET Core 3.1 application and I'm setting up the generic host as follows:
static void Main(string[] args)
{
Host.CreateDefaultBuilder(args)
.ConfigureLogging((context, loggingBuilder) =>
{
loggingBuilder.AddConsole();
loggingBuilder.AddDebug();
})
.ConfigureAppConfiguration((context, configurationBuilder) =>
{
// I want to get an ILogger instance here, but how?
configurationBuilder.Add(new CustomConfigurationSource(logger));
})
// some other setup logic
.Build().Run();
}
The problem is that I want to use an ILogger when configuring app configurations. The configuration source I used needs to access a remote server, and also contains some complicated logic for configuration reload, so I want it to be able to write logs for diagnostic and monitoring purposes.
Is there any proper way that this can be done in .NET Core generic host? I would think that this is a pretty legit requirement but can't seem to figure out a way.
The same problem statement also applies to ASP.NET Core applications.
