Search code examples
c#.netlog4netsentry

Using Sentry.NET in conjunction with log4net


I have a question regarding using Sentry.NET in conjunction with log4net.

I installed the Sentry.Log4Net NuGet package and setup the config file according to this example

In general, it works. The Log4net calls are reported to our Sentry account, according to the debug level I configured in the config file.
However, each Log call creates its own Sentry Event. I would've expected that Log4net calls create Sentry "Breadcrumbs". Its not really useful to have hundreds of logging events reporting to the Sentry back end.

Is there a way to change this behavior?


Solution

  • You are right that at this time the Sentry log4net only raises events. If possible, I'd suggest changing to one of the logging libraries that support structured logging like Serilog.

    The other logging integrations have such behavior where you have two log levels to configure. One to set the minimum level to create a breadcrumb, and another to send an event.

    You could raise an issue on GitHub requesting this feature. Or even, contribute with a pull request to change SentryAppender to behave like the SerilogSink, NLog Target or the Microsoft.Extensions.Logging integration.