LoggerBot 1.2.1
dotnet add package LoggerBot --version 1.2.1
NuGet\Install-Package LoggerBot -Version 1.2.1
<PackageReference Include="LoggerBot" Version="1.2.1" />
paket add LoggerBot --version 1.2.1
#r "nuget: LoggerBot, 1.2.1"
// Install LoggerBot as a Cake Addin #addin nuget:?package=LoggerBot&version=1.2.1 // Install LoggerBot as a Cake Tool #tool nuget:?package=LoggerBot&version=1.2.1
LoggerBot NuGet Package
Overview
The LoggerBot NuGet package provides a logging service that integrates with Telegram bots. It allows developers to easily log messages of various types (error, info, warning, success, and generic messages) to a designated Telegram chat using a Telegram bot.
Installation
You can install the LoggerBot NuGet package via the NuGet Package Manager or the .NET CLI:
dotnet add package LoggerBot
Usage
- Configure LoggerBot First, configure LoggerBot in your application's startup code to register the logger service in the dependency injection container:
using LoggerBot;
builder.Services.AddLoggerBot();
- Inject and Use LoggerService Inject the ILoggerService interface into your classes where logging is required and use its methods to log messages:
using LoggerBot.Services;
public class MyClass
{
private readonly ILoggerService _logger;
public MyClass(ILoggerService logger)
{
_logger = logger;
}
public async Task SomeMethod()
{
// Log an error message
await _logger.ErrorAsync("An error occurred.");
// Log an info message
await _logger.InfoAsync("Some information message.");
// Log a success message
await _logger.SuccessAsync("Operation completed successfully.");
// Log a warning message
await _logger.WarningAsync("Warning: Resource limit exceeded.");
// Log a generic message
await _logger.MessageAsync("A generic message.");
}
}
Configuration
The LoggerBot requires configuration settings to connect to your Telegram bot. Ensure the following configuration keys are present in your appsettings.json or environment variables:
LoggerBot:Token: The token of your Telegram bot.
LoggerBot:ChatId: The ID of the Telegram chat where logs will be sent.
Example:
"LoggerBot": {
"Token": "bot-token",
"ChatId": "-100chatId"
}
Supported Log Types
Error: Used for logging error messages.
Info: Used for logging informational messages.
Success: Used for logging success messages.
Warning: Used for logging warning messages.
Message: Used for logging generic messages.
Feel free to expand upon this documentation with more details specific to your package's usage or additional features!
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. |
-
net8.0
- Microsoft.Extensions.Configuration.Abstractions (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.1)
- Telegram.Bot (>= 19.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on LoggerBot:
Package | Downloads |
---|---|
GlobalErrorHandler
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.