1️⃣: Get WebhookId
and WebhookToken
Create webhoook and copy its url which contains WebhookId and WebhookToken:
https://discordapp.com/api/webhooks/{WebhookId}/{WebhookToken}
2️⃣: Install nuget package
3️⃣: 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();