LoggerBot 1.6.0

dotnet add package LoggerBot --version 1.6.0
                    
NuGet\Install-Package LoggerBot -Version 1.6.0
                    
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="LoggerBot" Version="1.6.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LoggerBot" Version="1.6.0" />
                    
Directory.Packages.props
<PackageReference Include="LoggerBot" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LoggerBot --version 1.6.0
                    
#r "nuget: LoggerBot, 1.6.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LoggerBot@1.6.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LoggerBot&version=1.6.0
                    
Install as a Cake Addin
#tool nuget:?package=LoggerBot&version=1.6.0
                    
Install as a Cake Tool

LoggerBot

Telegram bot orqali ASP.NET Core ilovalardan log yuborish uchun NuGet paket. v1.6.0 — IOptions<LoggerBotOptions>, IHttpClientFactory, va multi-target net6-10.

Quick install

dotnet add package LoggerBot --version 1.6.0

Targets

net6.0 / net7.0 / net8.0 / net9.0 / net10.0

Configuration

appsettings.json ichida LoggerBot sectionini to'ldiring:

{
  "LoggerBot": {
    "Token": "123456:bot-token",
    "ChatId": -100123456789
  }
}

Section nomi LoggerBotOptions.SectionName ("LoggerBot") orqali default keladi; options overload bilan o'zingiz qayta belgilashingiz mumkin.

// appsettings.json'dan bind:
builder.Services.AddLoggerBot();

// yoki dasturiy ravishda:
builder.Services.AddLoggerBot(o =>
{
    o.Token = "123456:bot-token";
    o.ChatId = -100123456789;
});

Ikkala overload ham LoggerBotOptions, named HttpClient ("LoggerBot") va ILoggerService singletonni ro'yxatga oladi.

Usage

ILoggerService ni controller yoki handlerga inject qiling. Har bir metod CancellationToken qabul qiladi va u botClient.SendTextMessageAsync ga uzatiladi.

using LoggerBot.Services;
using Microsoft.AspNetCore.Mvc;

[ApiController]
[Route("api/[controller]")]
public class OrdersController : ControllerBase
{
    private readonly ILoggerService _logger;

    public OrdersController(ILoggerService logger) => _logger = logger;

    [HttpPost]
    public async Task<IActionResult> Create(CancellationToken ct)
    {
        await _logger.InfoAsync("Order create boshlandi", cancellationToken: ct);

        try
        {
            // ... biznes logikasi
            await _logger.SuccessAsync("Order yaratildi", cancellationToken: ct);
            await _logger.MessageAsync("Audit: yangi buyurtma", cancellationToken: ct);
            await _logger.WarningAsync("Stok kam qoldi", cancellationToken: ct);
            return Ok();
        }
        catch (Exception ex)
        {
            await _logger.ErrorAsync(ex, detailed: true, cancellationToken: ct);

            var dump = System.Text.Encoding.UTF8.GetBytes(ex.ToString());
            await _logger.ErrorAttachmentAsync("Order yaratishda xatolik", dump, cancellationToken: ct);
            return StatusCode(500);
        }
    }
}

Legacy API (deprecated)

Eski LoggerService(IConfiguration, IHostEnvironment) konstruktori [Obsolete] deb belgilangan. Yangi konstruktor IOptions<LoggerBotOptions> qabul qiladi — DI orqali avtomatik chaqiriladi. Iltimos IOptions<LoggerBotOptions> ga ko'chib o'ting.

What's new in 1.6.0

  • Multi-target: net6.0 / net7.0 / net8.0 / net9.0 / net10.0
  • Strongly-typed LoggerBotOptions (Token, ChatId, SectionName)
  • IHttpClientFactory orqali named HttpClient ("LoggerBot") — TelegramBotClient shu HttpClient ustida ishlaydi
  • Interlocked.CompareExchange bilan race-free queue worker — aniq bitta worker ishga tushadi
  • CancellationToken butun yo'l bo'ylab botClient.SendTextMessageAsync ga uzatiladi
  • Console.WriteLine olib tashlandi — agar inject qilingan bo'lsa ILogger<LoggerService> ishlatiladi

Multi-project chats

Bir nechta loyihaga (chatga) yozish kerak bo'lsa, appsettings.json ga qo'shimcha kalitlar qo'shing va metod chaqirig'ida projectName bering:

{
  "LoggerBot": {
    "Token": "bot-token",
    "ChatId": -100default,
    "Project1": -100chatId1,
    "Project2": -100chatId2
  }
}
await _logger.ErrorAsync(exception, "Project1", detailed: true, cancellationToken: ct);

License / contributing

Issue va PR'lar ochiq — https://github.com/nbk-bot/LoggerBot. Litsenziya repo ildizidagi LICENSE fayliga muvofiq.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 is compatible.  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.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on LoggerBot:

Package Downloads
GlobalErrorHandler

Middleware for global exception handling in ASP.NET Core. Pluggable IErrorHandlerSink lets you opt in to Telegram delivery via LoggerBot or ship reports anywhere else.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.6.0 98 5/13/2026
1.5.3 300 8/22/2025
1.5.2 238 8/22/2025
1.5.1 362 2/17/2025
1.5.0 170 2/17/2025
1.4.0 241 1/27/2025
1.3.1 185 1/27/2025
1.3.0 248 1/4/2025
1.2.1 211 11/29/2024
1.2.0 186 11/29/2024
1.1.1 231 11/7/2024
1.1.0 175 11/7/2024
1.0.0 347 5/6/2024