This package provides Handler for Monolog Logger.
For me in some cases it's very convenient to receive logs in Telegram, so I wrote a short handler for using in any project.
- PHP 7.1+
- cURL and mbstring extensions activated
<?php
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!');
According to Laravel docs in config/logging.php
add channel:
return [
// ...
'channels' => [
// ...
'telegram' => [
'driver' => 'monolog',
'handler' => \TelegramLog\Handler\TelegramHandler::class,
'with' => [
'botToken' => 'your-bot-token',
'chatId' => '@yourChatId',
],
],
],
];
And use by set in .env LOG_CHANNEL=telegram