Comments (8)
You can configure the minimal level which a log entry has to be equal or higher in order to record a breadcrumb:
There's the same for sending event:
Besides that, you can use the MEL filter settings, like in this example:
In this example, I completely disable log messages coming from ExceptionHandlerMiddleware
for the SentryLogger
. Your other loggers will still get those messages, but they won't reach the SentryLogger
.
One other approach is using the Filter
property in the SentryLoggingOptions
object:
sentry-dotnet/src/Sentry.AspNetCore/SentryAspNetCoreOptionsSetup.cs
Lines 27 to 37 in c6c27e3
One caveat is that besides the first switches that set different levels for Breadcrumb and Sending event, the others will avoid the log message becoming a either a breadcrumb or an event.
from sentry-dotnet.
To give a better API to add filters, I raised this PR: #90
Having the IReadOnlyList<IFilter>
wasn't really the best experience I believe.
from sentry-dotnet.
Great, thanks for all the details
from sentry-dotnet.
Let me know how that works out for you. I'm using the API on a project but haven't had to filter too much stuff yet
from sentry-dotnet.
I'm having trouble getting a Log filter working with an Asp.Net core app running Sentry 1.0, here is my sample code:
.UseSentry(o =>
{
o.Dsn = Environment.GetEnvironmentVariable("SENTRY_DSN");
o.MinimumEventLevel = LogLevel.Critical;
o.MinimumBreadcrumbLevel = LogLevel.Warning;
o.AddLogEntryFilter((category, level, eventId, exception) => string.Equals(category, "Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager", StringComparison.Ordinal));
}
I am seeing breadcrumbs with this category.
from sentry-dotnet.
From what I can tell in SentryLogger.cs, even though the extension method says it's for messages & breadcrumbs, the filters are only applied to logged messages. So even if a message is filtered from going to Sentry it's still added to the breadcrumb list.
from sentry-dotnet.
Perhaps it was documented wrong in this case, could you please point me where it mentions filtering breadcrumbs so I can fix it?
There's a BeforeBreadcrumb
callback that could be used to filter breadcrumbs. The logger category goes into the breadcrumb category so it's a good way to filter IMHO.
In case you don't want it either as event nor as breadcrumb, perhaps using the framework's filter?
Somethingnlike on appsettings.json:
{
"Logging": {
"LogLevel": {
"Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager": "None"
}
}
from sentry-dotnet.
Perhaps it was documented wrong in this case, could you please point me where it mentions filtering breadcrumbs so I can fix it?
There's a
BeforeBreadcrumb
callback that could be used to filter breadcrumbs. The logger category goes into the breadcrumb category so it's a good way to filter IMHO.In case you don't want it either as event nor as breadcrumb, perhaps using the framework's filter?
Somethingnlike on appsettings.json:
{ "Logging": { "LogLevel": { "Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager": "None" } }
In SentryLoggingOptionsExtensions.cs, the extension method comment says:
/// Filters are called before recording a log message as a breadcrumb or sending event.
/// This allows the filter to decide whether the log message should not be recorded at all.
from sentry-dotnet.
Related Issues (20)
- Merge upstream AOT improvements into the Sentry Ben.Demystifier fork
- Some errors not captured if out of performance units HOT 11
- Getting start-up exception: System.TypeLoadException: Could not load type 'Sentry.SentryOptionsExtensions HOT 3
- Unable to Deploy Azure Function when using Sentry v4.x HOT 1
- `GetFlushableBuckets_IsThreadsafe` failed on CI HOT 2
- Add ServiceCollection extensions for native Android and iOS projects HOT 3
- User ID is left blank on Android HOT 2
- High memory usage from ISpan[] and SpanTracer HOT 4
- Sentry assembly produces trim warnings when compiling AOT HOT 1
- System.IO.IOException in DebugStackTrace
- Hangfire not in cron HOT 1
- Add logs to `metrics`
- Remove FirstChanceException workaround
- Try to populate DeviceInfo if/when sentry-native is available
- Add the Refit Exception Content to Sentry HOT 4
- Improve OutOfMemory insight
- Incorrect stack traces for UWP in .NET Native HOT 5
- Filter out health check transactions HOT 6
- Cocoa Issues
- Enhanced Stack Frames with Native AOT HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sentry-dotnet.