PHPackages                             vsavritsky/monolog-telegram - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. vsavritsky/monolog-telegram

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

vsavritsky/monolog-telegram
===========================

Monolog handler that sends logs through Telegram bot to any chat in HTML format

1.9(6y ago)04MITPHPPHP ^7.2

Since Feb 22Pushed 5y agoCompare

[ Source](https://github.com/vsavritsky/monolog-telegram)[ Packagist](https://packagist.org/packages/vsavritsky/monolog-telegram)[ RSS](/packages/vsavritsky-monolog-telegram/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (4)Versions (14)Used By (0)

Monolog Telegram Handler [![Build Status](https://camo.githubusercontent.com/6ead06d6f3cfdbfcc2d5c65e7652c08bc34033a7329c3b7031fdfe85e2b9049e/68747470733a2f2f7472617669732d63692e6f72672f6a61636b6c756c2f6d6f6e6f6c6f672d74656c656772616d2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/jacklul/monolog-telegram)
================================================================================================================================================================================================================================================================================================================================

[](#monolog-telegram-handler-)

Send your logs through Telegram bot to any chat and make them look fancy!

#### Features:

[](#features)

- [Continous logging](https://i.imgur.com/8EnxO90.jpg) and [batch logging](https://i.imgur.com/4C9Y6cT.jpg) support
- Standard stack traces wrapped in `` tags
- Automatic splitting of the message when it exceeds maximum limit

Prerequisites
-------------

[](#prerequisites)

- Telegram Bot API token - [see here](https://core.telegram.org/bots#creating-a-new-bot) to learn how to obtain one
- ID of the chat to which you want to send the logs - see below

#### Obtaining chat ID

[](#obtaining-chat-id)

One of the simplest ways to do that is to interact with the bot in the target chat:

- private and group chats - send any dummy command
- channels - post something in it

After interacting visit `https://api.telegram.org/botTOKEN/getUpdates` (replace `TOKEN` with your actual bot token), you will be able to find the chat id (`chat_id`) in the result JSON.

Installation
------------

[](#installation)

Install with [Composer](https://github.com/composer/composer):

```
$ composer require jacklul/monolog-telegram
```

Usage
-----

[](#usage)

To use this handler you just have to add it like every other **Monolog** handler:

```
require 'vendor/autoload.php';

$api_token = '123456789:teMbvbETojnSG93jDhnynvH8pT28H9TIB1h';    // Bot API token
$chat_id = 987654321;    // Target Chat ID
$level = Logger::ERROR;     // Log level
$bubble = true;     // Bubble up the stack or not
$use_curl = true;    // Use cURL or not? (default: use when available)
$timeout = 10;   // Timeout for API requests
$verify_peer = true;   // Verify SSL certificate or not? (development/debugging)

$logger = new Logger('My project');
$handler = new TelegramHandler($api_token, $chat_id, $level, $bubble, $use_curl, $timeout, $verify_peer);
$handler->setFormatter(new TelegramFormatter());    // Usage of this formatter is optional but recommended if you want better message layout
$logger->pushHandler($handler);

$logger->error('Error!');
```

To prevent spamming the chat and hitting Telegram's API limits it is advised to use [DeduplicationHandler](https://github.com/Seldaek/monolog/blob/master/src/Monolog/Handler/DeduplicationHandler.php) and/or [BufferHandler](https://github.com/Seldaek/monolog/blob/master/src/Monolog/Handler/BufferHandler.php), ideal solution for production use would be:

```
$handler = new TelegramHandler('TOKEN', 123456789);
$handler->setFormatter(new TelegramFormatter());

// Combine all log entries into one and force batch processing
$handler = new BufferHandler($handler);

// Make sure that particular log stack wasn't sent before
$handler = new DeduplicationHandler($handler);

// Keep collecting logs until ERROR occurs, after that send collected logs to $handler
$handler = new FingersCrossedHandler($handler, new ErrorLevelActivationStrategy(Logger::ERROR));

$logger->pushHandler($handler);
```

You can customize the formatter:

```
$html = true;    // Choose whether to send the message in HTMl format
$format = "%level_name% (%channel%) [%date%]\n\n%message%\n\n%context%%extra%";   // Error (My project) [2018-05-01 15:55:15 UTC]
$date_format = 'Y-m-d H:i:s e';       // 2018-05-01 15:55:15 UTC, format must be supported by DateTime::format
$separator = '-';       // Seperation character for batch processing - when empty one empty line is used

$handler->setFormatter(new TelegramFormatter($html, $format, $date_format, $separator));
```

License
-------

[](#license)

See [LICENSE](LICENSE).

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 96.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~55 days

Recently: every ~75 days

Total

13

Last Release

2375d ago

PHP version history (2 changes)1.0.0PHP ^5.5|^7.0

1.9PHP ^7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/1872ace6ad18c747f549b07e197ac0405e2c92ba56449fbeebead453ed4fd69f?d=identicon)[savritsky](/maintainers/savritsky)

---

Top Contributors

[![jacklul](https://avatars.githubusercontent.com/u/8418678?v=4)](https://github.com/jacklul "jacklul (27 commits)")[![vsavritsky](https://avatars.githubusercontent.com/u/5252233?v=4)](https://github.com/vsavritsky "vsavritsky (1 commits)")

---

Tags

logloggingbottelegrammonolog

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/vsavritsky-monolog-telegram/health.svg)

```
[![Health](https://phpackages.com/badges/vsavritsky-monolog-telegram/health.svg)](https://phpackages.com/packages/vsavritsky-monolog-telegram)
```

###  Alternatives

[jacklul/monolog-telegram

Monolog handler that sends logs through Telegram bot to any chat in HTML format

2469.4k2](/packages/jacklul-monolog-telegram)[inpsyde/wonolog

Monolog-based logging package for WordPress.

184631.3k7](/packages/inpsyde-wonolog)[rahimi/monolog-telegram

A handler for Monolog that sends messages to Telegram Channels

6980.2k1](/packages/rahimi-monolog-telegram)[mero/telegram-handler

Monolog handler to send log by Telegram

36114.6k](/packages/mero-telegram-handler)[thecoder/laravel-monolog-telegram

Telegram Handler for Monolog

2941.1k](/packages/thecoder-laravel-monolog-telegram)[logtail/monolog-logtail

Logtail handler for Monolog

233.5M3](/packages/logtail-monolog-logtail)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
