-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from dragonfruitnetwork/cleanup-logging
inject logger earlier and use extension method
- Loading branch information
Showing
1 changed file
with
16 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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>("#app"); | ||
builder.RootComponents.Add<HeadOutlet>("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://[email protected]/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<WikiRenderer>(); | ||
builder.Services.AddScoped<ApiClient, SakuraClient>(); | ||
|
||
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://[email protected]/6542291"; | ||
}); | ||
|
||
builder.Logging.AddProvider(new SerilogLoggerProvider(loggingConfig.CreateLogger(), true)); | ||
|
||
await builder.Build().RunAsync(); | ||
} | ||
} | ||
|