Logging.ExceptionSender 4.4.0

dotnet add package Logging.ExceptionSender --version 4.4.0
NuGet\Install-Package Logging.ExceptionSender -Version 4.4.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Logging.ExceptionSender" Version="4.4.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Logging.ExceptionSender --version 4.4.0
#r "nuget: Logging.ExceptionSender, 4.4.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Logging.ExceptionSender as a Cake Addin
#addin nuget:?package=Logging.ExceptionSender&version=4.4.0

// Install Logging.ExceptionSender as a Cake Tool
#tool nuget:?package=Logging.ExceptionSender&version=4.4.0

Logging.ExceptionSender

ExceptionSenderMiddleware watches for unhandled exceptions. When found - details are saved to text files in specific folder.

ExceptionSenderTask monitors that folder and sends exception info to you by email (using MailGun.com, but you can add your own)

Written for ASP.NET Core (ASP.NET 5, ASP.NET vNext) projects.

NuGet

Main features

  • Exception message and stacktrace are captured;
  • Last N log records captured (Logging.Memory is used);
  • Captured data saved in logs subdirectory for later processing;
  • Task (based on RecurrentTasks) is used for checking new exception data;
  • Every single exception - one email to you;
  • MailGun is used to send emails (free quota 10K emails/month), you can add new mail providers (inherit from ExceptionSenderTask);
  • When new exception is caught - tries to send immediately;
  • When message sucessfully sent - files are deleted from disk;
  • Can send message to multiple recipients (multiple To)

Installation

Use NuGet package Logging.ExceptionSender

Dependencies

Usage

1. Register at MailGun.com (if needed)

If you wish to use MailGun for sending mail, you need to create account (or use existing one, if any).

Register your site at MailGun.com and write down your domain name and api key:

"sample

2. Configure/initialize in Startup.cs

Sample (minimum) configuration in config.json (aka appsettings.json):

{
    ...
    "ExceptionSender": {
        "MailgunBaseUrl": "https://api.mailgun.net/v3/", // some accounts need https://api.eu.mailgun.net/v3/
        "MailgunDomain": "example.com",
        "MailgunApiKey": "key-*************",
        "From": "myapp@example.com",
        "To": ["admin1@example.com", "admin2@example.com"]
    }
    ...
}

In ConfigureServices method of your Startup.cs:

services.AddMailgunExceptionSender(Configuration.GetSection("ExceptionSender"));

In Configure method of your Statup.cs:

// Enable in-memory logging
loggerFactory.AddMemory();

// Activate ExceptionSender middleware to catch ASP exceptions
app.UseExceptionSender();

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Logging.ExceptionSender:

Package Downloads
ExceptionSenderSmtp

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
4.4.0 453 11/10/2023
4.3.1 130 11/3/2023
4.3.0 171 7/26/2023
4.2.0 2,059 4/15/2022
4.1.0 441 4/15/2022
4.0.0 3,379 2/10/2020
4.0.0-RC2 454 12/17/2019
4.0.0-RC1 396 12/16/2019
3.5.0 1,401 10/12/2018
3.4.1 1,479 2/14/2018
3.3.0 1,947 9/14/2017
3.2.0 1,406 2/10/2017
3.1.0 1,740 11/3/2016
3.0.0 1,064 10/31/2016
3.0.0-beta2 903 10/22/2016
3.0.0-beta1 908 10/22/2016
2.2.1 1,499 7/18/2016
2.2.0 1,255 7/15/2016
2.1.0 1,329 6/28/2016
2.1.0-preview2 1,161 5/24/2016
2.0.0 1,149 5/20/2016
1.0.0 1,581 2/8/2016

Trim too long log file (use LogFileMaxSize option, default is 10MB).