serilog-contrib / Serilog-Sinks-Discord

Serilog discord sink
17 stars 11 forks source link
discord log logger serilog sink webhookid

Serilog sink for Discord

Write your logs to discord.

Serilog

Serilog

To get started:

:one:: Get WebhookId and WebhookToken

Create webhoook and copy its url which contains WebhookId and WebhookToken:
https://discordapp.com/api/webhooks/{WebhookId}/{WebhookToken}

:two:: Install nuget package

:three:: Add discord output:

Log.Logger = new LoggerConfiguration()
  .WriteTo.Discord({WebhookId}, {WebhookToken})
  .CreateLogger();

for async logging you can use serilog-sinks-async

Log.Logger = new LoggerConfiguration()
 .WriteTo.Async( a => 
     a.Discord({WebhookId}, {WebhookToken}))
 .Enrich.FromLogContext()
 .CreateLogger();