Web adapter for ExceptionSender to catch unhandled pipeline errors.
$ dotnet add package Logging.ExceptionSender.WebWatches for unhandled exceptions, saves details to text files in specific folder, starts background task that sends exception info to you (MailGun and Telegram are supported, add your own if needed).
Written for console/worker projects that use RecurrentTasks and for ASP.NET projects (via Logging.ExceptionSender.Web).
log subdirectory for later processing;ExceptionSenderTask;To).Use NuGet package Logging.ExceptionSender for console/worker projects, or Logging.ExceptionSender.Web for web projects.
See Sample project.
Put values into appsettings file:
{
"ExceptionSender": {
// For Mailgun
"MailgunDomain": "example.com",
"MailgunApiKey": "key-*************",
"From": "myapp@example.com",
"To": [ "admin1@example.com", "admin2@example.com" ],
// For Telegram
"ChatId": "",
"BotToken": ""
}
}
services.AddMailgunExceptionSender(Configuration.GetSection("ExceptionSender"));
// or
services.AddTelegramExceptionSender(Configuration.GetSection("ExceptionSender"));
Append .WithExceptionSender() to task configuration:
services.AddTask<SomeTask>(o => o.AutoStart(...).WithExceptionSender());
Append .UseExceptionSender() to aspnet request pipeline:
app.UseExceptionSender();
var loggerFactory = app.Services.GetRequiredService<ILoggerFactory>();
loggerFactory.AddMemory(LogLevel.Debug);
Microsoft.Extensions.Http (for HttpClient)