Use Serilog in EntityFramework Core logging.

This commit is contained in:
2025-07-24 21:23:53 +01:00
parent 1435aa10ee
commit bf19439e49
15 changed files with 69 additions and 36 deletions

View File

@@ -39,6 +39,7 @@ using RomRepoMgr.Core.Models;
using RomRepoMgr.Core.Workers;
using RomRepoMgr.Database;
using Serilog;
using Serilog.Extensions.Logging;
namespace RomRepoMgr.ViewModels;
@@ -175,7 +176,8 @@ public sealed partial class SplashWindowViewModel : ViewModelBase
if(!Directory.Exists(dbPathFolder)) Directory.CreateDirectory(dbPathFolder);
using var ctx = Context.Create(Settings.Settings.Current.DatabasePath);
using var ctx = Context.Create(Settings.Settings.Current.DatabasePath,
new SerilogLoggerFactory(Log.Logger));
Dispatcher.UIThread.Post(MigrateDatabase);
}
@@ -203,7 +205,8 @@ public sealed partial class SplashWindowViewModel : ViewModelBase
{
try
{
using var ctx = Context.Create(Settings.Settings.Current.DatabasePath);
using var ctx = Context.Create(Settings.Settings.Current.DatabasePath,
new SerilogLoggerFactory(Log.Logger));
ctx.Database.Migrate();
@@ -233,7 +236,8 @@ public sealed partial class SplashWindowViewModel : ViewModelBase
{
try
{
using var ctx = Context.Create(Settings.Settings.Current.DatabasePath);
using var ctx = Context.Create(Settings.Settings.Current.DatabasePath,
new SerilogLoggerFactory(Log.Logger));
GotRomSets?.Invoke(this,
new RomSetsEventArgs