mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-20 09:04:42 +01:00
fixed multiple log files
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using NLog;
|
||||
using MediaBrowser.Common.Implementations.Logging;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using NLog;
|
||||
using NLog.Config;
|
||||
using NLog.Targets;
|
||||
using System.ComponentModel;
|
||||
@@ -18,14 +20,17 @@ namespace MediaBrowser.ServerApplication.Logging
|
||||
/// </summary>
|
||||
private readonly TaskScheduler _uiThread;
|
||||
|
||||
private readonly ILogManager _logManager;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LogWindow" /> class.
|
||||
/// </summary>
|
||||
/// <param name="kernel">The kernel.</param>
|
||||
public LogWindow()
|
||||
public LogWindow(ILogManager logManager)
|
||||
{
|
||||
InitializeComponent();
|
||||
_uiThread = TaskScheduler.FromCurrentSynchronizationContext();
|
||||
_logManager = logManager;
|
||||
|
||||
Loaded += LogWindow_Loaded;
|
||||
}
|
||||
@@ -42,6 +47,7 @@ namespace MediaBrowser.ServerApplication.Logging
|
||||
Layout = "${longdate}, ${level}, ${logger}, ${message}"
|
||||
};
|
||||
|
||||
((NlogManager)_logManager).RemoveTarget("LogWindowTraceTarget");
|
||||
AddLogTarget(target, "LogWindowTraceTarget");
|
||||
}
|
||||
|
||||
@@ -53,7 +59,7 @@ namespace MediaBrowser.ServerApplication.Logging
|
||||
{
|
||||
base.OnClosing(e);
|
||||
|
||||
RemoveLogTarget("LogWindowTraceTarget");
|
||||
((NlogManager) _logManager).RemoveTarget("LogWindowTraceTarget");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -83,8 +89,6 @@ namespace MediaBrowser.ServerApplication.Logging
|
||||
{
|
||||
var config = NLog.LogManager.Configuration;
|
||||
|
||||
config.RemoveTarget(name);
|
||||
|
||||
target.Name = name;
|
||||
config.AddTarget(name, target);
|
||||
|
||||
@@ -95,19 +99,6 @@ namespace MediaBrowser.ServerApplication.Logging
|
||||
|
||||
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>
|
||||
/// Shuts down.
|
||||
|
||||
@@ -125,7 +125,7 @@ namespace MediaBrowser.ServerApplication
|
||||
// Add our log window if specified
|
||||
if (_configurationManager.Configuration.ShowLogWindow)
|
||||
{
|
||||
Trace.Listeners.Add(new WindowTraceListener(new LogWindow()));
|
||||
Trace.Listeners.Add(new WindowTraceListener(new LogWindow(_logManager)));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user