I'm in the process of writing a custom ConfigurationSource
/ConfigurationProvider
to access configuration stored in a Spring Cloud Config Server.
I want to be able to write errors and trace information to the log but so far haven't found a way to get an ILogger<T>
this early in the application lifecycle.
I know about this answer but LoggerFactory.AddConsole
is deprecated. The only implementation of the proposed alternative ILoggingBuilder
is internal. Copying the really simple implementation wouldn't help me either because I don't have access to an IServiceProvider
.
Any other ideas?
Update
Not much to it but that would be the outline to my problem. It's an extract from Program.CreateWebHostBuilder(string[])
of an ASP.NET Core web app.
IWebHostBuilder builder = WebHost.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((webHostBuilderContext, configurationBuilder) =>
{
ILogger<MyCustomConfigSource> logger = ???;
configurationBuilder.Add(new MyCustomConfigSource(logger));
});