PHP code example of therealartz / telegram-log-handler

1. Go to this page and download the library: Download therealartz/telegram-log-handler library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

therealartz / telegram-log-handler example snippets




use Monolog\Logger;
use TelegramLog\Handler\TelegramHandler;

$botToken = 'your-bot-token';
$chatId = '@yourChatId';

$logger = new Logger(
    'logger_dev',
    [
        new TelegramHandler($botToken, $chatId)
    ]
);

$logger->info('My logger works!');

return [

    // ...
    
    'channels' => [
    
        // ...
        
        'telegram' => [
            'driver' => 'monolog',
            'handler' => \TelegramLog\Handler\TelegramHandler::class,
            'with' => [
                'botToken' => 'your-bot-token',
                'chatId' => '@yourChatId',
            ],
        ],
    ],
];