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