From a110f9d060e42208841dea1898fd800a138bd8ec Mon Sep 17 00:00:00 2001 From: JustArchi Date: Sat, 8 Sep 2018 02:23:23 +0200 Subject: [PATCH] Set kestrel logging globally User is free to override it if he wants to --- ArchiSteamFarm/IPC/ArchiKestrel.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ArchiSteamFarm/IPC/ArchiKestrel.cs b/ArchiSteamFarm/IPC/ArchiKestrel.cs index 8d2deaafe..188449fcf 100644 --- a/ArchiSteamFarm/IPC/ArchiKestrel.cs +++ b/ArchiSteamFarm/IPC/ArchiKestrel.cs @@ -67,6 +67,10 @@ namespace ArchiSteamFarm.IPC { // Check if custom config is available string absoluteConfigDirectory = Path.Combine(Directory.GetCurrentDirectory(), SharedInfo.ConfigDirectory); + // Firstly initialize settings that user is free to override + builder.ConfigureLogging(logging => logging.SetMinimumLevel(Debugging.IsUserDebugging ? LogLevel.Trace : LogLevel.Warning)); + + // Now conditionally initialize settings that are not possible to override if (File.Exists(Path.Combine(absoluteConfigDirectory, ConfigurationFile))) { // Set up custom config to be used builder.UseConfiguration(new ConfigurationBuilder().SetBasePath(absoluteConfigDirectory).AddJsonFile(ConfigurationFile, false, true).Build()); @@ -75,9 +79,8 @@ namespace ArchiSteamFarm.IPC { builder.UseKestrel((builderContext, options) => options.Configure(builderContext.Configuration.GetSection("Kestrel"))); builder.ConfigureLogging((hostingContext, logging) => logging.AddConfiguration(hostingContext.Configuration.GetSection("Logging"))); } else { - // Use ASF defaults for Kestrel and Logging + // Use ASF defaults for Kestrel builder.UseKestrel(options => options.ListenLocalhost(1242)); - builder.ConfigureLogging(logging => logging.SetMinimumLevel(Debugging.IsUserDebugging ? LogLevel.Trace : LogLevel.Warning)); } // Enable NLog integration for logging