mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 18:57:39 -07:00
Lots of initialization, configuration clean up.
This commit is contained in:
parent
62013f6f87
commit
51518787d8
74 changed files with 316 additions and 279 deletions
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using NLog.Config;
|
||||
using Ninject;
|
||||
using NLog;
|
||||
using NLog.Targets;
|
||||
|
@ -19,6 +20,15 @@ namespace NzbDrone.Core.Instrumentation
|
|||
_database = database;
|
||||
}
|
||||
|
||||
|
||||
public void Register()
|
||||
{
|
||||
LogManager.Configuration.AddTarget("DbLogger", this);
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, this));
|
||||
|
||||
LogManager.ConfigurationReloaded += (sender, args) => Register();
|
||||
LogConfiguration.Reload();
|
||||
}
|
||||
|
||||
|
||||
protected override void Write(LogEventInfo logEvent)
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
using System.IO;
|
||||
using Ninject;
|
||||
using NLog;
|
||||
using NLog.Config;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Providers;
|
||||
|
||||
namespace NzbDrone.Core.Instrumentation
|
||||
{
|
||||
public class LogConfiguration
|
||||
{
|
||||
private readonly EnviromentProvider _enviromentProvider;
|
||||
private readonly DatabaseTarget _databaseTarget;
|
||||
|
||||
public LogConfiguration(EnviromentProvider enviromentProvider, DatabaseTarget databaseTarget)
|
||||
{
|
||||
_enviromentProvider = enviromentProvider;
|
||||
_databaseTarget = databaseTarget;
|
||||
}
|
||||
|
||||
public void Setup()
|
||||
{
|
||||
if (Common.EnviromentProvider.IsProduction)
|
||||
{
|
||||
LogManager.ThrowExceptions = false;
|
||||
}
|
||||
|
||||
LogManager.Configuration = new XmlLoggingConfiguration(_enviromentProvider.GetNlogConfigPath(), false);
|
||||
|
||||
Common.LogConfiguration.RegisterConsoleLogger(LogLevel.Info, "NzbDrone.Web.MvcApplication");
|
||||
Common.LogConfiguration.RegisterConsoleLogger(LogLevel.Info, "NzbDrone.Core.CentralDispatch");
|
||||
|
||||
LogManager.ConfigurationReloaded += ((s, e) => RegisterDatabaseLogger(_databaseTarget));
|
||||
|
||||
}
|
||||
|
||||
public static void RegisterDatabaseLogger(DatabaseTarget databaseTarget)
|
||||
{
|
||||
LogManager.Configuration.AddTarget("DbLogger", databaseTarget);
|
||||
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, databaseTarget));
|
||||
Reload();
|
||||
}
|
||||
|
||||
public static void Reload()
|
||||
{
|
||||
Common.LogConfiguration.Reload();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue