diff --git a/ArchiSteamFarm/Logging.cs b/ArchiSteamFarm/Logging.cs index 6c7be6504..e1d4cd5ec 100644 --- a/ArchiSteamFarm/Logging.cs +++ b/ArchiSteamFarm/Logging.cs @@ -80,20 +80,31 @@ namespace ArchiSteamFarm { } internal static void InitHistoryLogger() { - if (IsUsingCustomConfiguration || (LogManager.Configuration == null)) { + if (LogManager.Configuration == null) { return; } - // TODO: We could use some nice HTML layout for this - HistoryTarget historyTarget = new HistoryTarget("History") { - Layout = GeneralLayout, - MaxCount = 20 - }; + HistoryTarget historyTarget; - LogManager.Configuration.AddTarget(historyTarget); - LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, historyTarget)); + if (IsUsingCustomConfiguration) { + historyTarget = LogManager.Configuration.AllTargets.OfType().FirstOrDefault(); + + if (historyTarget == null) { + return; + } + } else { + // TODO: We could use some nice HTML layout for this + historyTarget = new HistoryTarget("History") { + Layout = GeneralLayout, + MaxCount = 20 + }; + + LogManager.Configuration.AddTarget(historyTarget); + LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, historyTarget)); + + LogManager.ReconfigExistingLoggers(); + } - LogManager.ReconfigExistingLoggers(); IPC.OnNewHistoryTarget(historyTarget); } @@ -163,4 +174,4 @@ namespace ArchiSteamFarm { } } } -} \ No newline at end of file +}