1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-30 19:45:57 +00:00
Lidarr/NzbDrone.Core/Instrumentation/LogConfiguration.cs

39 lines
1.2 KiB
C#
Raw Normal View History

using System.Diagnostics;
using System.IO;
2011-04-10 02:44:01 +00:00
using Ninject;
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);
LogManager.ConfigurationReloaded += ((s, e) => StartDbLogging());
}
public static void StartDbLogging()
{
2011-10-17 01:37:29 +00:00
#if DEBUG
#else
var exTarget = new ExceptioneerTarget();
LogManager.Configuration.AddTarget("Exceptioneer", exTarget);
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", NLog.LogLevel.Error, exTarget));
#endif
var sonicTarget = CentralDispatch.NinjectKernel.Get<DatabaseTarget>();
LogManager.Configuration.AddTarget("DbLogger", sonicTarget);
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, sonicTarget));
LogManager.Configuration.Reload();
}
}
2011-04-10 02:44:01 +00:00
}