agtong/yii2-telegram-log-target

Telegram log target for Yii 2

Maintainers

Package info

github.com/agtong/yii2-telegram-log-target

Type:yii2-extension

pkg:composer/agtong/yii2-telegram-log-target

Statistics

Installs: 36

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2020-04-19 14:49 UTC

This package is auto-updated.

Last update: 2026-02-20 03:40:58 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!');