diff --git a/src/KFlearning/KFlearning.csproj b/src/KFlearning/KFlearning.csproj index 0fd9881..d0a8933 100644 --- a/src/KFlearning/KFlearning.csproj +++ b/src/KFlearning/KFlearning.csproj @@ -164,12 +164,21 @@ 4.4.1 + + 4.4.1 + + + 5.1.1 + 5.1.1 1.15.0 + + 4.7.8 + diff --git a/src/KFlearning/Program.cs b/src/KFlearning/Program.cs index f7a5e29..fc55762 100644 --- a/src/KFlearning/Program.cs +++ b/src/KFlearning/Program.cs @@ -11,13 +11,12 @@ using System; using System.Threading; using System.Windows.Forms; +using Castle.Core.Logging; using Castle.Windsor; -using KFlearning.Core; using KFlearning.Core.Extensions; using KFlearning.Core.Services; using KFlearning.Properties; using KFlearning.Services; -using KFlearning.Views; namespace KFlearning { @@ -43,6 +42,7 @@ static void Main(string[] args) } // install services + NLog.GlobalDiagnosticsContext.Set("logDirectory", PathHelpers.GetLogPath()); Container.Install(new KFlearningModulesInstaller()); // find vscode @@ -84,9 +84,13 @@ private static void Application_ApplicationExit(object sender, EventArgs e) usesPersistance.Save(); } } - catch + catch (Exception ex) { - // ignore + Container.Resolve().Error("Cannot save persistance", ex); + } + finally + { + NLog.LogManager.Shutdown(); } Container.Dispose(); diff --git a/src/KFlearning/Services/KFlearningModulesInstaller.cs b/src/KFlearning/Services/KFlearningModulesInstaller.cs index 6b04fb1..7fa56b2 100644 --- a/src/KFlearning/Services/KFlearningModulesInstaller.cs +++ b/src/KFlearning/Services/KFlearningModulesInstaller.cs @@ -4,6 +4,8 @@ using KFlearning.TemplateProvider; using KFlearning.Views; using System.Net; +using Castle.Facilities.Logging; +using Castle.Services.Logging.NLogIntegration; namespace KFlearning.Services { @@ -11,6 +13,7 @@ public class KFlearningModulesInstaller : IWindsorInstaller { public void Install(IWindsorContainer container, IConfigurationStore store) { + container.AddFacility(logger => logger.LogUsing()); container.Register( Component.For().ImplementedBy().LifestyleTransient(), diff --git a/src/KFlearning/Services/TelemetryService.cs b/src/KFlearning/Services/TelemetryService.cs index 1694492..416de4f 100644 --- a/src/KFlearning/Services/TelemetryService.cs +++ b/src/KFlearning/Services/TelemetryService.cs @@ -1,4 +1,5 @@ -using KFlearning.Core.API; +using Castle.Core.Logging; +using KFlearning.Core.API; using KFlearning.Core.Services; using System; using System.Threading.Tasks; @@ -13,9 +14,11 @@ public class TelemetryService : ITelemetryService { private readonly ISystemInfoService _infoService; private readonly ITelemetryClient _telemetry; + private readonly ILogger _logger; - public TelemetryService(ITelemetryClient telemetry, ISystemInfoService infoService) + public TelemetryService(ILogger logger, ITelemetryClient telemetry, ISystemInfoService infoService) { + _logger = logger; _telemetry = telemetry; _infoService = infoService; } @@ -42,9 +45,9 @@ public void Load() }) ); } - catch (Exception) + catch (Exception ex) { - // ignore + _logger.Error("Cannot post telemetry data", ex); } }