From 247a40fa614241b52babb29bc03b0afd9a9031f9 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 8 Jan 2014 23:44:51 -0500 Subject: add console logging during startup --- .../Logging/NlogManager.cs | 23 +++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'MediaBrowser.Common.Implementations/Logging') diff --git a/MediaBrowser.Common.Implementations/Logging/NlogManager.cs b/MediaBrowser.Common.Implementations/Logging/NlogManager.cs index fb7fd1698e..40dc380ea8 100644 --- a/MediaBrowser.Common.Implementations/Logging/NlogManager.cs +++ b/MediaBrowser.Common.Implementations/Logging/NlogManager.cs @@ -187,7 +187,7 @@ namespace MediaBrowser.Common.Implementations.Logging LogFilePath = Path.Combine(LogDirectory, LogFilePrefix + "-" + decimal.Round(DateTime.Now.Ticks / 10000000) + ".log"); Directory.CreateDirectory(Path.GetDirectoryName(LogFilePath)); - + AddFileTarget(LogFilePath, level); LogSeverity = level; @@ -212,5 +212,26 @@ namespace MediaBrowser.Common.Implementations.Logging { LogManager.Flush(); } + + + public void AddConsoleOutput() + { + var target = new ConsoleTarget() + { + Layout = "${level}, ${logger}, ${message}", + Error = false + }; + + RemoveTarget("ConsoleTarget"); + + target.Name = "ConsoleTarget"; + + AddLogTarget(target, LogSeverity); + } + + public void RemoveConsoleOutput() + { + RemoveTarget("ConsoleTarget"); + } } } -- cgit v1.2.3