-
-
Notifications
You must be signed in to change notification settings - Fork 472
-
I've recently trying Sentry. I like it very much, there's just one thing I do not know how to solve.
I'm using the starter and the logback dependencies. In application.properties configure a few things. And that's all I've got for Sentry.
Issues reach the Sentry server and I can see them.
The problem I having is that I use a lot log.error. And as default they every log.error is sent to Sentry and treated as issue. That flood the dashboard and I miss the real important for me.
Is there a simple way (preferible via application.properties) to instruct Sentry not to grab log.error and send them as issues? I do want to keep breadcrumbs, I just don't want that a log messages is treated as an issue.
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions
Hey @sebasira , you could filter events in beforeSend. Heres some docs for it. The easiest way to register it for a Spring Boot application is to register a bean:
@Bean
public SentryOptions.BeforeSendCallback beforeSendCallback() {
return ((event, hint) -> {
if (event.getLogger() != null) {
return null;
}
return event;
});
}
Replies: 2 comments 2 replies
-
Hey @sebasira , you could filter events in beforeSend. Heres some docs for it. The easiest way to register it for a Spring Boot application is to register a bean:
@Bean
public SentryOptions.BeforeSendCallback beforeSendCallback() {
return ((event, hint) -> {
if (event.getLogger() != null) {
return null;
}
return event;
});
}
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
Thank you @adinauer ! I'll try that.
One more question related to this.
Also some times when I catch an exception I print the stack trace so if the problem is bigger I could understand what's going on. So for example I have.
} catch (SomeException ex){ log.error("Something went wrong with......."); ex.printStackTrace() ... ... }
And in the Sentry dashboard I see the log.error (which you told me how to disable) and also the stackTrace. How can I also skip sending the stackTrace?
Beta Was this translation helpful? Give feedback.
All reactions
-
That stack trace should also be coming from log.error and go away at the same time as ex.printStackTrace() just prints to Standard.err which shouldn't be intercepted and thus not sent to Sentry.
Beta Was this translation helpful? Give feedback.
All reactions
-
Nice! Thank you for your assistance!
Beta Was this translation helpful? Give feedback.
All reactions
-
❤️ 1