aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common.Implementations/Logging/NlogManager.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2013-09-20 21:04:14 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2013-09-20 21:04:14 -0400
commit2e511fba839e86d9393e5eeb10795f1b0aed7ce0 (patch)
treed82481b8352ae2f088cbe902cc7fc222b8b0a0ed /MediaBrowser.Common.Implementations/Logging/NlogManager.cs
parentb5615cb233923f8424a40af009101a901f30f591 (diff)
support run as service
Diffstat (limited to 'MediaBrowser.Common.Implementations/Logging/NlogManager.cs')
-rw-r--r--MediaBrowser.Common.Implementations/Logging/NlogManager.cs41
1 files changed, 39 insertions, 2 deletions
diff --git a/MediaBrowser.Common.Implementations/Logging/NlogManager.cs b/MediaBrowser.Common.Implementations/Logging/NlogManager.cs
index cd3dc5c16..109e85d80 100644
--- a/MediaBrowser.Common.Implementations/Logging/NlogManager.cs
+++ b/MediaBrowser.Common.Implementations/Logging/NlogManager.cs
@@ -1,10 +1,10 @@
-using System.Linq;
-using MediaBrowser.Model.Logging;
+using MediaBrowser.Model.Logging;
using NLog;
using NLog.Config;
using NLog.Targets;
using System;
using System.IO;
+using System.Linq;
using System.Threading.Tasks;
namespace MediaBrowser.Common.Implementations.Logging
@@ -45,6 +45,41 @@ namespace MediaBrowser.Common.Implementations.Logging
LogFilePrefix = logFileNamePrefix;
}
+ private LogSeverity _severity = LogSeverity.Debug;
+ public LogSeverity LogSeverity
+ {
+ get
+ {
+ return _severity;
+ }
+ set
+ {
+ var changed = _severity != value;
+
+ _severity = value;
+
+ if (changed)
+ {
+ UpdateLogLevel(value);
+ }
+ }
+ }
+
+ private void UpdateLogLevel(LogSeverity newLevel)
+ {
+ var level = GetLogLevel(newLevel);
+
+ var rules = LogManager.Configuration.LoggingRules;
+
+ foreach (var rule in rules)
+ {
+ if (!rule.IsLoggingEnabledForLevel(level))
+ {
+ rule.EnableLoggingForLevel(level);
+ }
+ }
+ }
+
/// <summary>
/// Adds the file target.
/// </summary>
@@ -154,6 +189,8 @@ namespace MediaBrowser.Common.Implementations.Logging
AddFileTarget(LogFilePath, level);
+ LogSeverity = level;
+
if (LoggerLoaded != null)
{
Task.Run(() =>