agtong / yii2-telegram-log-target
Telegram log target for Yii 2
Installs: 36
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:yii2-extension
pkg:composer/agtong/yii2-telegram-log-target
Requires
- agtong/yii2-telegram-bot: ~1.0
- yiisoft/yii2: ~2.0.0
This package is auto-updated.
Last update: 2025-10-20 02:57:40 UTC
README
Yii2 Telegram log target that sends selected log messages to the specified telegram chats or channels.
Installation
The preferred way to install this extension is through composer.
Either run
composer require agtong/yii2-telegram-log-target
or add
"agtong/yii2-telegram-log-target": "*"
to the require section of your composer.json file.
Usage
Add this log target to the components section in your configuration.
'components' => [
'log' => [
'targets' => [
[
'class' => 'agtong\yii2\log\TelegramTarget',
'botToken' => '123456:abcde',
'chatId' => '123456',
'levels' => ['error'],
'logVars' => [],
],
],
],
],
You can choose to disable this target by default,
'components' => [
'log' => [
'targets' => [
'telegramTarget => [ // Name this target
'class' => 'agtong\yii2\log\TelegramTarget',
'botToken' => '123456:abcde',
'chatId' => '123456',
'enabled' => false, // Disabled by default
'levels' => ['error'],
'logVars' => [],
],
],
],
],
and enable it when required.
Yii::$app->log->targets['telegramTarget']->enabled = true;
Yii::error('Hello World!');