|
@@ -1,4 +1,6 @@
|
|
-using NLog;
|
|
|
|
|
|
+using MediaBrowser.Common.Implementations.Logging;
|
|
|
|
+using MediaBrowser.Model.Logging;
|
|
|
|
+using NLog;
|
|
using NLog.Config;
|
|
using NLog.Config;
|
|
using NLog.Targets;
|
|
using NLog.Targets;
|
|
using System.ComponentModel;
|
|
using System.ComponentModel;
|
|
@@ -18,14 +20,17 @@ namespace MediaBrowser.ServerApplication.Logging
|
|
/// </summary>
|
|
/// </summary>
|
|
private readonly TaskScheduler _uiThread;
|
|
private readonly TaskScheduler _uiThread;
|
|
|
|
|
|
|
|
+ private readonly ILogManager _logManager;
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="LogWindow" /> class.
|
|
/// Initializes a new instance of the <see cref="LogWindow" /> class.
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="kernel">The kernel.</param>
|
|
/// <param name="kernel">The kernel.</param>
|
|
- public LogWindow()
|
|
|
|
|
|
+ public LogWindow(ILogManager logManager)
|
|
{
|
|
{
|
|
InitializeComponent();
|
|
InitializeComponent();
|
|
_uiThread = TaskScheduler.FromCurrentSynchronizationContext();
|
|
_uiThread = TaskScheduler.FromCurrentSynchronizationContext();
|
|
|
|
+ _logManager = logManager;
|
|
|
|
|
|
Loaded += LogWindow_Loaded;
|
|
Loaded += LogWindow_Loaded;
|
|
}
|
|
}
|
|
@@ -42,6 +47,7 @@ namespace MediaBrowser.ServerApplication.Logging
|
|
Layout = "${longdate}, ${level}, ${logger}, ${message}"
|
|
Layout = "${longdate}, ${level}, ${logger}, ${message}"
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ ((NlogManager)_logManager).RemoveTarget("LogWindowTraceTarget");
|
|
AddLogTarget(target, "LogWindowTraceTarget");
|
|
AddLogTarget(target, "LogWindowTraceTarget");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -53,7 +59,7 @@ namespace MediaBrowser.ServerApplication.Logging
|
|
{
|
|
{
|
|
base.OnClosing(e);
|
|
base.OnClosing(e);
|
|
|
|
|
|
- RemoveLogTarget("LogWindowTraceTarget");
|
|
|
|
|
|
+ ((NlogManager) _logManager).RemoveTarget("LogWindowTraceTarget");
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -83,8 +89,6 @@ namespace MediaBrowser.ServerApplication.Logging
|
|
{
|
|
{
|
|
var config = NLog.LogManager.Configuration;
|
|
var config = NLog.LogManager.Configuration;
|
|
|
|
|
|
- config.RemoveTarget(name);
|
|
|
|
-
|
|
|
|
target.Name = name;
|
|
target.Name = name;
|
|
config.AddTarget(name, target);
|
|
config.AddTarget(name, target);
|
|
|
|
|
|
@@ -95,19 +99,6 @@ namespace MediaBrowser.ServerApplication.Logging
|
|
|
|
|
|
NLog.LogManager.Configuration = config;
|
|
NLog.LogManager.Configuration = config;
|
|
}
|
|
}
|
|
-
|
|
|
|
- /// <summary>
|
|
|
|
- /// Removes the log target.
|
|
|
|
- /// </summary>
|
|
|
|
- /// <param name="name">The name.</param>
|
|
|
|
- private void RemoveLogTarget(string name)
|
|
|
|
- {
|
|
|
|
- var config = NLog.LogManager.Configuration;
|
|
|
|
-
|
|
|
|
- config.RemoveTarget(name);
|
|
|
|
-
|
|
|
|
- NLog.LogManager.Configuration = config;
|
|
|
|
- }
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Shuts down.
|
|
/// Shuts down.
|