X.Extensions.Logging.Telegram 1.0.2

.NET Standard 2.0
There is a newer version of this package available.
See the version list below for details.
dotnet add package X.Extensions.Logging.Telegram --version 1.0.2
NuGet\Install-Package X.Extensions.Logging.Telegram -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="X.Extensions.Logging.Telegram" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add X.Extensions.Logging.Telegram --version 1.0.2
#r "nuget: X.Extensions.Logging.Telegram, 1.0.2"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install X.Extensions.Logging.Telegram as a Cake Addin
#addin nuget:?package=X.Extensions.Logging.Telegram&version=1.0.2

// Install X.Extensions.Logging.Telegram as a Cake Tool
#tool nuget:?package=X.Extensions.Logging.Telegram&version=1.0.2

NuGet Version

X.Extensions.Logging.Telegram

Telegram logging provider

What is Telegram?

What is Telegram? What do I do here? Telegram is a messaging app with a focus on speed and security, it’s super-fast, simple and free. You can use Telegram on all your devices at the same time β€” your messages sync seamlessly across any number of your phones, tablets or computers. Telegram has over 500 million monthly active users and is one of the 10 most downloaded apps in the world.

Why you need write logs to Telegram?

Because it very comfortable - you can receive important messages directly to your smartphone or laptop.

Prepare Telegram bot

For sending log messages into telegram channel or chat you need create telegram bot before. Here you can find how to do it. After you created bot add it to channel with admin role and allow bot to post messages.

Prepare Telegram channel

In telegram there are two types of channels: public and private. For public channel you can use channel name as ChatId in configuration.

For private channel you can use @JsonDumpBot to get private channel id. Just forward any message from private channelto this bot. Additional information you can find here.

Configure Telegram Logging provider

You can configure Telegram logging provider by code or by config file:

Code

var options = new TelegramLoggerOptions
{
    AccessToken = "1234567890:AAAaaAAaa_AaAAaa-AAaAAAaAAaAaAaAAAA",
    ChatId = "-0000000000000",
    LogLevel = LogLevel.Information,
    Source = "Human Readable Project Name"
};

...


builder
  .ClearProviders()
  .AddTelegram(options)
  .AddConsole();
                        

appconfig.json

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    },
    "Telegram": {
      "LogLevel": "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>(); });
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

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
1.0.5.1 1,269 4/25/2022
1.0.4-preview 102 12/20/2021
1.0.3 1,160 12/18/2021
1.0.2.1 321 11/5/2021
1.0.2 244 11/1/2021
1.0.1.5 585 6/27/2021
1.0.1.3 5,252 1/26/2021
1.0.1.2 216 1/26/2021