Skip to content

Serilog.Sinks.Telegram is a library to save logging information from Serilog to Telegram. The assembly was written and tested in .Net Framework 4.8 and .Net Standard 2.0.

License

Notifications You must be signed in to change notification settings

LykkeBusinessPlatform/Serilog.Sinks.Telegram

 
 

Repository files navigation

Serilog.Sinks.Telegram

Serilog.Sinks.Telegram is a library to save logging information from Serilog to Telegram. The assembly was written and tested in .Net Framework 4.8 and .Net Standard 2.0.

Build status GitHub issues GitHub forks GitHub stars License: MIT Nuget NuGet Downloads Known Vulnerabilities Gitter

Available for

  • NetFramework 4.6
  • NetFramework 4.6.2
  • NetFramework 4.7
  • NetFramework 4.7.2
  • NetFramework 4.8
  • NetStandard 2.0
  • NetStandard 2.1
  • NetCore 2.1
  • NetCore 3.1

Net Core and Net Framework latest and LTS versions

Basic usage:

var logger = new LoggerConfiguration()
	.WriteTo.Telegram("botToken", "chatId")
    .CreateLogger();

The project can be found on nuget.

Configuration options:

Parameter Meaning Example Default value
botToken The Telegram bot token. "123151488:AAgshf4r373rffsdfOfsdzgfwezfzqwfr7zewE" None, is mandatory.
chatId The Telegram chat id. "12345" None, is mandatory.
period The time to wait between checking for event batches. period: new TimeSpan(0, 0, 20) 00:00:05
formatProvider The IFormatProvider to use. Supplies culture-specific formatting information. Check https://docs.microsoft.com/en-us/dotnet/api/system.iformatprovider?view=netframework-4.8. new CultureInfo("de-DE") null
batchSizeLimit The maximum number of events to include in a single batch. batchSizeLimit: 40 30
restrictedToMinimumLevel The minimum level of the logging. restrictedToMinimumLevel: LogEventLevel.Verbose LogEventLevel.Verbose
sendBatchesAsSingleMessages A value indicating whether the batches are sent as single messages or as one block of messages. false true

Configuration via JSON options

{
    "Serilog": {
        "Using": [ "Serilog.Sinks.Telegram" ],
        "MinimumLevel": {
            "Default": "Warning"
        },
        "WriteTo": [
            {
                "Name": "Telegram",
                "Args": {
                    "botToken": "123151488:AAgshf4r373rffsdfOfsdzgfwezfzqwfr7zewE",
                    "chatId": "12345",
                    "restrictedToMinimumLevel": "Warning"
                }
            }
        ]
    }
}

Further information

This sink is basically the same as https://github.com/oxozle/serilog-sinks-telegram but is maintained and provides badging of events.

You need to get a bot API token following https://core.telegram.org/api#bot-api.

Change history

See the Changelog.

About

Serilog.Sinks.Telegram is a library to save logging information from Serilog to Telegram. The assembly was written and tested in .Net Framework 4.8 and .Net Standard 2.0.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%