holdmann / monolog-telegram-async
Handler for Monolog to send logs by Telegram asynchronously
Package info
github.com/holdmann/monolog-telegram-async
pkg:composer/holdmann/monolog-telegram-async
v1.0.0
2026-04-29 12:01 UTC
Requires
- php: ^7.4 || ^8
- ext-json: *
- guzzlehttp/guzzle: ^7
- monolog/monolog: *
Requires (Dev)
This package is auto-updated.
Last update: 2026-04-29 12:10:11 UTC
README
Handler for Monolog to send logs by Telegram asynchronously in HTML format
Requirements
- PHP 7.4 or above
- Guzzle 7+
Installation with composer
composer require holdmann/monolog-telegram-async
Declaring handler object
To declare this handler, you need to know the bot token and the chat identifier(chat_id) to which the log will be sent.
// ... $handler = new \Holdmann\Monolog\TelegramAsyncHandler('<token>', <chat_id>, <log_level>); // ...
Example:
$log = new \Monolog\Logger('telegram_channel'); $handler = new \Holdmann\Monolog\TelegramAsyncHandler( '000000000:XXXXX-xxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 123456789, \Monolog\Logger::DEBUG ); $handler->setFormatter(new \Monolog\Formatter\LineFormatter("%message%", null, true)); $log->pushHandler($handler); $log->debug('Test message');
The above example is using standard LineFormatter from Monolog package. You can write and use your own message formatter for better logs format.
Example with proxy (for russian servers):
$handler = new \Holdmann\Monolog\TelegramAsyncHandler('<token>', <chat_id>, <log_level>); $handler->setProxy('http://username:password@192.168.16.1:80'); // or simply 'http://192.168.16.1:80' $handler->setFormatter(new \Monolog\Formatter\LineFormatter("%message%", null, true));