This is the .Net Honeybadger Notifier.
All modern .Net Core applications are supported, up to .Net 9.0.
The Honeybadger Notifier can be configured using the HoneybadgerOptions
class.
Honeybadger can be configured by passing the options when registering the service,
or through your appsettings.json
file.
Honeybadger, by default, will not report errors in development environments.
You can override the development environments by setting the DevelopmentEnvironments
property in the options.
Alternatively, you can set the ReportData
property to true
to report errors in all environments.
See below for examples on how to configure Honeybadger for different types of applications.
-
Install Honeybadger.DotNetCore from Nuget
dotnet add package Honeybadger.DotNetCore
-
Register the Honeybadger Middleware:
var builder = WebApplication.CreateBuilder(args); builder.AddHoneybadger(new HoneybadgerOptions("apiKey"));
Or you can configure Honeybadger through your
appsettings.json
file, by adding aHoneybadger
section:{ "Honeybadger": { "ApiKey": "apiKey", "AppEnvironment": "Development", "ReportData": true } }
And simply call
AddHoneybadger
without any parameters:var builder = WebApplication.CreateBuilder(args); builder.AddHoneybadger();
You can access the Honeybadger Client using DI:
app.MapGet("/", ([FromServices] IHoneybadgerClient client) =>
{
client.AddBreadcrumb("reached index route", "route", new Dictionary<string, object?>());
return "Hello World!";
});
Any unhandled exceptions should be reported to Honeybadger automatically (unless ReportUnhandledExceptions
is set to false):
app.MapGet("/debug", () =>
{
throw new Exception("hello from .Net Core Web App!");
});
See example project in examples/Honeybadger.DotNetCoreWebApp
.
-
Install Honeybadger.Extensions.Logging from Nuget
dotnet add package Honeybadger.Extensions.Logging
-
Register Honeybadger and additionally the custom logging provider:
var builder = WebApplication.CreateBuilder(args); // or set the configuration in the appsettings.json file builder.AddHoneybadger(new HoneybadgerOptions("apiKey")); builder.Logging.AddHoneybadger();
You should also configure the minimum log level as you would configure other log providers in .Net Core. The following would report only logged errors:
{ "Logging": { "Honeybadger": { "Default": "Error" } } }
And simply call
AddHoneybadger
andLogging.AddHoneybadger
without any parameters:var builder = WebApplication.CreateBuilder(args); builder.AddHoneybadger(); builder.Logging.AddHoneybadger();
Note: If you want to disable automatic reporting of unhandled exceptions, you can set the
ReportUnhandledExceptions
property tofalse
in theHoneybadgerOptions
:{ "Honeybadger": { "ApiKey": "apiKey", "AppEnvironment": "Development", "ReportData": true, "ReportUnhandledExceptions": false } }
Errors from the logger
will be reported to Honeybadger:
app.MapGet("/notify", ([FromServices] ILogger logger) =>
{
logger.LogError("hello from Honeybadger.Logger!");
return "Log reported to Honeybadger. Check your dashboard!";
});
See example project in examples/Honeybadger.DotNetCoreWebApp.Logger
.
- Install the Honeybadger Nuget.
dotnet add package Honeybadger
- Initialize the Honeybadger Client:
using Microsoft.Extensions.Options; var options = new HoneybadgerOptions("apiKey"); var client = new HoneybadgerClient(Options.Create(options));
- Call
notify
to report to Honeybadger:// blocking client.Notify("hello from .Net !"); // or async await client.NotifyAsync("hello from .Net !");
See example project in examples/Honeybadger.Console
.
Changelog is automatically generated using Conventional Commits with versionize. Conventional Commits are enforced with a pre-commit git hook (using husky).
- Fork the repo.
- Create a topic branch git checkout -b my_branch
- Commit your changes git commit -am "chore: boom"
- Write a test that verifies your changes
- Push to your branch git push origin my_branch
- Send a pull request
- Make sure that CI checks are passing
All packages are published on nuget.org with a Github Actions Worfklow. The workflow does the following:
dotnet versionize
- bump versions and generate changelogdotnet pack
dotnet package push
Note: only users with write permissions can trigger this workflow (i.e. Collaborators).
- Publish README with basic info to setup core nuget
- Publish Honeybadger.DotNetCore with README
- Publish Honeybadger.Extensions.Logging with README
- Implement Error Grouping (custom fingerprint)
- Implement Error Tags
- Allow excluding errors (either with a BeforeNotify method or exception classes config)
- Implement Filter Keys (exclude sensitive keys)
- Implement Checkins
- Implement Collect User Feedback
- Create guide for Deployment Tracking
- Create integration guide in honeybadger-docs project
This Honeybadger repository and published packages are MIT licensed. See the MIT-LICENSE file in this repository for details.