serilog-contrib / serilog-sinks-teams

A Serilog event sink that writes to Microsoft Teams
MIT License
18 stars 11 forks source link

Serilog.Sinks.MicrosoftTeams


NuGet Version

A Serilog event sink that writes to Microsoft Teams.

Package - Serilog.Sinks.MicrosoftTeams | Platforms - .NETStandard 1.1

You need to add an "Incoming Webhook" connector to your Teams channel and get it's URL. title is optional but can help your distinguish logs coming from different sources.

var log = new LoggerConfiguration()
    .WriteTo.MicrosoftTeams(webHookUri, title: title)
    .CreateLogger();

JSON configuration

It is possible to configure the sink using Serilog.Settings.Configuration by specifying the table name and connection string in appsettings.json:

"Serilog": {
  "WriteTo": [
    {"Name": "MicrosoftTeams", "Args": {"webHookUri": "", "title": ""}}
  ]
}

JSON configuration must be enabled using ReadFrom.Configuration(); see the documentation of the JSON configuration package for details.