From fd563b5fbfb71112c2af861e0eb50987aa2228eb Mon Sep 17 00:00:00 2001
From: Qstick <qstick@gmail.com>
Date: Tue, 10 Sep 2019 21:50:45 -0400
Subject: [PATCH] New: Register a null target for sentry logs

Co-Authored-By: Mark McDowall <markus101@users.noreply.github.com>
---
 src/NzbDrone.Test.Common/LoggingTest.cs | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/NzbDrone.Test.Common/LoggingTest.cs b/src/NzbDrone.Test.Common/LoggingTest.cs
index 26f0a915d..13706633d 100644
--- a/src/NzbDrone.Test.Common/LoggingTest.cs
+++ b/src/NzbDrone.Test.Common/LoggingTest.cs
@@ -26,6 +26,8 @@ namespace NzbDrone.Test.Common
                 var logOutput = TestLogOutput.Console;
                 Enum.TryParse<TestLogOutput>(Environment.GetEnvironmentVariable("LIDARR_TESTS_LOG_OUTPUT"), out logOutput);
 
+                RegisterSentryLogger();
+
                 switch (logOutput)
                 {
                     case TestLogOutput.Console:
@@ -68,6 +70,13 @@ namespace NzbDrone.Test.Common
             LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Trace, fileTarget));
         }
 
+        private static void RegisterSentryLogger()
+        {
+            // Register a null target for sentry logs, so they aren't caught by other loggers.
+            var loggingRuleSentry = new LoggingRule("Sentry", LogLevel.Debug, new NullTarget()) { Final = true };
+            LogManager.Configuration.LoggingRules.Insert(0, loggingRuleSentry);
+        }
+
         private static void RegisterExceptionVerification()
         {
             var exceptionVerification = new ExceptionVerification();