From d8f55c03580c776ae88fc31fd8b9ae7984cefe14 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Tue, 4 Mar 2014 17:02:36 -0800 Subject: [PATCH] Catch errors when failing to write logs to database --- src/NzbDrone.Core/Instrumentation/DatabaseTarget.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/NzbDrone.Core/Instrumentation/DatabaseTarget.cs b/src/NzbDrone.Core/Instrumentation/DatabaseTarget.cs index 8c71174a4..36d942dfc 100644 --- a/src/NzbDrone.Core/Instrumentation/DatabaseTarget.cs +++ b/src/NzbDrone.Core/Instrumentation/DatabaseTarget.cs @@ -1,4 +1,5 @@ using System; +using NLog.Common; using NLog.Config; using NLog; using NLog.Layouts; @@ -76,10 +77,18 @@ namespace NzbDrone.Core.Instrumentation log.ExceptionType = logEvent.Exception.GetType().ToString(); } - + log.Level = logEvent.Level.Name; - _repository.Insert(log); + try + { + _repository.Insert(log); + } + catch (Exception ex) + { + InternalLogger.Error("Unable to save log event to database: {0}", ex); + throw; + } } public void Handle(ApplicationShutdownRequested message)