Incompatible with Serilog.AspNetCore
See original GitHub issueI’m not sure if this is an issue that would need to be fixed on the side of serilog/serilog-aspnetcore or sentry, but currently they cannot be used together.
The following code results in an exception on startup:
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseSentry()
.UseSerilog();
λ dotnet run
Using launch settings from C:\Users\Mitchell\source\repos\WebApplication4\WebApplication4\Properties\launchSettings.json...
Application startup exception: System.NullReferenceException: Object reference not set to an instance of an object.
at Sentry.SentryOptionsExtensions.AddEventProcessorProvider(SentryOptions options, Func`1 processorProvider) in C:\projects\sentry-dotnet\src\Sentry\SentryOptionsExtensions.cs:line 80
at Microsoft.AspNetCore.Builder.ApplicationBuilderExtensions.UseServiceProviderProcessors(IServiceProvider provider) in C:\projects\sentry-dotnet\src\Sentry.AspNetCore\ApplicationBuilderExtensions.cs:line 37
at Microsoft.AspNetCore.Builder.ApplicationBuilderExtensions.UseSentry(IApplicationBuilder app) in C:\projects\sentry-dotnet\src\Sentry.AspNetCore\ApplicationBuilderExtensions.cs:line 26
at Sentry.AspNetCore.SentryStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder e) in C:\projects\sentry-dotnet\src\Sentry.AspNetCore\SentryStartupFilter.cs:line 13
at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
at Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at Sentry.SentryOptionsExtensions.AddEventProcessorProvider(SentryOptions options, Func`1 processorProvider) in C:\projects\sentry-dotnet\src\Sentry\SentryOptionsExtensions.cs:line 80
at Microsoft.AspNetCore.Builder.ApplicationBuilderExtensions.UseServiceProviderProcessors(IServiceProvider provider) in C:\projects\sentry-dotnet\src\Sentry.AspNetCore\ApplicationBuilderExtensions.cs:line 37
at Microsoft.AspNetCore.Builder.ApplicationBuilderExtensions.UseSentry(IApplicationBuilder app) in C:\projects\sentry-dotnet\src\Sentry.AspNetCore\ApplicationBuilderExtensions.cs:line 26
at Sentry.AspNetCore.SentryStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder e) in C:\projects\sentry-dotnet\src\Sentry.AspNetCore\SentryStartupFilter.cs:line 13
at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
at Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
at Microsoft.AspNetCore.Hosting.Internal.WebHost.StartAsync(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String shutdownMessage)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
at WebApplication4.Program.Main(String[] args) in C:\Users\Mitchell\source\repos\WebApplication4\WebApplication4\Program.cs:line 18
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
ASP.NET Core Web API - How to resolve conflict between ...
ASP.NET Core 6 by default includes Microsoft.Extensions.Logging . You can either 'disable' all "usings" or remove Microsoft.Extensions.
Read more >Can we get a fix for the dll hell issue seen when using the C# ...
In ASP .NET Core 6.0, the below error is seen when using the C# SDK along with package SeriLog.AspNetCore. This dll hell issue,...
Read more >Setting up Serilog in ASP.NET Core - Detailed Beginner ...
This article covers the implementation of Serilog in ASP.NET Core which provides structured logging that is easier to be read by programs.
Read more >Setting up Serilog in .NET 6 - Structured Blog
Adding the Serilog package. To get started you'll need Serilog.AspNetCore: dotnet add package Serilog.AspNetCore. This includes the core Serilog ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@bruno-garcia Great, thanks!
If you are using on prem please note the last release doesn’t work if you don’t have nginx or something which supports chunked requests. You have disabled gzip requests to work around it. Master has it fixed and it will be on nuget soon when we publish preview5