|
|
|
@ -2,6 +2,8 @@
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using NLog;
|
|
|
|
|
using NLog.Config;
|
|
|
|
|
using NLog.Targets.Syslog;
|
|
|
|
|
using NLog.Targets.Syslog.Settings;
|
|
|
|
|
using NzbDrone.Common.EnvironmentInfo;
|
|
|
|
|
using NzbDrone.Common.Extensions;
|
|
|
|
|
using NzbDrone.Common.Instrumentation;
|
|
|
|
@ -40,6 +42,11 @@ namespace NzbDrone.Core.Instrumentation
|
|
|
|
|
minimumConsoleLogLevel = LogLevel.Info;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (_configFileProvider.SyslogServer.IsNotNullOrWhiteSpace())
|
|
|
|
|
{
|
|
|
|
|
SetSyslogParameters(_configFileProvider.SyslogServer, _configFileProvider.SyslogPort, minimumLogLevel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var rules = LogManager.Configuration.LoggingRules;
|
|
|
|
|
|
|
|
|
|
//Console
|
|
|
|
@ -101,6 +108,24 @@ namespace NzbDrone.Core.Instrumentation
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SetSyslogParameters(string syslogServer, int syslogPort, LogLevel minimumLogLevel)
|
|
|
|
|
{
|
|
|
|
|
var syslogTarget = new SyslogTarget();
|
|
|
|
|
|
|
|
|
|
syslogTarget.Name = "syslogTarget";
|
|
|
|
|
syslogTarget.MessageSend.Protocol = ProtocolType.Udp;
|
|
|
|
|
syslogTarget.MessageSend.Udp.Port = syslogPort;
|
|
|
|
|
syslogTarget.MessageSend.Udp.Server = syslogServer;
|
|
|
|
|
syslogTarget.MessageSend.Udp.ReconnectInterval = 500;
|
|
|
|
|
syslogTarget.MessageCreation.Rfc = RfcNumber.Rfc5424;
|
|
|
|
|
syslogTarget.MessageCreation.Rfc5424.AppName = "Prowlarr";
|
|
|
|
|
|
|
|
|
|
var loggingRule = new LoggingRule("*", minimumLogLevel, syslogTarget);
|
|
|
|
|
|
|
|
|
|
LogManager.Configuration.AddTarget("syslogTarget", syslogTarget);
|
|
|
|
|
LogManager.Configuration.LoggingRules.Add(loggingRule);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<LogLevel> GetLogLevels()
|
|
|
|
|
{
|
|
|
|
|
return new List<LogLevel>
|
|
|
|
|