Re-use any existing ReloadableLogger

It's possible that consumers have already set up a bootstrap logger themselves before Umbraco had a chance too, if that's the case we just reload it.
This commit is contained in:
Vitor Rodrigues
2022-10-27 11:42:01 +02:00
committed by Sebastiaan Janssen
parent d4c921264d
commit 7ad1e638e6

View File

@@ -96,11 +96,18 @@ public static class ServiceCollectionExtensions
// Bootstrap logger setup
///////////////////////////////////////////////
LoggerConfiguration serilogConfig = new LoggerConfiguration()
Func<LoggerConfiguration, LoggerConfiguration> serilogConfig = cfg => cfg
.MinimalConfiguration(hostEnvironment, loggingConfig, umbracoFileConfiguration)
.ReadFrom.Configuration(configuration);
Log.Logger = serilogConfig.CreateBootstrapLogger();
if (Log.Logger is ReloadableLogger reloadableLogger)
{
reloadableLogger.Reload(serilogConfig);
}
else
{
Log.Logger = serilogConfig(new LoggerConfiguration()).CreateBootstrapLogger();
}
///////////////////////////////////////////////
// Runtime logger setup