2010-10-24 09:46:58 +02:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Instrumentation
|
|
|
|
|
{
|
|
|
|
|
public static class LogConfiguration
|
|
|
|
|
{
|
|
|
|
|
public static void Setup()
|
|
|
|
|
{
|
|
|
|
|
if (Debugger.IsAttached)
|
|
|
|
|
{
|
|
|
|
|
LogManager.ThrowExceptions = true;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-10 04:44:01 +02:00
|
|
|
|
LogManager.Configuration = new XmlLoggingConfiguration(Path.Combine(CentralDispatch.AppPath, "log.config"),
|
|
|
|
|
false);
|
2010-10-24 09:46:58 +02:00
|
|
|
|
LogManager.ConfigurationReloaded += ((s, e) => BindCustomLoggers());
|
|
|
|
|
BindCustomLoggers();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void BindCustomLoggers()
|
|
|
|
|
{
|
2010-10-30 04:46:32 +02:00
|
|
|
|
#if Release
|
2010-10-24 09:46:58 +02:00
|
|
|
|
var exTarget = new ExceptioneerTarget();
|
|
|
|
|
LogManager.Configuration.AddTarget("Exceptioneer", exTarget);
|
|
|
|
|
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", NLog.LogLevel.Error, exTarget));
|
2010-10-30 04:46:32 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
2010-10-24 09:46:58 +02:00
|
|
|
|
|
|
|
|
|
var sonicTarget = CentralDispatch.NinjectKernel.Get<SubsonicTarget>();
|
|
|
|
|
LogManager.Configuration.AddTarget("DbLogger", sonicTarget);
|
|
|
|
|
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", NLog.LogLevel.Info, sonicTarget));
|
|
|
|
|
|
|
|
|
|
LogManager.Configuration.Reload();
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-04-10 04:44:01 +02:00
|
|
|
|
}
|