X.Extensions.Logging.Telegram
2.0.2
Prefix Reserved
dotnet add package X.Extensions.Logging.Telegram --version 2.0.2
NuGet\Install-Package X.Extensions.Logging.Telegram -Version 2.0.2
<PackageReference Include="X.Extensions.Logging.Telegram" Version="2.0.2" />
paket add X.Extensions.Logging.Telegram --version 2.0.2
#r "nuget: X.Extensions.Logging.Telegram, 2.0.2"
// Install X.Extensions.Logging.Telegram as a Cake Addin #addin nuget:?package=X.Extensions.Logging.Telegram&version=2.0.2 // Install X.Extensions.Logging.Telegram as a Cake Tool #tool nuget:?package=X.Extensions.Logging.Telegram&version=2.0.2
X.Extensions.Logging.Telegram
X.Extensions.Logging.Telegram is logging provider for standard .NET logging.
Getting Started
You can configure Telegram logging provider by code or by config file:
var options = new TelegramLoggerOptions(LogLevel.Information)
{
AccessToken = "1234567890:AAAaaAAaa_AaAAaa-AAaAAAaAAaAaAaAAAA",
ChatId = "-0000000000000",
Source = "Human Readable Project Name"
};
...
builder
.ClearProviders()
.AddTelegram(options)
.AddConsole();
appconfig.json
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
},
"Telegram": {
"LogLevel": {
"Default": "Error",
"WebApp.Controllers": "Warning"
},
"AccessToken": "1234567890:AAAaaAAaa_AaAAaa-AAaAAAaAAaAaAaAAAA",
"ChatId": "1234567890",
"Source": "Human Readable Project Name"
}
},
"AllowedHosts": "*"
}
and pass IConfiguration object to extensions method
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureLogging((context, builder) =>
{
if (context.Configuration != null)
builder
.AddTelegram(context.Configuration)
.AddConsole();
})
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); });
Use a custom log writer
Now developers can use their own implementation for writing data to Telegram. Custom writer should implement ILogWriter interface:
var customLogWriter = new CustomLogWriter();
logBuilder.AddTelegram(options, customLogWriter);
Use custom message formatter
For implement custom message formatting ITelegramMessageFormatter can be used now.
private ITelegramMessageFormatter CreateFormatter(string name)
{
return new CustomTelegramMessageFormatter(name);
}
logBuilder.AddTelegram(options, CreateFormatter);
For using custom message formatter delegate Func<string, ITelegramMessageFormatter> should be passed to extensions method AddTelegram. Delegate should be used because formatter needs to know which category is used for rendering the message.
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 is compatible. 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 is compatible. |
.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.Configuration.Binder (>= 9.0.0)
- Microsoft.Extensions.Logging (>= 9.0.0)
- Microsoft.Extensions.Logging.Configuration (>= 9.0.0)
- X.Extensions.Logging.Telegram.Base (>= 2.0.2)
-
net8.0
- Microsoft.Extensions.Configuration.Binder (>= 9.0.0)
- Microsoft.Extensions.Logging (>= 9.0.0)
- Microsoft.Extensions.Logging.Configuration (>= 9.0.0)
- X.Extensions.Logging.Telegram.Base (>= 2.0.2)
-
net9.0
- Microsoft.Extensions.Configuration.Binder (>= 9.0.0)
- Microsoft.Extensions.Logging (>= 9.0.0)
- Microsoft.Extensions.Logging.Configuration (>= 9.0.0)
- X.Extensions.Logging.Telegram.Base (>= 2.0.2)
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 |
---|---|---|
2.0.2 | 60 | 1/1/2025 |
2.0.1-rc | 90 | 10/27/2024 |
2.0.0-beta | 99 | 8/30/2024 |
1.0.7 | 569 | 7/9/2024 |
1.0.6.1 | 3,317 | 3/5/2023 |
1.0.5.1 | 5,448 | 4/25/2022 |
1.0.4-preview | 204 | 12/20/2021 |
1.0.3 | 2,149 | 12/18/2021 |
1.0.2.1 | 466 | 11/5/2021 |
1.0.2 | 386 | 11/1/2021 |
1.0.1.5 | 730 | 6/27/2021 |
1.0.1.3 | 9,052 | 1/26/2021 |
1.0.1.2 | 350 | 1/26/2021 |