mirror of
https://github.com/Radarr/Radarr.git
synced 2024-10-05 15:47:20 +02:00
New: Added UDP syslog support
(cherry picked from commit 8d856b2edb8bf46a2b516d5f7644ae3fa1151323)
This commit is contained in:
parent
8ae84222d1
commit
4f512c5cdf
@ -11,6 +11,7 @@
|
|||||||
<PackageReference Include="NLog" Version="4.7.14" />
|
<PackageReference Include="NLog" Version="4.7.14" />
|
||||||
<PackageReference Include="NLog.Extensions.Logging" Version="1.7.4" />
|
<PackageReference Include="NLog.Extensions.Logging" Version="1.7.4" />
|
||||||
<PackageReference Include="Sentry" Version="3.15.0" />
|
<PackageReference Include="Sentry" Version="3.15.0" />
|
||||||
|
<PackageReference Include="NLog.Targets.Syslog" Version="6.0.3" />
|
||||||
<PackageReference Include="SharpZipLib" Version="1.3.3" />
|
<PackageReference Include="SharpZipLib" Version="1.3.3" />
|
||||||
<PackageReference Include="System.Text.Json" Version="6.0.2" />
|
<PackageReference Include="System.Text.Json" Version="6.0.2" />
|
||||||
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
|
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
|
||||||
|
@ -46,6 +46,8 @@ public interface IConfigFileProvider : IHandleAsync<ApplicationStartedEvent>,
|
|||||||
bool UpdateAutomatically { get; }
|
bool UpdateAutomatically { get; }
|
||||||
UpdateMechanism UpdateMechanism { get; }
|
UpdateMechanism UpdateMechanism { get; }
|
||||||
string UpdateScriptPath { get; }
|
string UpdateScriptPath { get; }
|
||||||
|
string SyslogServer { get; }
|
||||||
|
int SyslogPort { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ConfigFileProvider : IConfigFileProvider
|
public class ConfigFileProvider : IConfigFileProvider
|
||||||
@ -211,6 +213,9 @@ public string UrlBase
|
|||||||
|
|
||||||
public string UpdateScriptPath => GetValue("UpdateScriptPath", "", false);
|
public string UpdateScriptPath => GetValue("UpdateScriptPath", "", false);
|
||||||
|
|
||||||
|
public string SyslogServer => GetValue("SyslogServer", "", persist: false);
|
||||||
|
public int SyslogPort => GetValueInt("SyslogPort", 514, persist: false);
|
||||||
|
|
||||||
public int GetValueInt(string key, int defaultValue, bool persist = true)
|
public int GetValueInt(string key, int defaultValue, bool persist = true)
|
||||||
{
|
{
|
||||||
return Convert.ToInt32(GetValue(key, defaultValue, persist));
|
return Convert.ToInt32(GetValue(key, defaultValue, persist));
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NLog.Config;
|
using NLog.Config;
|
||||||
|
using NLog.Targets.Syslog;
|
||||||
|
using NLog.Targets.Syslog.Settings;
|
||||||
using NzbDrone.Common.EnvironmentInfo;
|
using NzbDrone.Common.EnvironmentInfo;
|
||||||
using NzbDrone.Common.Extensions;
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Common.Instrumentation;
|
using NzbDrone.Common.Instrumentation;
|
||||||
@ -40,6 +42,11 @@ public void Reconfigure()
|
|||||||
minimumConsoleLogLevel = LogLevel.Info;
|
minimumConsoleLogLevel = LogLevel.Info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_configFileProvider.SyslogServer.IsNotNullOrWhiteSpace())
|
||||||
|
{
|
||||||
|
SetSyslogParameters(_configFileProvider.SyslogServer, _configFileProvider.SyslogPort, minimumLogLevel);
|
||||||
|
}
|
||||||
|
|
||||||
var rules = LogManager.Configuration.LoggingRules;
|
var rules = LogManager.Configuration.LoggingRules;
|
||||||
|
|
||||||
//Console
|
//Console
|
||||||
@ -101,6 +108,24 @@ private void ReconfigureSentry()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 = BuildInfo.AppName;
|
||||||
|
|
||||||
|
var loggingRule = new LoggingRule("*", minimumLogLevel, syslogTarget);
|
||||||
|
|
||||||
|
LogManager.Configuration.AddTarget("syslogTarget", syslogTarget);
|
||||||
|
LogManager.Configuration.LoggingRules.Add(loggingRule);
|
||||||
|
}
|
||||||
|
|
||||||
private List<LogLevel> GetLogLevels()
|
private List<LogLevel> GetLogLevels()
|
||||||
{
|
{
|
||||||
return new List<LogLevel>
|
return new List<LogLevel>
|
||||||
|
Loading…
Reference in New Issue
Block a user