Browse Source

Fix nlog

pull/5/head
Ionite 2 years ago
parent
commit
ae3c1aeb2a
No known key found for this signature in database
  1. 14
      StabilityMatrix/App.xaml.cs

14
StabilityMatrix/App.xaml.cs

@ -1,4 +1,6 @@
using System.Windows;
using System;
using System.IO;
using System.Windows;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
@ -9,6 +11,7 @@ using StabilityMatrix.Services;
using StabilityMatrix.ViewModels;
using Wpf.Ui.Contracts;
using Wpf.Ui.Services;
using SetupBuilderExtensions = NLog.SetupBuilderExtensions;
namespace StabilityMatrix
{
@ -29,14 +32,21 @@ namespace StabilityMatrix
serviceCollection.AddSingleton<SettingsViewModel>();
serviceCollection.AddSingleton<LaunchViewModel>();
serviceCollection.AddSingleton<IContentDialogService, ContentDialogService>();
serviceCollection.AddSingleton<ISnackbarService, SnackbarService>();
serviceCollection.AddSingleton<ISettingsManager, SettingsManager>();
serviceCollection.AddRefitClient<IGithubApi>();
var logPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log.txt");
var logConfig = new NLog.Config.LoggingConfiguration();
var fileTarget = new NLog.Targets.FileTarget("logfile") {FileName = logPath};
logConfig.AddRule(NLog.LogLevel.Trace, NLog.LogLevel.Fatal, fileTarget);
NLog.LogManager.Configuration = logConfig;
serviceCollection.AddLogging(log =>
{
log.ClearProviders();
log.SetMinimumLevel(LogLevel.Trace);
log.AddNLog();
log.AddNLog(logConfig);
});
var provider = serviceCollection.BuildServiceProvider();

Loading…
Cancel
Save