From 7417f76086e9df5da4bca1f7303a204668c23710 Mon Sep 17 00:00:00 2001 From: Keivan Beigi Date: Fri, 30 Aug 2013 19:32:30 -0700 Subject: [PATCH] updated logging/loggly --- NzbDrone.Common/Instrumentation/LogTargets.cs | 17 +++-------------- NzbDrone.Common/NzbDrone.Common.csproj | 2 +- NzbDrone.Common/packages.config | 2 +- .../Instrumentation/SetLoggingLevel.cs | 5 ++++- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/NzbDrone.Common/Instrumentation/LogTargets.cs b/NzbDrone.Common/Instrumentation/LogTargets.cs index 1e0e3f419..d63520e80 100644 --- a/NzbDrone.Common/Instrumentation/LogTargets.cs +++ b/NzbDrone.Common/Instrumentation/LogTargets.cs @@ -31,6 +31,8 @@ namespace NzbDrone.Common.Instrumentation RegisterAppFile(appFolderInfo); } + + LogManager.ReconfigExistingLoggers(); } private static void RegisterConsole() @@ -51,9 +53,6 @@ namespace NzbDrone.Common.Instrumentation LogManager.Configuration.AddTarget("console", coloredConsoleTarget); LogManager.Configuration.LoggingRules.Add(loggingRule); - - LogManager.ConfigurationReloaded += (sender, args) => RegisterConsole(); - LogManager.ReconfigExistingLoggers(); } @@ -80,9 +79,6 @@ namespace NzbDrone.Common.Instrumentation LogManager.Configuration.AddTarget("appfile", fileTarget); LogManager.Configuration.LoggingRules.Add(loggingRule); - - LogManager.ConfigurationReloaded += (sender, args) => RegisterAppFile(appFolderInfo); - LogManager.ReconfigExistingLoggers(); } @@ -104,9 +100,6 @@ namespace NzbDrone.Common.Instrumentation LogManager.Configuration.AddTarget("updateFile", fileTarget); LogManager.Configuration.LoggingRules.Add(loggingRule); - - LogManager.ConfigurationReloaded += (sender, args) => RegisterUpdateFile(appFolderInfo); - LogManager.ReconfigExistingLoggers(); } private static void RegisterExceptron() @@ -117,12 +110,10 @@ namespace NzbDrone.Common.Instrumentation LogManager.Configuration.AddTarget("ExceptronTarget", exceptronTarget); LogManager.Configuration.LoggingRules.Add(rule); - LogManager.ConfigurationReloaded += (sender, args) => RegisterExceptron(); - LogManager.ReconfigExistingLoggers(); } - public static void RegisterLoggly() + private static void RegisterLoggly() { var logglyTarger = new LogglyTarget(); @@ -130,8 +121,6 @@ namespace NzbDrone.Common.Instrumentation LogManager.Configuration.AddTarget("LogglyLogger", logglyTarger); LogManager.Configuration.LoggingRules.Add(rule); - LogManager.ConfigurationReloaded += (sender, args) => RegisterLoggly(); - LogManager.ReconfigExistingLoggers(); } } diff --git a/NzbDrone.Common/NzbDrone.Common.csproj b/NzbDrone.Common/NzbDrone.Common.csproj index d379a7a3a..e392e51bb 100644 --- a/NzbDrone.Common/NzbDrone.Common.csproj +++ b/NzbDrone.Common/NzbDrone.Common.csproj @@ -41,7 +41,7 @@ False - ..\packages\loggly-csharp.2.2\lib\Loggly.dll + ..\packages\loggly-csharp.2.3\lib\net35\Loggly.dll diff --git a/NzbDrone.Common/packages.config b/NzbDrone.Common/packages.config index c1ce89767..7252d18f7 100644 --- a/NzbDrone.Common/packages.config +++ b/NzbDrone.Common/packages.config @@ -1,6 +1,6 @@  - + diff --git a/NzbDrone.Core/Instrumentation/SetLoggingLevel.cs b/NzbDrone.Core/Instrumentation/SetLoggingLevel.cs index 251ef6f38..1792a8b3c 100644 --- a/NzbDrone.Core/Instrumentation/SetLoggingLevel.cs +++ b/NzbDrone.Core/Instrumentation/SetLoggingLevel.cs @@ -2,6 +2,7 @@ using System.Linq; using NLog; using NLog.Config; +using NLog.Targets; using NzbDrone.Common.Messaging; using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration.Events; @@ -28,10 +29,12 @@ namespace NzbDrone.Core.Instrumentation var minimumLogLevel = LogLevel.FromString(_configFileProvider.LogLevel); var rules = LogManager.Configuration.LoggingRules; - var rollingFileLogger = rules.Single(s => s.Targets.Any(t => t.Name == "rollingFileLogger")); + var rollingFileLogger = rules.Single(s => s.Targets.Any(t => t is FileTarget)); rollingFileLogger.EnableLoggingForLevel(LogLevel.Trace); SetMinimumLogLevel(rollingFileLogger, minimumLogLevel); + + LogManager.ReconfigExistingLoggers(); } private void SetMinimumLogLevel(LoggingRule rule, LogLevel minimumLogLevel)