mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-22 00:35:26 +03:00
support run as service
This commit is contained in:
@@ -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(() =>
|
||||
|
||||
Reference in New Issue
Block a user