From ff5dc6f0ce3f2dc05541ad1440e7e0f8a90dbf64 Mon Sep 17 00:00:00 2001 From: Icer Addis Date: Thu, 2 Jan 2014 19:43:57 -0800 Subject: [PATCH] NLog - Added debugger target --- .../Instrumentation/LogTargets.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/NzbDrone.Common/Instrumentation/LogTargets.cs b/src/NzbDrone.Common/Instrumentation/LogTargets.cs index 4f028aa60..e5d1be2f0 100644 --- a/src/NzbDrone.Common/Instrumentation/LogTargets.cs +++ b/src/NzbDrone.Common/Instrumentation/LogTargets.cs @@ -15,6 +15,11 @@ namespace NzbDrone.Common.Instrumentation LogManager.Configuration = new LoggingConfiguration(); + if (System.Diagnostics.Debugger.IsAttached) + { + RegisterDebugger(); + } + RegisterExceptron(); if (updateApp) @@ -35,6 +40,18 @@ namespace NzbDrone.Common.Instrumentation LogManager.ReconfigExistingLoggers(); } + private static void RegisterDebugger() + { + DebuggerTarget target = new DebuggerTarget(); + target.Name = "debuggerLogger"; + target.Layout = "[${level}] [${threadid}] ${logger}: ${message} ${onexception:inner=${newline}${newline}${exception:format=ToString}${newline}}"; + + var loggingRule = new LoggingRule("*", LogLevel.Trace, target); + LogManager.Configuration.AddTarget("console", target); + LogManager.Configuration.LoggingRules.Add(loggingRule); + } + + private static void RegisterConsole() { var level = LogLevel.Trace;