PHPackages                             thecoder/laravel-monolog-telegram - 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. thecoder/laravel-monolog-telegram

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

thecoder/laravel-monolog-telegram
=================================

Telegram Handler for Monolog

v2.5.3(6mo ago)2939.5k↓27.3%8MITPHPPHP ^8.0

Since Nov 14Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/mbpcoder/laravel-monolog-telegram)[ Packagist](https://packagist.org/packages/thecoder/laravel-monolog-telegram)[ Docs](https://github.com/mbpcoder/monolog-telegram)[ RSS](/packages/thecoder-laravel-monolog-telegram/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (30)Used By (0)

Real-Time Laravel exception logs in your Telegram 🚀
===================================================

[](#real-time-laravel-exception-logs-in-your-telegram-)

ScreenShot
----------

[](#screenshot)

[![image](https://user-images.githubusercontent.com/3877538/172431112-020d7a7c-f515-49bc-961a-3f63c9ff21af.png)](https://user-images.githubusercontent.com/3877538/172431112-020d7a7c-f515-49bc-961a-3f63c9ff21af.png)

❓ Why Another Logger?
---------------------

[](#-why-another-logger)

Logging should be more than just saving data — it should **drive action**. Here’s why 🔔 **Telegram Handler for Monolog** 📝 is a game-changer:

- 🚀 **Real-Time Feedback** – Instantly receive logs in your Telegram chat.
- 🧠 **Actionable Insights** – Include useful context for quick understanding.
- 🛡️ **No Need for Sentry or Third-Party Services**
- ⚡ **Immediate Alerts** – Be notified of issues the moment they happen.
- 👥 **Team Collaboration** – Share logs in group chats for quick follow-up.
- 🧩 **Easy Customization** – Use PHP attributes to control log routing.

🎯 Installation
--------------

[](#-installation)

Install via Composer:

```
composer require thecoder/laravel-monolog-telegram
```

⚙️ Usage
--------

[](#️-usage)

Update your `config/logging.php` file to configure the Telegram logging channel.

### ⏳ Running Logs in a Queue

[](#-running-logs-in-a-queue)

If a queue name is set, logs will be processed asynchronously in the specified queue. Otherwise, they will run synchronously.

### 🔧 Configuration Example

[](#-configuration-example)

Modify your `config/logging.php` file:

```
use TheCoder\MonologTelegram\Attributes\EmergencyAttribute;
use TheCoder\MonologTelegram\Attributes\CriticalAttribute;
use TheCoder\MonologTelegram\Attributes\ImportantAttribute;
use TheCoder\MonologTelegram\Attributes\DebugAttribute;
use TheCoder\MonologTelegram\Attributes\InformationAttribute;
use TheCoder\MonologTelegram\Attributes\LowPriorityAttribute;

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

        'telegram' => [
            'driver' => 'monolog',
            'level' => 'debug',
            'handler' => TheCoder\MonologTelegram\TelegramBotHandler::class,
            'handler_with' => [
                'token' => env('LOG_TELEGRAM_BOT_TOKEN'),
                'chat_id' => env('LOG_TELEGRAM_CHAT_ID'),
                'topic_id' => env('LOG_TELEGRAM_TOPIC_ID', null),
                'bot_api' => env('LOG_TELEGRAM_BOT_API', 'https://api.telegram.org/bot'),
                'proxy' => env('LOG_TELEGRAM_BOT_PROXY', null),
                'queue' => env('LOG_TELEGRAM_QUEUE', null),
                'timeout' => env('LOG_TELEGRAM_TIMEOUT', 5),
                'topics_level' => [
                    EmergencyAttribute::class => env('LOG_TELEGRAM_EMERGENCY_ATTRIBUTE_TOPIC_ID', null),
                    CriticalAttribute::class => env('LOG_TELEGRAM_CRITICAL_ATTRIBUTE_TOPIC_ID', null),
                    ImportantAttribute::class => env('LOG_TELEGRAM_IMPORTANT_ATTRIBUTE_TOPIC_ID', null),
                    DebugAttribute::class => env('LOG_TELEGRAM_DEBUG_ATTRIBUTE_TOPIC_ID', null),
                    InformationAttribute::class => env('LOG_TELEGRAM_INFORMATION_ATTRIBUTE_TOPIC_ID', null),
                    LowPriorityAttribute::class => env('LOG_TELEGRAM_LOWPRIORITY_ATTRIBUTE_TOPIC_ID', null),
                ]
            ],
            'formatter' => TheCoder\MonologTelegram\TelegramFormatter::class,
            'formatter_with' => [
                'tags' => env('LOG_TELEGRAM_TAGS', null),
            ],
        ],
    ],
];
```

### 🏷️ Topic-Based Logging

[](#️-topic-based-logging)

You can assign a **PHP Attribute (Annotation)** to controller methods, command handlers, or job handlers, enabling topic-based logging. The package will use the first detected attribute to determine the topic for logging messages.

#### 💡 Example:

[](#-example)

**📌 Controller Method:**

```
namespace App\Http\Controllers\NewWeb;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use TheCoder\MonologTelegram\Attributes\EmergencyAttribute;

class HomeController extends Controller
{
    #[EmergencyAttribute]
    public function index(Request $request)
    {
        // Your logic here
    }
}
```

**⚡ Command or Job Handler:**

```
namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeQueued;
use Illuminate\Foundation\Bus\Dispatchable;
use TheCoder\MonologTelegram\Attributes\CriticalAttribute;

class ProcessData implements ShouldBeQueued
{
    use Dispatchable, Queueable;

    #[CriticalAttribute]
    public function handle()
    {
        // Job processing logic
    }
}
```

**⚙️ Livewire Component Route:**

```

```

```
class CreatePost extends Component
{
    #[CriticalAttribute]
    public function save()
    {

    }

    public function render()
    {
        return view('livewire.create-post');
    }
}
```

### 🔄 Customizing Log Settings at Runtime

[](#-customizing-log-settings-at-runtime)

You can dynamically set the bot token, chat ID, and topic ID while logging:

```
logger('message', [
    'token' => 'your_bot_token',
    'chat_id' => 'your_chat_id',
    'topic_id' => 'your_topic_id'
]);
```

📜 Environment Variables
-----------------------

[](#-environment-variables)

Ensure the following variables are set in your `.env` file:

```
LOG_TELEGRAM_BOT_TOKEN=
LOG_TELEGRAM_CHAT_ID=

# 🏷️ If using chat groups with topic support, define the topic ID
LOG_TELEGRAM_TOPIC_ID=

# 🌍 Optional: Change the API endpoint (default is Telegram's official API)
LOG_TELEGRAM_BOT_API='https://api.telegram.org/bot'

# 🛡️ Optional: Use a proxy (e.g., Tor for restricted regions)
LOG_TELEGRAM_BOT_PROXY='socks5h://localhost:9050'

# 🔥 Topic Level Configurations
LOG_TELEGRAM_EMERGENCY_ATTRIBUTE_TOPIC_ID=
LOG_TELEGRAM_CRITICAL_ATTRIBUTE_TOPIC_ID=
LOG_TELEGRAM_IMPORTANT_ATTRIBUTE_TOPIC_ID=
LOG_TELEGRAM_DEBUG_ATTRIBUTE_TOPIC_ID=
LOG_TELEGRAM_INFORMATION_ATTRIBUTE_TOPIC_ID=
LOG_TELEGRAM_LOWPRIORITY_ATTRIBUTE_TOPIC_ID=
```

📄 License
---------

[](#-license)

This package is open-source and available under the MIT License. 🏆

###  Health Score

55

—

FairBetter than 98% of packages

Maintenance79

Regular maintenance activity

Popularity40

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 72.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~65 days

Recently: every ~88 days

Total

29

Last Release

192d ago

Major Versions

v0.5 → v1.02024-01-18

v1.0.2 → v2.02024-07-31

### Community

Maintainers

![](https://www.gravatar.com/avatar/47ca7d89ddf7e0cd20c6c17b516919c1de6bf1af2702e37999ec296954ecf51a?d=identicon)[mb-programmer](/maintainers/mb-programmer)

---

Top Contributors

[![mbpcoder](https://avatars.githubusercontent.com/u/3877538?v=4)](https://github.com/mbpcoder "mbpcoder (61 commits)")[![saMahmoudzadeh](https://avatars.githubusercontent.com/u/36761585?v=4)](https://github.com/saMahmoudzadeh "saMahmoudzadeh (9 commits)")[![jbidad](https://avatars.githubusercontent.com/u/51882296?v=4)](https://github.com/jbidad "jbidad (8 commits)")[![amirhshokri](https://avatars.githubusercontent.com/u/123773211?v=4)](https://github.com/amirhshokri "amirhshokri (5 commits)")[![mohammadqasemi](https://avatars.githubusercontent.com/u/23121027?v=4)](https://github.com/mohammadqasemi "mohammadqasemi (1 commits)")

---

Tags

laravelmonologtelegramtelegram-botloglaravelloggingtelegrammonologchannelsbotsmonolog-telegram

### Embed Badge

![Health badge](/badges/thecoder-laravel-monolog-telegram/health.svg)

```
[![Health](https://phpackages.com/badges/thecoder-laravel-monolog-telegram/health.svg)](https://phpackages.com/packages/thecoder-laravel-monolog-telegram)
```

###  Alternatives

[rahimi/monolog-telegram

A handler for Monolog that sends messages to Telegram Channels

6980.2k1](/packages/rahimi-monolog-telegram)[mero/telegram-handler

Monolog handler to send log by Telegram

36113.3k](/packages/mero-telegram-handler)[codeinternetapplications/monolog-stackdriver

Stackdriver handler for Monolog.

14181.7k](/packages/codeinternetapplications-monolog-stackdriver)[jacklul/monolog-telegram

Monolog handler that sends logs through Telegram bot to any chat in HTML format

2364.7k1](/packages/jacklul-monolog-telegram)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
