X.Extensions.Logging.Telegram
3.0.0
Prefix Reserved
dotnet add package X.Extensions.Logging.Telegram --version 3.0.0
NuGet\Install-Package X.Extensions.Logging.Telegram -Version 3.0.0
<PackageReference Include="X.Extensions.Logging.Telegram" Version="3.0.0" />
<PackageVersion Include="X.Extensions.Logging.Telegram" Version="3.0.0" />
<PackageReference Include="X.Extensions.Logging.Telegram" />
paket add X.Extensions.Logging.Telegram --version 3.0.0
#r "nuget: X.Extensions.Logging.Telegram, 3.0.0"
#:package X.Extensions.Logging.Telegram@3.0.0
#addin nuget:?package=X.Extensions.Logging.Telegram&version=3.0.0
#tool nuget:?package=X.Extensions.Logging.Telegram&version=3.0.0
X.Extensions.Logging.Telegram
Telegram logging provider for Microsoft.Extensions.Logging. Receive important log messages directly on your phone or laptop.
dotnet add package X.Extensions.Logging.Telegram
Targets netstandard2.0 and net10.0.
Prepare Telegram bot and channel
- Create a Telegram bot and copy its access token.
- Add the bot to your channel or chat as an admin with permission to post messages.
- Get the chat id. For a public channel you can use its name (
@channel_name). For a private channel, forward any message from it to @JsonDumpBot to get the id.
Configure in code
var options = new TelegramLoggerOptions(LogLevel.Information)
{
AccessToken = "1234567890:AAAaaAAaa_AaAAaa-AAaAAAaAAaAaAaAAAA",
ChatId = "-0000000000000",
FormatterConfiguration = new FormatterConfiguration
{
ReadableApplicationName = "Human Readable Project Name",
UseEmoji = true,
IncludeException = true
}
};
builder.Logging
.ClearProviders()
.AddTelegram(options)
.AddConsole();
Or with a delegate:
builder.Logging.AddTelegram(options =>
{
options.AccessToken = "...";
options.ChatId = "...";
options.FormatterConfiguration.ReadableApplicationName = "My App";
});
Configure with appsettings.json
{
"Logging": {
"LogLevel": {
"Default": "Information"
},
"Telegram": {
"LogLevel": {
"Default": "Error",
"WebApp.Controllers": "Warning"
},
"AccessToken": "1234567890:AAAaaAAaa_AaAAaa-AAaAAAaAAaAaAaAAAA",
"ChatId": "1234567890",
"FormatterConfiguration": {
"ReadableApplicationName": "Human Readable Project Name",
"UseEmoji": true,
"IncludeException": true
}
}
}
}
and pass IConfiguration to the extension method:
builder.Logging.AddTelegram(builder.Configuration);
Formatter options
| Option | Description |
|---|---|
ReadableApplicationName |
Application name shown in every message. |
UseEmoji |
Prefix the log level with an emoji. |
IncludeException |
Include the exception details. |
IncludeProperties |
Include log entry properties. |
TimeZone |
Time zone for timestamps. UTC by default. |
Custom log writer
Implement ILogWriter to deliver messages your own way:
builder.Logging.AddTelegram(options, new CustomLogWriter());
Custom message formatter
Implement IMessageFormatter (or derive from MessageFormatterBase) and pass a factory. The factory receives the logger category name:
builder.Logging.AddTelegram(options, category => new CustomMessageFormatter(category));
Examples
The examples folder contains a console app and a web app.
Contributing
Feel free to add any improvements you want via pull requests. All pull requests must be linked to an issue.
License
This project is licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.Logging.Configuration (>= 10.0.14)
- Telegram.Bot (>= 22.10.3.3)
-
net10.0
- Microsoft.Extensions.Logging.Configuration (>= 10.0.14)
- Telegram.Bot (>= 22.10.3.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.0 | 345 | 10/29/2026 |
| 2.0.2 | 3,193 | 1/1/2025 |
| 2.0.1-rc | 230 | 10/27/2024 |
| 2.0.0-beta | 234 | 8/30/2024 |
| 1.0.7 | 1,885 | 7/9/2024 |
| 1.0.6.1 | 3,879 | 3/5/2023 |
| 1.0.5.1 | 7,253 | 4/25/2022 |
| 1.0.4-preview | 440 | 12/20/2021 |
| 1.0.3 | 2,688 | 12/18/2021 |
| 1.0.2.1 | 685 | 11/5/2021 |
| 1.0.2 | 617 | 11/1/2021 |
| 1.0.1.5 | 987 | 6/27/2021 |
| 1.0.1.3 | 11,605 | 1/26/2021 |
| 1.0.1.2 | 590 | 1/26/2021 |