From 654733fc366a94bdad6b7865209382a85e46ccf5 Mon Sep 17 00:00:00 2001 From: Albie Date: Sat, 26 Nov 2022 18:38:13 +0000 Subject: [PATCH] inject logger earlier and use extension method --- DragonFruit.Sakura/Program.cs | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/DragonFruit.Sakura/Program.cs b/DragonFruit.Sakura/Program.cs index dcf7fc0..deb7173 100644 --- a/DragonFruit.Sakura/Program.cs +++ b/DragonFruit.Sakura/Program.cs @@ -11,7 +11,6 @@ using MudBlazor.Services; using Serilog; using Serilog.Events; -using Serilog.Extensions.Logging; namespace DragonFruit.Sakura { @@ -35,6 +34,22 @@ public static async Task Main(string[] args) builder.RootComponents.Add("#app"); builder.RootComponents.Add("head::after"); + var loggingConfig = new LoggerConfiguration() + .MinimumLevel.Debug() + .Enrich.WithProperty("InstanceId", Guid.NewGuid().ToString("D")) + .WriteTo.BrowserConsole() + .WriteTo.Sentry(o => + { + var version = Assembly.GetExecutingAssembly().GetName().Version; + + o.MaxBreadcrumbs = 50; + o.MinimumEventLevel = LogEventLevel.Error; + o.MinimumBreadcrumbLevel = LogEventLevel.Debug; + o.Release = version?.ToString(version.Build > 0 ? 3 : 2); + o.Dsn = "https://d42ddda84a6f4ffb8d9d66cb7d1a6d9b@o97031.ingest.sentry.io/6542291"; + }); + + builder.Logging.AddSerilog(loggingConfig.CreateLogger(), true); builder.Services.AddOidcAuthentication(o => { o.ProviderOptions.Authority = "https://id.dragonfruit.network/connect/authorize"; @@ -61,23 +76,6 @@ public static async Task Main(string[] args) builder.Services.AddScoped(); builder.Services.AddScoped(); - var loggingConfig = new LoggerConfiguration() - .MinimumLevel.Debug() - .Enrich.WithProperty("InstanceId", Guid.NewGuid().ToString("D")) - .WriteTo.BrowserConsole() - .WriteTo.Sentry(o => - { - var version = Assembly.GetExecutingAssembly().GetName().Version; - - o.MaxBreadcrumbs = 50; - o.MinimumEventLevel = LogEventLevel.Error; - o.MinimumBreadcrumbLevel = LogEventLevel.Debug; - o.Release = version?.ToString(version.Build > 0 ? 3 : 2); - o.Dsn = "https://d42ddda84a6f4ffb8d9d66cb7d1a6d9b@o97031.ingest.sentry.io/6542291"; - }); - - builder.Logging.AddProvider(new SerilogLoggerProvider(loggingConfig.CreateLogger(), true)); - await builder.Build().RunAsync(); } }