kimsey0 / serilog-sinks-slack

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

serilog-sinks-slack

Simple and beautiful Serilog Slack sink :)

NuGet

Install-Package Serilog.Sinks.Slack

Sample

Sample

Usages

Minimal (using default WebHook integration settings)

Log.Logger = new LoggerConfiguration()
    .WriteTo.Slack("https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    .CreateLogger();

Custom channel, username or icon:

Log.Logger = new LoggerConfiguration()
    .WriteTo.Slack("https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",  20, TimeSpan.FromSeconds(10), "#general" ,"Im a Ghost", ":ghost:")
    .CreateLogger();

Advanced:

 Log.Logger = new LoggerConfiguration()
    .MinimumLevel.Verbose()
    .WriteTo.Slack(new SlackSinkOptions()
        {
            WebHookUrl = "https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
            CustomChannel = "#test",
            BatchSizeLimit = 20,
            CustomIcon = ":ghost:",
            Period = TimeSpan.FromSeconds(10),
            ShowDefaultAttachments = false,
            ShowExceptionAttachments = true,
        })
        .CreateLogger();

About

License:MIT License


Languages

Language:C# 100.0%