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.

StackOverflowException on ASP.NET Core + Microsoft.Extensions.Logging with default DiagnosticLevel and Debug enabled

See original GitHub issue

Please mark the type framework used:

  • ASP.NET MVC
  • ASP.NET Web API (OWIN)
  • ASP.NET Core
  • WPF
  • WinForms
  • Xamarin
  • Other:

Please mark the type of the runtime used:

  • .NET Framework
  • Mono
  • .NET Core
  • Version:

Please mark the NuGet packages used:

  • Sentry
  • Sentry.Serilog
  • Sentry.NLog
  • Sentry.Log4Net
  • Sentry.Extensions.Logging
  • Sentry.AspNetCore
  • Version: 3.0.0

Description

I’m getting a StackOverflowException with the new version when attempting to run Integration Tests. I have my code configured to not log to Sentry if we are in unit tests by setting DSN to "".

If I actually Debug, it looks like I’m getting the non-stop message “Debug: Configuring the Scope”.

If I downgrade to 2.1.8, this error goes away.

The active test run was aborted. Reason: Test host process crashed : Stack overflow.
   at Microsoft.Extensions.Logging.Debug.DebugLogger.Log[[Microsoft.Extensions.Logging.FormattedLogValues, Microsoft.Extensions.Logging.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](Microsoft.Extensions.Logging.LogLevel, Microsoft.Extensions.Logging.EventId, Microsoft.Extensions.Logging.FormattedLogValues, System.Exception, System.Func`3<Microsoft.Extensions.Logging.FormattedLogValues,System.Exception,System.String>)
   at Microsoft.Extensions.Logging.Logger.<Log>g__LoggerLog|12_0[[Microsoft.Extensions.Logging.FormattedLogValues, Microsoft.Extensions.Logging.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](Microsoft.Extensions.Logging.LogLevel, Microsoft.Extensions.Logging.EventId, Microsoft.Extensions.Logging.ILogger, System.Exception, System.Func`3<Microsoft.Extensions.Logging.FormattedLogValues,System.Exception,System.String>, System.Collections.Generic.List`1<System.Exception> ByRef, Microsoft.Extensions.Logging.FormattedLogValues ByRef)
   at Microsoft.Extensions.Logging.Logger.Log[[Microsoft.Extensions.Logging.FormattedLogValues, Microsoft.Extensions.Logging.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](Microsoft.Extensions.Logging.LogLevel, Microsoft.Extensions.Logging.EventId, Microsoft.Extensions.Logging.FormattedLogValues, System.Exception, System.Func`3<Microsoft.Extensions.Logging.FormattedLogValues,System.Exception,System.String>)
   at Microsoft.Extensions.Logging.Logger`1[[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Microsoft.Extensions.Logging.ILogger.Log[[Microsoft.Extensions.Logging.FormattedLogValues, Microsoft.Extensions.Logging.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](Microsoft.Extensions.Logging.LogLevel, Microsoft.Extensions.Logging.EventId, Microsoft.Extensions.Logging.FormattedLogValues, System.Exception, System.Func`3<Microsoft.Extensions.Logging.FormattedLogValues,System.Exception,System.String>)
   at Microsoft.Extensions.Logging.LoggerExtensions.Log(Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.LogLevel, Microsoft.Extensions.Logging.EventId, System.Exception, System.String, System.Object[])
   at Microsoft.Extensions.Logging.LoggerExtensions.Log(Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.LogLevel, System.Exception, System.String, System.Object[])
   at Sentry.Extensions.Logging.MelDiagnosticLogger.Log(Sentry.SentryLevel, System.String, System.Exception, System.Object[])
   at Sentry.Extensibility.DiagnosticLoggerExtensions.LogIfEnabled(Sentry.Extensibility.IDiagnosticLogger, Sentry.SentryLevel, System.String, System.Exception)
   at Sentry.Extensibility.DiagnosticLoggerExtensions.LogDebug(Sentry.Extensibility.IDiagnosticLogger, System.String)
   at Sentry.Internal.SentryScopeManager.ConfigureScope(System.Action`1<Sentry.Scope>)
   at Sentry.Internal.Hub.ConfigureScope(System.Action`1<Sentry.Scope>)
   at Sentry.SentrySdk.ConfigureScope(System.Action`1<Sentry.Scope>)
   at Sentry.Extensibility.HubAdapter.ConfigureScope(System.Action`1<Sentry.Scope>)
   at Sentry.HubExtensions.AddBreadcrumb(Sentry.IHub, Sentry.Infrastructure.ISystemClock, System.String, System.String, System.String, System.Collections.Generic.IDictionary`2<System.String,System.String>, Sentry.Protocol.BreadcrumbLevel)
   at Sentry.Extensions.Logging.SentryLogger.Log[[Microsoft.Extensions.Logging.FormattedLogValues, Microsoft.Extensions.Logging.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](Microsoft.Extensions.Logging.LogLevel, Microsoft.Extensions.Logging.EventId, Microsoft.Extensions.Logging.FormattedLogValues, System.Exception, System.Func`3<Microsoft.Extensions.Logging.FormattedLogValues,System.Exception,System.String>)
   at Microsoft.Extensions.Logging.Logger.<Log>g__LoggerLog|12_0[[Microsoft.Extensions.Logging.FormattedLogValues, Microsoft.Extensions.Logging.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](Microsoft.Extensions.Logging.LogLevel, Microsoft.Extensions.Logging.EventId, Microsoft.Extensions.Logging.ILogger, System.Exception, System.Func`3<Microsoft.Extensions.Logging.FormattedLogValues,System.Exception,System.String>, System.Collections.Generic.List`1<System.Exception> ByRef, Microsoft.Extensions.Logging.FormattedLogValues ByRef)
   at Microsoft.Extensions.Logging.Logger.Log[[Microsoft.Extensions.Logging.FormattedLogValues, Microsoft.Extensions.Logging.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](Microsoft.Extensions.Logging.LogLevel, Microsoft.Extensions.Logging.EventId, Microsoft.Extensions.Logging.FormattedLogValues, System.Exception, System.Func`3<Microsoft.Extensions.Logging.FormattedLogValues,System.Exception,System.String>)
   at Microsoft.Extensions.Logging.Logger`1[[System.__Canon, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Microsoft.Extensions.Logging.ILogger.Log[[Microsoft.Extensions.Logging.FormattedLogValues, Microsoft.Extensions.Logging.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](Microsoft.Extensions.Logging.LogLevel, Microsoft.Extensions.Logging.EventId, Microsoft.Extensions.Logging.FormattedLogValues, System.Exception, System.Func`3<Microsoft.Extensions.Logging.FormattedLogValues,System.Exception,System.String>)
   at Microsoft.Extensions.Logging.LoggerExtensions.Log(Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.LogLevel, Microsoft.Extensions.Logging.EventId, System.Exception, System.String, System.Object[])
   at Microsoft.Extensions.Logging.LoggerExtensions.Log(Microsoft.Extensions.Logging.ILogger, Microsoft.Extensions.Logging.LogLevel, System.Exception, System.String, System.Object[])
   at Sentry.Extensions.Logging.MelDiagnosticLogger.Log(Sentry.SentryLevel, System.String, System.Exception, System.Object[])
   at Sentry.Extensibility.DiagnosticLoggerExtensions.LogIfEnabled(Sentry.Extensibility.IDiagnosticLogger, Sentry.SentryLevel, System.String, System.Exception)
   at Sentry.Extensibility.DiagnosticLoggerExtensions.LogDebug(Sentry.Extensibility.IDiagnosticLogger, System.String)
   at Sentry.Internal.SentryScopeManager.ConfigureScope(System.Action`1<Sentry.Scope>)
   at Sentry.Internal.Hub.ConfigureScope(System.Action`1<Sentry.Scope>)
   at Sentry.SentrySdk.ConfigureScope(System.Action`1<Sentry.Scope>)
   at Sentry.Extensibility.HubAdapter.ConfigureScope(System.Action`1<Sentry.Scope>)
   at Sentry.HubExtensions.AddBreadcrumb(Sentry.IHub, Sentry.Infrastructure.ISystemClock, System.String, System.String, System.String, System.Collections.Generic.IDictionary`2<System.String,System.String>, Sentry.Protocol.BreadcrumbLevel)
   at Sentry.Extensions.Logging.SentryLogger.Log[[Microsoft.Extensions.Logging.FormattedLogValues, Microsoft.Extensions.Logging.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](Microsoft.Extensions.Logging.LogLevel, Microsoft.Extensions.Logging.EventId, Microsoft.Extensions.Logging.FormattedLogValues, System.Exception, System.Func`3<Microsoft.Extensions.Logging.FormattedLogValues,System.Exception,System.String>)
   at Microsoft.Extensions.Logging.Logger.<Log>g__LoggerLog|12_0[[Microsoft.Extensions.Logging.FormattedLogValues, Microsoft.Extensions.Logging.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](Microsoft.Extensions.Logging.LogLevel, Microsoft.Extensions.Logging.EventId, Microsoft.Extensions.Logging.ILogger, System.Exception, System.Func`3<Microsoft.Extensions.Logging.FormattedLogValues,System.Exception,System.String>, System.Collections.Generic.List`1<System.Exception> ByRef, Microsoft.Extensions.Logging.FormattedLogValues ByRef)
   at Microsoft.Extensions.Logging.Logger.Log[[Microsoft.Extensions.Logging.FormattedLogValues, Microsoft.Extensions.Logging.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]](Microsoft.Extensions.Logging.LogLevel, Microsoft.Extensions.Logging.EventId, Micr

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
Tyrrrzcommented, Feb 1, 2021

@jovnas thanks for pointing that out!

2reactions
jovnascommented, Feb 1, 2021

@Tyrrrz After some testing, it turns out this is probably not a new issue at all! I get the same error down to version 1.0.0 if I explicitly configure Sentry to behave the same way. (in appsettings: Logging.Default = Debug, Sentry.Diagnostic(s)Level = Debug, Sentry.Debug = true)

I guess the main reason this issue popped up now, with the release of version 3, is the new name of DiagnosticLevel. I missed that the property was renamed and the project I was working on broke when upgrading the NuGet package to v3 from v2.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Debug .net core Application System. ...
Go to: Debug/Windows/Exception Settings and make sure Common Language Runtime Exceptions is turned on. This should point you to the place ...
Read more >
Debugging StackOverflow errors
In this article ... A StackOverflowException is thrown when the execution stack overflows because it contains too many nested method calls.
Read more >
Logging in .NET Core and ASP.NET Core
Learn how to use the logging framework provided by the Microsoft.Extensions.Logging NuGet package.
Read more >
Logging in C# - .NET
When a LogLevel is specified, logging is enabled for messages at the specified level and higher. In the preceding JSON, the Default category ......
Read more >
StackOverflowException Class (System)
The exception that is thrown when the execution stack exceeds the stack size. This class cannot be inherited.
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