1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-12 11:15:43 +02:00
Sonarr/NzbDrone.Core/Instrumentation/LogConfiguration.cs
kay.one 30d8da3ce8 Log is now configured earlier in the life cycle.
Glimpse now listens to all IP addresses
2011-05-17 19:53:31 -07:00

38 lines
1.3 KiB
C#

using System.Diagnostics;
using System.IO;
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;
}
LogManager.Configuration = new XmlLoggingConfiguration(Path.Combine(CentralDispatch.AppPath, "log.config"),
false);
LogManager.ConfigurationReloaded += ((s, e) => BindCustomLoggers());
BindCustomLoggers();
}
private static void BindCustomLoggers()
{
#if Release
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<SubsonicTarget>();
LogManager.Configuration.AddTarget("DbLogger", sonicTarget);
LogManager.Configuration.LoggingRules.Add(new LoggingRule("*", NLog.LogLevel.Info, sonicTarget));
LogManager.Configuration.Reload();
}
}
}