Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MinimumEventLevel to Sentry.Log4Net and convert events below it to breadcrumbs #2505

Merged
merged 17 commits into from Jul 31, 2023

Conversation

IhateTrains
Copy link
Contributor

@IhateTrains IhateTrains commented Jul 22, 2023

Both NLog and Serilog integrations already feature MinimumEventLevel. I attempted to also add it for log4net, hope its implementation is acceptable to you.

If MinimumEventLevel is specified, every log4net LoggingEvent above threshold and below MinimumEventLevel will be converted to a breadcrumb.

Heavily inspired by this solution from SO:
https://stackoverflow.com/a/62923187/10249243

@IhateTrains IhateTrains marked this pull request as ready for review July 22, 2023 16:03
@IhateTrains IhateTrains changed the title Add breadcrumbs below MinimumEventLevel for log4net Add MinimumEventLevel to Sentry.Log4Net and convert events below it to breadcrumbs Jul 22, 2023
Copy link
Collaborator

@jamescrosswell jamescrosswell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@IhateTrains thank you so much for the contribution.

I added a few comments but generally looking pretty good 👍🏻

src/Sentry.Log4Net/LevelMapping.cs Outdated Show resolved Hide resolved
test/Sentry.Log4Net.Tests/SentryAppenderTests.cs Outdated Show resolved Hide resolved
test/Sentry.Log4Net.Tests/SentryAppenderTests.cs Outdated Show resolved Hide resolved
src/Sentry.Log4Net/SentryAppender.cs Outdated Show resolved Hide resolved
@jamescrosswell
Copy link
Collaborator

This is looking great @IhateTrains ! Just the small tweak to be made to LevelMappings and then getting the build checks passing. Let me know if you need any guidance/help working out the problems with the builds.

ℹ️ One tip in that respect is search for the text Failed!, since that's a marker for any failed unit tests...

@IhateTrains
Copy link
Contributor Author

@jamescrosswell turns out the Hub.IsEnabled.Returns(true); I copied from another test class' fixture was a problem; after removing it all checks are passing.

Copy link
Collaborator

@jamescrosswell jamescrosswell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @IhateTrains ! Thanks heaps for the contribution 👍🏻

jamescrosswell and others added 2 commits July 31, 2023 12:30
Co-authored-by: Sean Feldman <SeanFeldman@users.noreply.github.com>
@jamescrosswell jamescrosswell merged commit 0f58599 into getsentry:main Jul 31, 2023
14 checks passed
@IhateTrains IhateTrains deleted the log4net-breadcrumbs branch July 31, 2023 05:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
.NET SDK
Awaiting triage
Development

Successfully merging this pull request may close these issues.

None yet

3 participants