Skip to content

Narochno/Narochno.Serilog.Slack

Repository files navigation

Narochno.Serilog.Slack Build status NuGet

A batching Serilog sink for Slack, narochno. Each log message is sent as an attachment on the same message, with the log event properties rendered out as fields.

Screenshot

Example Usage

var webHookUrl = "your webhook URL";
var services = new ServiceCollection();
services.AddSlack(new SlackConfig()
{
    WebHookUrl = webHookUrl 
});
var serviceProvider = services.BuildServiceProvider();
var slackClient = serviceProvider.GetRequiredService<ISlackClient>();

Log.Logger = new LoggerConfiguration()
    .MinimumLevel.Verbose()
    .WriteTo.SlackBlocking(slackClient, LogEventLevel.Information)
    .CreateLogger();

Log.Information("Testing!");

More on correct usage of DI and Serilog on ASP.NET Core can be found here. https://nblumhardt.com/2020/09/serilog-inject-dependencies/

See the Narochno.Slack project for more information.

Releases

No releases published

Packages

No packages published

Languages