From d61976251ea279913a6c626d43a0b591b842ace1 Mon Sep 17 00:00:00 2001 From: Keivan Beigi Date: Thu, 5 Jan 2017 10:46:16 -0800 Subject: [PATCH] Apparently RemoveTarget doesn't do what you expect it to do. --- src/NzbDrone.Common/Instrumentation/NzbDroneLogger.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/NzbDrone.Common/Instrumentation/NzbDroneLogger.cs b/src/NzbDrone.Common/Instrumentation/NzbDroneLogger.cs index 75b9c8739..7a05776ae 100644 --- a/src/NzbDrone.Common/Instrumentation/NzbDroneLogger.cs +++ b/src/NzbDrone.Common/Instrumentation/NzbDroneLogger.cs @@ -1,6 +1,7 @@ using System; using System.Diagnostics; using System.IO; +using System.Linq; using LogentriesNLog; using NLog; using NLog.Config; @@ -61,7 +62,13 @@ namespace NzbDrone.Common.Instrumentation public static void UnRegisterRemoteLoggers() { - LogManager.Configuration.RemoveTarget("sentryTarget"); + var sentryRules = LogManager.Configuration.LoggingRules.Where(r => r.Targets.Any(t => t.Name == "sentryTarget")); + + foreach (var rules in sentryRules) + { + rules.Targets.Clear(); + } + LogManager.ReconfigExistingLoggers(); } @@ -103,7 +110,7 @@ namespace NzbDrone.Common.Instrumentation }; var loggingRule = new LoggingRule("*", updateClient ? LogLevel.Trace : LogLevel.Error, target); - LogManager.Configuration.AddTarget("logentries", target); + LogManager.Configuration.AddTarget("sentryTarget", target); LogManager.Configuration.LoggingRules.Add(loggingRule); }