|
1 | 1 | # X.Serilog.Sinks.Telegram |
2 | | -X.Serilog.Sinks.Telegram is a Serilog sink that write events to [Telegram](https://telegram.org/) channel or chat. |
3 | 2 |
|
4 | | -## Current Statuses |
5 | 3 | [](https://ci.appveyor.com/project/Bardin08/x-serilog-sinks-telegram/branch/main) |
6 | | -[](https://www.nuget.org/packages/X.Serilog.Sinks.Telegram/) |
7 | 4 |
|
8 | | -## Installation |
| 5 | +[](https://www.nuget.org/packages/X.Serilog.Sinks.Telegram) |
| 6 | +[](https://www.nuget.org/packages/X.Serilog.Sinks.Telegram) |
9 | 7 |
|
10 | | -The package can be installed by NuGet manually or within one of the listed commands. |
| 8 | +## Table of Contents |
11 | 9 |
|
12 | | -```ps |
13 | | -PM> Install-Package X.Serilog.Sinks.Telegram -Version 1.0.0 |
14 | | -``` |
| 10 | +- [X.Serilog.Sinks.Telegram](#xserilogsinkstelegram) |
| 11 | + - [Introduction](#introduction) |
| 12 | + - [Features](#features) |
| 13 | + - [Getting Started](#getting-started) |
| 14 | + - [Examples](#examples) |
| 15 | + - [Contributing](#contributing) |
| 16 | + - [License](#license) |
15 | 17 |
|
16 | | -```sh |
17 | | -$ dotnet add package X.Serilog.Sinks.Telegram --version 1.0.0 |
18 | | -``` |
| 18 | +## Introduction |
19 | 19 |
|
20 | | -## Documentation |
21 | | -For more comprehensive and detailed documentation, please visit our [GitHub Wiki](https://github.com/Bardin08/X.Serilog.Sinks.Telegram/wiki/Overview) pages. Here, you'll find in-depth information about configuration options, usage examples, troubleshooting guides, and more to help you effectively integrate and utilize the X.Serilog.Sinks.Telegram sink in your projects. |
| 20 | +X.Serilog.Sinks.Telegram is an open-source Serilog sink that allows you to send log events to Telegram. It's a convenient way to integrate Telegram as a logging output, enabling you to receive important log information directly in your chat. |
22 | 21 |
|
| 22 | +## Features |
23 | 23 |
|
24 | | -## Usage |
| 24 | +- **Real-time Logging**: The sink offers the ability to send log events to a Telegram channel in real-time, ensuring that you can stay up-to-date with your application's behavior and any issues as they arise. |
25 | 25 |
|
26 | | -Check [docs](./docs) folder to find more interesting things that can be useful. |
| 26 | +- **Customizable Formatting**: You have the flexibility to configure the format of log messages sent to the Telegram channel, allowing you to tailor them to your preferences and specific requirements. |
27 | 27 |
|
28 | | -### Code-Based Configuration |
29 | | -The simplest configuration require [Telegram bot token](https://core.telegram.org/bots#generating-an-authentication-token) and [channel ID](https://community.jamaicans.dev/t/get-the-telegram-channel-id/427). Check the enclosed links to understand how to receive them. |
| 28 | +- **Filtering**: The sink supports filtering log events before they are dispatched to the Telegram channel, ensuring that only pertinent information is shared. |
30 | 29 |
|
31 | | -```cs |
32 | | -Log.Logger = new LoggerConfiguration() |
33 | | - .WriteTo.Telegram( |
34 | | - token: "0000000000:0000_000000000000000000000000000000", |
35 | | - chatId: "-0000000000000") |
36 | | - .CreateLogger(); |
37 | | -``` |
| 30 | +- **Asynchronous Sending**: Log events are sent asynchronously to the Telegram channel, minimizing any potential impact on your application's performance. |
38 | 31 |
|
39 | | -For more complex configuration examples please check the related wiki page or browse the examples folder. |
| 32 | +- **Easy Configuration**: Configuring the sink to work with your Telegram channel is straightforward, and you can find comprehensive information in the [Configuration Wiki](https://github.com/Bardin08/X.Serilog.Sinks.Telegram/wiki/Configuration). |
40 | 33 |
|
41 | | -Sink also can be configured by JSON configuration file. |
42 | | -### JSON-Based Configuration |
43 | | -#### *Microsoft.Extensions.Configuration* package required |
44 | | -Keys and values are case-insensitive. |
| 34 | +## Getting Started |
| 35 | + |
| 36 | +To begin using the X.Serilog.Sinks.Telegram sink, follow these steps: |
| 37 | + |
| 38 | +1. **Install the Package**: You can install the sink package from NuGet using the following command: |
| 39 | +```shell |
| 40 | +dotnet add package X.Serilog.Sinks.Telegram |
| 41 | +``` |
45 | 42 |
|
46 | | -```json |
47 | | -"Serilog": { |
48 | | - "Using": [ |
49 | | - "X.Serilog.Sinks.Telegram" |
50 | | - ], |
51 | | - "WriteTo": [ |
| 43 | +2. **Configure the Sink**: In your application's configuration, set up the Telegram sink with the appropriate settings. Here's an example configuration in C#: |
| 44 | + |
| 45 | +```c# |
| 46 | +var logger = new LoggerConfiguration() |
| 47 | + .Telegram(config => |
52 | 48 | { |
53 | | - "Name": "Telegram", |
54 | | - "Args": { |
55 | | - "Token": "0000000000:0000_000000000000000000000000000000", |
56 | | - "ChatId": "-0000000000000", |
57 | | - } |
58 | | - } |
59 | | - ], |
60 | | -} |
| 49 | + config.Token = "your_telegram_bot_token"; |
| 50 | + config.ChatId = "your_chat_id"; |
| 51 | + config.BatchPostingLimit = 10; |
| 52 | + config.Mode = LoggingMode.Logs; |
| 53 | + config.FormatterConfiguration = new FormatterConfiguration |
| 54 | + { |
| 55 | + UseEmoji = true, |
| 56 | + ReadableApplicationName = "MyTestApp", |
| 57 | + IncludeException = true, |
| 58 | + IncludeProperties = true |
| 59 | + }; |
| 60 | + config.BatchEmittingRulesConfiguration = new BatchEmittingRulesConfiguration |
| 61 | + { |
| 62 | + // Batch Emitting rules configuration here... |
| 63 | + }; |
| 64 | + config.LogFiltersConfiguration = new LogsFiltersConfiguration |
| 65 | + { |
| 66 | + ApplyLogFilters = true, |
| 67 | + FiltersOperator = LogFiltersOperator.Or, |
| 68 | + Filters = new List<IFilter> { |
| 69 | + // Your filters here... |
| 70 | + } |
| 71 | + }; |
| 72 | + }, null, LogEventLevel.Debug) |
| 73 | + .CreateLogger(); |
61 | 74 | ``` |
62 | 75 |
|
63 | | -## Roadmap |
64 | | -Project's roadmap described at [Roadmap](./docs/roadmap.md). |
| 76 | +3. **Start Logging**: Once the sink is configured, you can start logging using Serilog as you normally would. Log events will be sent to your Telegram channel. |
| 77 | + |
| 78 | +For more detailed configuration options, please refer to the [Configuration Wiki](https://github.com/Bardin08/X.Serilog.Sinks.Telegram/wiki/Configuration). |
| 79 | + |
| 80 | +## Examples |
| 81 | + |
| 82 | +This repository includes a number of example projects that demonstrate how to use X.Serilog.Sinks.Telegram in various scenarios. These examples can be very helpful if you're just getting started or looking to use a specific feature. |
| 83 | + |
| 84 | +You can find the examples in the following location: [X.Serilog.Sinks.Telegram Examples](https://github.com/Bardin08/X.Serilog.Sinks.Telegram/tree/main/examples) |
65 | 85 |
|
66 | 86 | ## Contributing |
67 | 87 | Feel free to add any improvements you want via pull requests. All pull requests must be linked to an issue. |
68 | 88 |
|
| 89 | +## License |
| 90 | +This project is licensed under the [MIT License](https://en.wikipedia.org/wiki/MIT_License)https://en.wikipedia.org/wiki/MIT_License. |
0 commit comments