Skip to content

Latest commit

 

History

History
30 lines (22 loc) · 1.18 KB

README.md

File metadata and controls

30 lines (22 loc) · 1.18 KB

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.