PHPackages                             ashishgusai/laravel-telegram-logger - 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. ashishgusai/laravel-telegram-logger

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

ashishgusai/laravel-telegram-logger
===================================

Production-grade asynchronous critical log dispatcher for Telegram Bot API with rate limiting, topic routing, and message truncation.

v1.0.1(1w ago)02↑1400%MITPHPPHP ^8.2CI passing

Since May 31Pushed 1w agoCompare

[ Source](https://github.com/ashishgusai/laravel-telegram-logger)[ Packagist](https://packagist.org/packages/ashishgusai/laravel-telegram-logger)[ RSS](/packages/ashishgusai-laravel-telegram-logger/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (8)Versions (3)Used By (0)

laravel-telegram-logger
=======================

[](#laravel-telegram-logger)

Send Laravel error logs to a Telegram chat, group, or supergroup topic via a Telegram Bot. Built as a Monolog driver so it plugs into the standard Laravel logging stack — no custom exception-handler hacks required.

Features
--------

[](#features)

- Native Monolog handler — works with the `Log` facade and `config/logging.php` channels.
- **Rate limiting / de-duplication** to prevent alert storms (cache-backed signature hash).
- **Topic / thread routing** for Telegram supergroups (`message_thread_id` per log level).
- **4096-character safe truncation** so verbose stack traces never get rejected by Telegram.
- **Optional queue dispatch** so the request lifecycle is never blocked by Telegram API latency.
- HTML-escaped output by default — safe with `parse_mode=HTML`.

Requirements
------------

[](#requirements)

- PHP `^8.2`
- Laravel `^10.0 | ^11.0 | ^12.0`
- Monolog `^3.0`

Installation
------------

[](#installation)

```
composer require ashishgusai/laravel-telegram-logger
```

Publish the config (optional, but recommended):

```
php artisan vendor:publish --tag=telegram-logger-config
```

Configuration
-------------

[](#configuration)

Add the following to your `.env`:

```
TELEGRAM_LOG_BOT_TOKEN="123456789:ABCdefGhIJKlmNoPQRsTUVwXyz"
TELEGRAM_LOG_CHAT_ID="-1001234567890"
TELEGRAM_LOG_ENABLED=true

# Optional — supergroup topic routing
TELEGRAM_LOG_DEFAULT_THREAD_ID=
TELEGRAM_LOG_CRITICAL_THREAD_ID=

# Optional — queue dispatch (recommended for production)
TELEGRAM_LOG_QUEUE_ENABLED=true
TELEGRAM_LOG_QUEUE_CONNECTION=redis
TELEGRAM_LOG_QUEUE_NAME=alerts

# Optional — rate limit duplicate alerts (seconds)
TELEGRAM_LOG_RATE_LIMIT_ENABLED=true
TELEGRAM_LOG_RATE_LIMIT_WINDOW=300

# Optional — global volume cap per minute across all signatures (0 = disabled)
TELEGRAM_LOG_GLOBAL_MAX_PER_MIN=10
```

Register the channel in `config/logging.php`:

```
'channels' => [
    'stack' => [
        'driver'   => 'stack',
        'channels' => ['daily', 'telegram'],
        'ignore_exceptions' => false,
    ],

    'telegram' => [
        'driver' => 'custom',
        'via'    => \AshishGusai\TelegramLogger\Logging\TelegramLoggingInstance::class,
        'level'  => 'critical',
    ],
],
```

Usage
-----

[](#usage)

```
use Illuminate\Support\Facades\Log;

Log::critical('Database connection lost', [
    'host'   => 'db-primary',
    'reason' => 'timeout',
]);

// Exceptions are formatted with file/line and the trace
try {
    // ...
} catch (\Throwable $e) {
    Log::critical('Background job failed', ['exception' => $e]);
}
```

How rate limiting works
-----------------------

[](#how-rate-limiting-works)

Each log line is hashed by `level + message`. If the same hash is seen again within `rate_limit.window` seconds (default 300), the duplicate is silently dropped. Cache backend defaults to your app default; override with `TELEGRAM_LOG_RATE_LIMIT_STORE`.

A second gate — the **global volume cap** (`TELEGRAM_LOG_GLOBAL_MAX_PER_MIN`, default 10) — limits the absolute number of messages sent in any single wall-clock minute, regardless of how many distinct signatures are active. This prevents "variety storms" where a broken deployment throws 20 different exceptions at once and floods the channel. Set to `0` to disable the global cap.

How thread routing works
------------------------

[](#how-thread-routing-works)

If your Telegram chat is a supergroup with topics, set the per-level `message_thread_id`s in the config. The handler looks up `thread_ids[level_name]` first, then `thread_ids['default']`, and omits the field if both are empty.

Queueing
--------

[](#queueing)

Set `TELEGRAM_LOG_QUEUE_ENABLED=true` and the handler dispatches `SendTelegramLogJob` onto your queue instead of making a blocking HTTP call. The job is `tries=3` with a 10-second backoff.

Testing
-------

[](#testing)

```
composer install
composer test
```

License
-------

[](#license)

MIT

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance98

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 55.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 ~2 days

Total

2

Last Release

7d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a27ca50927578c5500a0bac1bedab0e0d14dd7cd0143b5786282a597cb6ab7cd?d=identicon)[ashishgusai](/maintainers/ashishgusai)

---

Top Contributors

[![ashishgusai](https://avatars.githubusercontent.com/u/45149861?v=4)](https://github.com/ashishgusai "ashishgusai (5 commits)")[![claude](https://avatars.githubusercontent.com/u/81847?v=4)](https://github.com/claude "claude (4 commits)")

---

Tags

laravelloggingqueuealertsbottelegrammonolog

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ashishgusai-laravel-telegram-logger/health.svg)

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

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9732.3M121](/packages/roots-acorn)[naoray/laravel-github-monolog

Log driver to store logs as github issues

10822.5k](/packages/naoray-laravel-github-monolog)

PHPackages © 2026

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