c0dem1ner / laravel-telegram-logger
Telegram Log integration for Laravel
Installs: 127
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/c0dem1ner/laravel-telegram-logger
Requires
- php: >=7.4
- illuminate/support: ^7.0|^8.0|^9.0|^10.0|^11.0|^12.0
README
A simple Laravel package to send log messages directly to a Telegram chat or group using the Telegram Bot API.
Features
- Log messages from Laravel to Telegram in real-time.
- Easy setup with simple configuration.
- Customizable Telegram message format.
Installation
composer require c0dem1ner/laravel-telegram-logger
Configuration
- Publish the config file:
php artisan vendor:publish --tag=telegram-logger-config
- Update the
.envfile:
TELEGRAM_BOT_TOKEN=your-telegram-bot-token
TELEGRAM_CHAT_ID=your-telegram-chat-id
- Configure logging in
config/logging.php:
'channels' => [ // other channels... 'telegram' => [ 'driver' => 'custom', 'level' => env('LOG_LEVEL', 'debug'), 'via' => \C0deM1ner\LaravelTelegramLogger\Logger\TelegramLogger::class, 'chat_id' => env('TELEGRAM_CHAT_ID', '1234567'), 'token' => env('TELEGRAM_BOT_TOKEN', '') 'type' => 'alert', // can be 'alert', 'error', 'info' ], // You can also add multiple Telegram channels ], ],
Usage
You can log directly to Telegram using:
telegramLog()->info('Your message here'); telegramLog()->alert('Your message here'); telegramLog()->error('Your message here');
Or use Laravel’s global logging:
logger() ->channel('telegram') ->debug('Your message here');
Any log message matching the configured level will be sent to Telegram.
Customizing Messages
If needed, you can publish and edit the view for Telegram messages:
php artisan vendor:publish --tag=telegram-logger-views
Customize the message structure in resources/views/vendor/telegram-logger/messages.
Testing
You can test your configuration by running:
php artisan telegram-log:send-test-message
License
This package is open-sourced software licensed under the MIT license.
Credits
- Developed by C0deM1ner
- Telegram Bot API
Contributions
Contributions are welcome! Please open issues or submit PRs.
Security
If you discover any security-related issues, please email noro.danielyan.1998@gmail.com instead of using the issue tracker.