diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props
index a1829afd0..345dd2423 100644
--- a/src/Directory.Packages.props
+++ b/src/Directory.Packages.props
@@ -29,9 +29,9 @@
-
-
-
+
+
+
diff --git a/src/NzbDrone.Common/Instrumentation/Extensions/SentryLoggerExtensions.cs b/src/NzbDrone.Common/Instrumentation/Extensions/SentryLoggerExtensions.cs
index 2e17aad44..68201d62c 100644
--- a/src/NzbDrone.Common/Instrumentation/Extensions/SentryLoggerExtensions.cs
+++ b/src/NzbDrone.Common/Instrumentation/Extensions/SentryLoggerExtensions.cs
@@ -1,6 +1,6 @@
-using System.Linq;
+using System.Collections.Generic;
+using System.Linq;
using NLog;
-using NLog.Fluent;
namespace NzbDrone.Common.Instrumentation.Extensions
{
@@ -8,47 +8,46 @@ namespace NzbDrone.Common.Instrumentation.Extensions
{
public static readonly Logger SentryLogger = LogManager.GetLogger("Sentry");
- public static LogBuilder SentryFingerprint(this LogBuilder logBuilder, params string[] fingerprint)
+ public static LogEventBuilder SentryFingerprint(this LogEventBuilder logBuilder, params string[] fingerprint)
{
return logBuilder.Property("Sentry", fingerprint);
}
- public static LogBuilder WriteSentryDebug(this LogBuilder logBuilder, params string[] fingerprint)
+ public static LogEventBuilder WriteSentryDebug(this LogEventBuilder logBuilder, params string[] fingerprint)
{
return LogSentryMessage(logBuilder, LogLevel.Debug, fingerprint);
}
- public static LogBuilder WriteSentryInfo(this LogBuilder logBuilder, params string[] fingerprint)
+ public static LogEventBuilder WriteSentryInfo(this LogEventBuilder logBuilder, params string[] fingerprint)
{
return LogSentryMessage(logBuilder, LogLevel.Info, fingerprint);
}
- public static LogBuilder WriteSentryWarn(this LogBuilder logBuilder, params string[] fingerprint)
+ public static LogEventBuilder WriteSentryWarn(this LogEventBuilder logBuilder, params string[] fingerprint)
{
return LogSentryMessage(logBuilder, LogLevel.Warn, fingerprint);
}
- public static LogBuilder WriteSentryError(this LogBuilder logBuilder, params string[] fingerprint)
+ public static LogEventBuilder WriteSentryError(this LogEventBuilder logBuilder, params string[] fingerprint)
{
return LogSentryMessage(logBuilder, LogLevel.Error, fingerprint);
}
- private static LogBuilder LogSentryMessage(LogBuilder logBuilder, LogLevel level, string[] fingerprint)
+ private static LogEventBuilder LogSentryMessage(LogEventBuilder logBuilder, LogLevel level, string[] fingerprint)
{
- SentryLogger.Log(level)
- .CopyLogEvent(logBuilder.LogEventInfo)
+ SentryLogger.ForLogEvent(level)
+ .CopyLogEvent(logBuilder.LogEvent)
.SentryFingerprint(fingerprint)
- .Write();
+ .Log();
- return logBuilder.Property("Sentry", null);
+ return logBuilder.Property("Sentry", null);
}
- private static LogBuilder CopyLogEvent(this LogBuilder logBuilder, LogEventInfo logEvent)
+ private static LogEventBuilder CopyLogEvent(this LogEventBuilder logBuilder, LogEventInfo logEvent)
{
- return logBuilder.LoggerName(logEvent.LoggerName)
- .TimeStamp(logEvent.TimeStamp)
+ return logBuilder.TimeStamp(logEvent.TimeStamp)
.Message(logEvent.Message, logEvent.Parameters)
- .Properties(logEvent.Properties.ToDictionary(v => v.Key, v => v.Value))
+ .Properties(logEvent.Properties.Select(p => new KeyValuePair(p.Key.ToString(), p.Value)))
.Exception(logEvent.Exception);
}
}
diff --git a/src/NzbDrone.Common/Instrumentation/NzbDroneFileTarget.cs b/src/NzbDrone.Common/Instrumentation/NzbDroneFileTarget.cs
index 62e41b0e0..84658cf74 100644
--- a/src/NzbDrone.Common/Instrumentation/NzbDroneFileTarget.cs
+++ b/src/NzbDrone.Common/Instrumentation/NzbDroneFileTarget.cs
@@ -1,13 +1,15 @@
-using NLog;
+using System.Text;
+using NLog;
using NLog.Targets;
namespace NzbDrone.Common.Instrumentation
{
public class NzbDroneFileTarget : FileTarget
{
- protected override string GetFormattedMessage(LogEventInfo logEvent)
+ protected override void RenderFormattedMessage(LogEventInfo logEvent, StringBuilder target)
{
- return CleanseLogMessage.Cleanse(Layout.Render(logEvent));
+ var result = CleanseLogMessage.Cleanse(Layout.Render(logEvent));
+ target.Append(result);
}
}
}
diff --git a/src/NzbDrone.Common/Instrumentation/NzbDroneLogger.cs b/src/NzbDrone.Common/Instrumentation/NzbDroneLogger.cs
index 67d77d203..81f05a97e 100644
--- a/src/NzbDrone.Common/Instrumentation/NzbDroneLogger.cs
+++ b/src/NzbDrone.Common/Instrumentation/NzbDroneLogger.cs
@@ -34,6 +34,8 @@ namespace NzbDrone.Common.Instrumentation
var appFolderInfo = new AppFolderInfo(startupContext);
+ RegisterGlobalFilters();
+
if (Debugger.IsAttached)
{
RegisterDebugger();
@@ -101,6 +103,16 @@ namespace NzbDrone.Common.Instrumentation
LogManager.Configuration.LoggingRules.Add(loggingRule);
}
+ private static void RegisterGlobalFilters()
+ {
+ LogManager.Setup().LoadConfiguration(c =>
+ {
+ c.ForLogger("Microsoft.Hosting.Lifetime*").WriteToNil(LogLevel.Info);
+ c.ForLogger("System*").WriteToNil(LogLevel.Warn);
+ c.ForLogger("Microsoft*").WriteToNil(LogLevel.Warn);
+ });
+ }
+
private static void RegisterConsole()
{
var level = LogLevel.Trace;
diff --git a/src/NzbDrone.Core/Download/CompletedDownloadService.cs b/src/NzbDrone.Core/Download/CompletedDownloadService.cs
index b2078a96c..3ff389848 100644
--- a/src/NzbDrone.Core/Download/CompletedDownloadService.cs
+++ b/src/NzbDrone.Core/Download/CompletedDownloadService.cs
@@ -164,14 +164,14 @@ namespace NzbDrone.Core.Download
}
else
{
- _logger.Debug()
+ _logger.ForDebugEvent()
.Message("No books were just imported, but all books were previously imported, possible issue with download history.")
.Property("AuthorId", trackedDownload.RemoteBook.Author.Id)
.Property("DownloadId", trackedDownload.DownloadItem.DownloadId)
.Property("Title", trackedDownload.DownloadItem.Title)
.Property("Path", trackedDownload.DownloadItem.OutputPath.ToString())
.WriteSentryWarn("DownloadHistoryIncomplete")
- .Write();
+ .Log();
}
trackedDownload.State = TrackedDownloadState.Imported;
diff --git a/src/NzbDrone.Core/Instrumentation/ReconfigureLogging.cs b/src/NzbDrone.Core/Instrumentation/ReconfigureLogging.cs
index ee7d2f072..38b695ccc 100644
--- a/src/NzbDrone.Core/Instrumentation/ReconfigureLogging.cs
+++ b/src/NzbDrone.Core/Instrumentation/ReconfigureLogging.cs
@@ -117,7 +117,6 @@ namespace NzbDrone.Core.Instrumentation
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 = _configFileProvider.InstanceName;
diff --git a/src/NzbDrone.Core/MediaFiles/AudioTag.cs b/src/NzbDrone.Core/MediaFiles/AudioTag.cs
index 8b4e4b47b..986c225a8 100644
--- a/src/NzbDrone.Core/MediaFiles/AudioTag.cs
+++ b/src/NzbDrone.Core/MediaFiles/AudioTag.cs
@@ -400,11 +400,11 @@ namespace NzbDrone.Core.MediaFiles
}
catch (Exception ex)
{
- Logger.Warn()
+ Logger.ForWarnEvent()
.Exception(ex)
.Message($"Tag writing failed for {path}")
.WriteSentryWarn("Tag writing failed")
- .Write();
+ .Log();
}
finally
{
diff --git a/src/NzbDrone.Core/MediaFiles/AudioTagService.cs b/src/NzbDrone.Core/MediaFiles/AudioTagService.cs
index 7a5b05a3d..568822728 100644
--- a/src/NzbDrone.Core/MediaFiles/AudioTagService.cs
+++ b/src/NzbDrone.Core/MediaFiles/AudioTagService.cs
@@ -147,11 +147,11 @@ namespace NzbDrone.Core.MediaFiles
}
catch (Exception ex)
{
- _logger.Warn()
+ _logger.ForWarnEvent()
.Exception(ex)
.Message($"Tag removal failed for {path}")
.WriteSentryWarn("Tag removal failed")
- .Write();
+ .Log();
}
finally
{
diff --git a/src/NzbDrone.Core/MediaFiles/MediaInfoFormatter.cs b/src/NzbDrone.Core/MediaFiles/MediaInfoFormatter.cs
index 60bb6b75d..be2d155bf 100644
--- a/src/NzbDrone.Core/MediaFiles/MediaInfoFormatter.cs
+++ b/src/NzbDrone.Core/MediaFiles/MediaInfoFormatter.cs
@@ -65,10 +65,10 @@ namespace NzbDrone.Core.MediaFiles
}
else
{
- Logger.Debug()
+ Logger.ForDebugEvent()
.Message("Unknown audio format: '{0}'.", string.Join(", ", mediaInfo.AudioFormat))
.WriteSentryWarn("UnknownAudioFormat", mediaInfo.AudioFormat)
- .Write();
+ .Log();
return "Unknown";
}