sonarr-repo-only/NzbDrone.Core/Instrumentation/LogConfiguration.cs

34 lines
1.2 KiB
C#
Raw Normal View History

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