MinimumEventLevel and MinimumBreadcrumbLevel options ignored when configured through AddSentry extension
See original GitHub issuePackage
Sentry.Extensions.Logging
.NET Flavor
.NET
.NET Version
6.0.0
OS
Windows
SDK Version
3.22.0
Self-Hosted Sentry Version
No response
Steps to Reproduce
Console app:
using var loggingFactory = LoggerFactory.Create(builder =>
{
builder.AddSentry(o => {
o.Dsn = "<your dsn here>";
o.MinimumBreadcrumbLevel = LogLevel.Trace;
o.MinimumEventLevel = LogLevel.Information;
o.IsGlobalModeEnabled = true;
});
});
var logger = loggingFactory.CreateLogger<Program>();
// should add a breadcrumb
logger.LogTrace("test trace");
// should send an event to Sentry.io, with the "test trace" breadcrumb above
logger.LogInformation("test information");
// should send a 2nd event to Sentry.io
logger.LogWarning("test warning");
Expected Result
Two events sent to Sentry.io. The first should include a breadcrumb “test trace”.
Actual Result
A single event is sent to Sentry.io, with a breadcrumb “test information”.
Issue Analytics
- State:
- Created a year ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
NLog | Sentry Documentation
Features. Store log messages as breadcrumbs; Send events to sentry. Two separate settings define the minimum log level to keep the log entry...
Read more >Microsoft.Extensions.Logging
Features. Store log messages as breadcrumbs; Send events to sentry. Two separate settings define the minimum log level to keep the log entry...
Read more >Sentry.Extensions.Logging 1.0.0-rc2
Extensions.Logging integration for Sentry - Open-source error tracking that helps developers monitor and fix crashes in real time.
Read more >How to make Sentry Ignore some Exceptions?
I would like to read those exceptions from the app settings file if possible. I tried this, but it did not work. I'm...
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
Changing my mind about this - it certainly is a bug, not an enhancement. The intent was always that
MinimumEventLevel
andMinimumBreadcrumbLevel
could be set independently of any other logging configuration and would work correctly, but presently it is constrained by the default global log level, or the log level set for a particular component or logging category.Fixed in #1992, so that the
MinimumEventLevel
andMinimumBreadcrumbLevel
can be set lower than the default.Ok, researching more, this was helpful (both “Default log level” and “Filter function” right below it). https://learn.microsoft.com/en-us/dotnet/core/extensions/logging#default-log-level
Thus, instead of
SetMinimumLevel
, we can use:That will send all logs to the
SentryLogger
regardless of level, then our ownMinimumBreadcrumbLevel
andMinimumEventLevel
will always work as expected. I’ll see if we can add this toAddSentry
so it’s the default, but you can add it safely to your own code as well.