Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/cyrus-sushiant/serilog.sinks.telegrambot

Serilog.Sinks.TelegramBot is a library to save logging information from Serilog to Telegram. The assembly was written and tested in .Net 6.0 or above
https://github.com/cyrus-sushiant/serilog.sinks.telegrambot

logger logging serilog serilog-extension serilog-sink serilog-sink-telegram telegram telegram-bot telegram-bot-api

Last synced: 15 days ago
JSON representation

Serilog.Sinks.TelegramBot is a library to save logging information from Serilog to Telegram. The assembly was written and tested in .Net 6.0 or above

Awesome Lists containing this project

README

        

# Serilog.Sinks.TelegramBot

[![NuGet Version](https://img.shields.io/nuget/v/Serilog.Sinks.TelegramBot.svg?style=flat)](https://www.nuget.org/packages/Serilog.Sinks.TelegramBot/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://raw.githubusercontent.com/Cyrus-Sushiant/Serilog.Sinks.TelegramBot/master/LICENSE)

A Serilog sink that writes events as messages to [Telegram](https://telegram.org/).

All you need is bot token and chat id. To manage bots go to [Bot Father](https://telegram.me/botfather). After you got bot token add bot to contacts and start it (`/start`). To get your id navigate to https://api.telegram.org/botTOKEN/getUpdates

## Available for
* .Net 6.0
* .Net 7.0
* .Net 8.0

# Install
```
Install-Package Serilog.Sinks.TelegramBot
```

## Basic usage:
```csharp
var log = new LoggerConfiguration()
.MinimumLevel.Verbose()
.WriteTo.TelegramBot("000000:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "000000")
.CreateLogger();
log.Information("This is an information message!");
```

### Example

![Simple Message](/assets/example.png)