1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-11 05:22:44 +01:00
Radarr/NzbDrone.Core/Instrumentation/LogConfiguration.cs

35 lines
1.2 KiB
C#

using System.IO;
using Ninject;
using NLog;
using NLog.Config;
using NzbDrone.Common;
using NzbDrone.Core.Providers;
namespace NzbDrone.Core.Instrumentation
{
public static class LogConfiguration
{
public static void Setup()
{
if (Common.EnviromentProvider.IsProduction)
{
LogManager.ThrowExceptions = false;
}
LogManager.Configuration = new XmlLoggingConfiguration(Path.Combine(new EnviromentProvider().WebRoot, "log.config"), false);
Common.LogConfiguration.RegisterConsoleLogger(LogLevel.Info, "NzbDrone.Web.MvcApplication");
Common.LogConfiguration.RegisterConsoleLogger(LogLevel.Info, "NzbDrone.Core.CentralDispatch");
LogManager.ConfigurationReloaded += ((s, e) => RegisterDatabaseLogger(CentralDispatch.NinjectKernel.Get<DatabaseTarget>()));
}
public static void RegisterDatabaseLogger(DatabaseTarget databaseTarget)
{
LogManager.Configuration.AddTarget("DbLogger", databaseTarget);
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, databaseTarget));
Common.LogConfiguration.Reload();
}
}
}