2010-10-24 07:46:58 +00:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.IO;
|
2011-04-10 02:44:01 +00:00
|
|
|
|
using Ninject;
|
2010-10-24 07:46:58 +00: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 02:44:01 +00:00
|
|
|
|
LogManager.Configuration = new XmlLoggingConfiguration(Path.Combine(CentralDispatch.AppPath, "log.config"),
|
|
|
|
|
false);
|
2011-06-13 03:45:22 +00:00
|
|
|
|
|
|
|
|
|
LogManager.ConfigurationReloaded += ((s, e) => StartDbLogging());
|
2010-10-24 07:46:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-06-13 03:45:22 +00:00
|
|
|
|
public static void StartDbLogging()
|
2010-10-24 07:46:58 +00:00
|
|
|
|
{
|
2011-10-17 01:37:29 +00:00
|
|
|
|
#if DEBUG
|
|
|
|
|
#else
|
2010-10-24 07:46:58 +00:00
|
|
|
|
var exTarget = new ExceptioneerTarget();
|
|
|
|
|
LogManager.Configuration.AddTarget("Exceptioneer", exTarget);
|
|
|
|
|
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", NLog.LogLevel.Error, exTarget));
|
2010-10-30 02:46:32 +00:00
|
|
|
|
#endif
|
2011-06-24 04:05:31 +00:00
|
|
|
|
var sonicTarget = CentralDispatch.NinjectKernel.Get<DatabaseTarget>();
|
2010-10-24 07:46:58 +00:00
|
|
|
|
LogManager.Configuration.AddTarget("DbLogger", sonicTarget);
|
2011-06-22 05:43:45 +00:00
|
|
|
|
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, sonicTarget));
|
2010-10-24 07:46:58 +00:00
|
|
|
|
|
|
|
|
|
LogManager.Configuration.Reload();
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-04-10 02:44:01 +00:00
|
|
|
|
}
|