question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incompatible with Serilog.AspNetCore

See original GitHub issue

I’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:closed
  • Created 5 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Mitch528commented, Aug 1, 2018

@bruno-garcia Great, thanks!

0reactions
bruno-garciacommented, Aug 1, 2018

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

Read more comments on GitHub >

github_iconTop 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 >
Serilog.AspNetCore 7.0.0
Serilog support for ASP.NET Core logging.
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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found