PHPackages                             muhamadzain/laravel-telegram-log - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. muhamadzain/laravel-telegram-log

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

muhamadzain/laravel-telegram-log
================================

laravel log record and send into Telegram Chat Bot

1.1.0(3y ago)18MITPHPPHP ^7.4|^8.0

Since Feb 11Pushed 3y ago1 watchersCompare

[ Source](https://github.com/Zainal21/Laravel-Telegram-Bot-Logging)[ Packagist](https://packagist.org/packages/muhamadzain/laravel-telegram-log)[ RSS](/packages/muhamadzain-laravel-telegram-log/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (3)Used By (0)

Laravel Telegram Bot Logging
----------------------------

[](#laravel-telegram-bot-logging)

> Send logs to Telegram chat via Telegram bot. Inspired by [ ](https://github.com/grkamil/laravel-telegram-logging)

Requirement
-----------

[](#requirement)

- PHP 8.0 above
- Laravel 8 or higher

Install
-------

[](#install)

```
composer require muhamadzain/laravel-telegram-log
```

Configurations
--------------

[](#configurations)

Please define Telegram Bot Credentials and chat id as environment parameters by modifying `.env` on your project path

```
TELEGRAM_BOT_TOKEN=null
TELEGRAM_CHAT_ID=null
TELEGRAM_LOGGER_TEMPLATE=null
TELEGRAM_OPTIONS=[]
```

Create new logging channel by modifying **config/logging.php** file

```
'telegram' => [
    'driver' => 'custom',
    'via'    => TelegramLog\TelegramLogger::class,
    'level'  => 'debug',
]
```

Or if your default log channel is a stack, you can add it to the stack channel like this

```
'stack' => [
    'driver' => 'stack',
    'channels' => ['single', 'telegram'],
]
```

By default `LOG_CHANNEL` will be set into `stack` so you need to set default logger on env after setting up configurations above

```
LOG_CHANNEL=telegram
```

Publish config file and views to override

```
php artisan vendor:publish --provider "TelegramLog\TelegramServiceProvider"
```

Create bot
----------

[](#create-bot)

For using this plugin, you need to create telegram bot

1. Go to [@BotFather](https://t.me/botfather) in the Telegram
2. Send `/newbot`
3. Set up name and bot-name for your bot.
4. Get token and add it to your .env file (it is written above)
5. Go to your bot and send `/start` message

Change log template at runtime
------------------------------

[](#change-log-template-at-runtime)

1. Change config for template.

```
config(['telegram-logger.template'=>'laravel-telegram-logging::custom'])
```

2. Use `Log` as usual

Lumen support
=============

[](#lumen-support)

To make it work with Lumen, you need also run two steps:

1. Place config/telegram-logger.php file with following code:

```
