PHPackages                             uzhlaravel/telegramlogs - 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. uzhlaravel/telegramlogs

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

uzhlaravel/telegramlogs
=======================

Monitor your Laravel application logs in real-time through Telegram. This package delivers instant notifications of critical events directly to your Telegram channel, with support for threaded discussions and Markdown formatting.

v1.0.3(1mo ago)91.6k[1 PRs](https://github.com/Uzziahlukeka/telegrammonitor/pulls)MITPHPPHP ^8.2CI passing

Since Feb 1Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/Uzziahlukeka/telegrammonitor)[ Packagist](https://packagist.org/packages/uzhlaravel/telegramlogs)[ Docs](https://github.com/Uzziahlukeka/telegrammonitor)[ GitHub Sponsors](https://github.com/uzhlaravel)[ RSS](/packages/uzhlaravel-telegramlogs/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (36)Versions (21)Used By (0)

Telegram Logs Monitor for Laravel
=================================

[](#telegram-logs-monitor-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/2321abf4ff78f299917d86bced0f4beceb4c5e2a511b586b9b738ff1b5febec1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f757a686c61726176656c2f74656c656772616d6c6f67732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/uzhlaravel/telegramlogs)[![GitHub Tests Action Status](https://github.com/Uzziahlukeka/telegrammonitor/actions/workflows/run-tests.yml/badge.svg)](https://github.com/Uzziahlukeka/telegrammonitor/actions/workflows/run-tests.yml/badge.svg)[![Code style](https://github.com/Uzziahlukeka/telegrammonitor/actions/workflows/fix-php-code-style-issues.yml/badge.svg)](https://github.com/Uzziahlukeka/telegrammonitor/actions/workflows/fix-php-code-style-issues.yml/badge.svg)[![Total Downloads](https://camo.githubusercontent.com/d514710c6c7e90ead61633fb30841a3858e18cb04c2a3a7e3b128d72bf76af59/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f757a686c61726176656c2f74656c656772616d6c6f67732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/uzhlaravel/telegramlogs)[![License](https://camo.githubusercontent.com/e890f34d290e8e23b3dde7385931221edbc98b427ae3c8fdf2b4196399c9994b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f757a686c61726176656c2f74656c656772616d6c6f67732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/uzhlaravel/telegramlogs)

---

A Laravel package that sends your application logs, exceptions, and model activity events directly to a Telegram channel or group — in real time.

Supports **Laravel 10 → 13**, PHP 8.2+, and includes production-only mode so notifications stay silent during local development.

---

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Configuration](#configuration)
    - [Environment Variables](#environment-variables)
    - [Restrict to Production Only](#restrict-to-production-only)
- [Usage](#usage)
    - [Log Channel Integration](#log-channel-integration)
    - [Direct Messaging](#direct-messaging)
    - [Activity Log](#activity-log)
        - [HasTelegramActivity Trait](#hastelegramactivity-trait)
        - [TelegramActivity Facade](#telegramactivity-facade)
- [Artisan Commands](#artisan-commands)
- [Log Levels](#log-levels)
- [Getting Telegram Credentials](#getting-telegram-credentials)
- [Security](#security)
- [Contributing](#contributing)
- [License](#license)

---

Features
--------

[](#features)

- **Monolog integration** — drop-in `telegram` log channel; works with `LOG_CHANNEL=telegram` or as a stacked channel
- **Direct messaging** — send arbitrary text to any chat from anywhere in your app
- **Activity log** — track Eloquent model `created / updated / deleted` events and push them to Telegram (inspired by [spatie/laravel-activitylog](https://github.com/spatie/laravel-activitylog))
- **Production-only mode** — restrict notifications to specific environments with a single env var
- **Smart formatting** — emoji-labelled MarkdownV2 messages with context, exception details, and stack traces
- **Long message splitting** — automatically splits messages that exceed Telegram's 4096-char limit
- **Forum/topic support** — route messages to specific threads in a Telegram group
- **Interactive install** — guided `telegramlogs:install` command

---

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

[](#requirements)

DependencyVersionPHP^8.2Laravel^10.0 | ^11.0 | ^12.0 | ^13.0---

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

[](#installation)

```
composer require uzhlaravel/telegramlogs
```

Run the interactive setup wizard:

```
php artisan telegramlogs:install
```

The wizard will publish the config file, help you set environment variables, optionally enable activity log, and send a test message.

Or publish the config manually:

```
php artisan vendor:publish --tag="telegramlogs-config"
```

---

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

[](#configuration)

### Environment Variables

[](#environment-variables)

Add these to your `.env` file:

```
# Required
TELEGRAM_BOT_TOKEN=your_bot_token_here
TELEGRAM_CHAT_ID=your_chat_id_here

# Optional
TELEGRAM_LOG_LEVEL=critical          # minimum level to forward (default: critical)
TELEGRAM_TOPIC_ID=                   # forum thread / topic ID
TELEGRAM_TIMEOUT=10                  # Telegram API timeout in seconds

# Environment control — see next section
TELEGRAM_ENVIRONMENTS=production     # default: production only

# Activity log
TELEGRAM_ACTIVITY_LOG=false          # set true to enable model event tracking
TELEGRAM_ACTIVITY_LOG_LEVEL=info     # log level for activity notifications
```

### Full Reference

[](#full-reference)

VariableRequiredDefaultDescription`TELEGRAM_BOT_TOKEN`Yes—Bot API token from @BotFather`TELEGRAM_CHAT_ID`Yes—Target chat, channel, or group ID`TELEGRAM_TOPIC_ID`No`null`Forum topic (thread) ID`TELEGRAM_TOPIC_MESSAGE_ID`No`null`Forum thread message ID`TELEGRAM_LOG_LEVEL`No`critical`Minimum PSR-3 level to send`TELEGRAM_TIMEOUT`No`10`HTTP timeout in seconds`TELEGRAM_ENVIRONMENTS`No`production`Comma-separated env list, or `*``TELEGRAM_ACTIVITY_LOG`No`false`Enable model activity tracking`TELEGRAM_ACTIVITY_LOG_LEVEL`No`info`Log level for activity messages---

### Restrict to Production Only

[](#restrict-to-production-only)

By default, notifications are only sent when `APP_ENV=production`. This prevents your local machine or CI from flooding your Telegram channel.

```
# Only production (default)
TELEGRAM_ENVIRONMENTS=production

# Production and staging
TELEGRAM_ENVIRONMENTS=production,staging

# Every environment — useful for local debugging
TELEGRAM_ENVIRONMENTS=*
```

The current environment and whether notifications are active are both shown in:

```
php artisan telegramlogs:test --config
```

---

Usage
-----

[](#usage)

### Log Channel Integration

[](#log-channel-integration)

Set Telegram as your default channel:

```
LOG_CHANNEL=telegram
```

Or add it to a stack so critical logs go to both your file log and Telegram:

```
// config/logging.php
'channels' => [
    'stack' => [
        'driver'   => 'stack',
        'channels' => ['daily', 'telegram'],
    ],
],
```

Use it like any Laravel logger:

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

Log::error('Payment processing failure');

Log::critical('Database unreachable', [
    'connection' => 'mysql',
    'host'       => config('database.connections.mysql.host'),
]);

try {
    // ...
} catch (\Exception $e) {
    Log::error('Unexpected exception', ['exception' => $e]);
}
```

Messages arrive in Telegram formatted like this:

```
❌ ERROR — MyApp [production]

Payment processing failure

Context:
{
  "connection": "mysql"
}

🕐 2025-08-19 14:32:01 UTC

```

---

### Direct Messaging

[](#direct-messaging)

Send arbitrary messages to Telegram without going through the logger — useful for contact forms, webhooks, or manual alerts.

```
use Uzhlaravel\Telegramlogs\Facades\TelegramMessage;

// Simple text
TelegramMessage::message('Scheduled backup completed.');

// With Telegram API options
TelegramMessage::send('Deployment finished', [
    'parse_mode'               => 'HTML',
    'disable_web_page_preview' => true,
]);

// Send to a different chat
TelegramMessage::toChat('-100987654321', 'Alert for ops team');

// Test connectivity
TelegramMessage::test();

// Get bot information
TelegramMessage::getBotInfo();
```

---

### Activity Log

[](#activity-log)

Inspired by [spatie/laravel-activitylog](https://github.com/spatie/laravel-activitylog), the activity log tracks Eloquent model events and pushes a formatted notification to Telegram.

Enable it in `.env`:

```
TELEGRAM_ACTIVITY_LOG=true
```

#### HasTelegramActivity Trait

[](#hastelegramactivity-trait)

Add the trait to any Eloquent model to automatically track its lifecycle events:

```
use Uzhlaravel\Telegramlogs\Traits\HasTelegramActivity;

class Post extends Model
{
    use HasTelegramActivity;
}
```

On `created`, `updated`, or `deleted`, a message like the following is sent to Telegram:

```
🟢 Activity — MyApp [production]

Created Post

Subject: Post #42
Properties:
{
  "attributes": { "title": "Hello World", "status": "draft" }
}

🕐 2025-08-19 14:32:01 UTC

```

**Customise per model:**

```
use Uzhlaravel\Telegramlogs\Traits\HasTelegramActivity;

class Order extends Model
{
    use HasTelegramActivity;

    // Track only these events for this model
    protected array $telegramActivityEvents = ['created', 'deleted'];

    // Custom description
    public function getTelegramActivityDescription(string $event): string
    {
        return ucfirst($event) . ' order #' . $this->id . ' — ' . $this->status;
    }

    // Extra properties to include
    public function getTelegramActivityProperties(string $event): array
    {
        return ['total' => $this->total, 'customer' => $this->customer->name];
    }
}
```

Global event list is controlled in `config/telegramlogs.php`:

```
'activity_log' => [
    'events'             => ['created', 'updated', 'deleted'],
    'include_old_values' => true,   // previous values on update
    'include_new_values' => true,   // changed values on update
],
```

#### TelegramActivity Facade

[](#telegramactivity-facade)

For manual / one-off activity notifications, use the fluent facade:

```
use Uzhlaravel\Telegramlogs\Facades\TelegramActivity;

TelegramActivity::performedOn($post)
    ->causedBy(auth()->user())
    ->withProperty('plan', 'pro')
    ->event('published')
    ->dispatch('Post was published');

// Simpler form
TelegramActivity::log('Nightly cleanup job finished');
```

---

Artisan Commands
----------------

[](#artisan-commands)

```
# Interactive setup
php artisan telegramlogs:install

# Send a test log message
php artisan telegramlogs:test

# Send with a custom message and level
php artisan telegramlogs:test --message="Health check OK" --level=warning

# Send a test activity notification
php artisan telegramlogs:test --activity

# Show current configuration (includes environment status)
php artisan telegramlogs:test --config

# List available log levels
php artisan telegramlogs:test --list
```

---

Log Levels
----------

[](#log-levels)

LevelEmojiUse Case`emergency`🚨System is unusable`alert`🔴Immediate action required`critical`💥Critical conditions`error`❌Runtime errors`warning`⚠️Potential issues`notice`📢Significant normal events`info`ℹ️General operational messages`debug`🐛Detailed diagnostic information---

Getting Telegram Credentials
----------------------------

[](#getting-telegram-credentials)

### 1. Create a Bot

[](#1-create-a-bot)

1. Open [@BotFather](https://t.me/BotFather) in Telegram
2. Send `/newbot` and follow the prompts
3. Copy the token into `TELEGRAM_BOT_TOKEN`

### 2. Get Your Chat ID

[](#2-get-your-chat-id)

- **Channel** — add the bot as an admin; the channel username (`@mychannel`) or numeric ID (`-100xxxxxxxxx`) works
- **Group** — add the bot to the group; send a message, then call `https://api.telegram.org/bot/getUpdates` to find `chat.id`
- **Private chat** — start a chat with the bot, then use `getUpdates`

### 3. Forum Topics (optional)

[](#3-forum-topics-optional)

1. Enable Topics in your group settings
2. Create a topic and send a message
3. From `getUpdates`, copy `message_thread_id` → `TELEGRAM_TOPIC_ID`

---

Security
--------

[](#security)

- Store `TELEGRAM_BOT_TOKEN` only in `.env` — never commit it
- Restrict which commands the bot can receive (via BotFather → `/mybots → Bot Settings → Group Privacy`)
- Audit who has access to your Telegram channel regularly

---

Contributing
------------

[](#contributing)

1. Fork the repository
2. Create a feature branch: `git checkout -b feature/my-feature`
3. Commit your changes: `git commit -m 'Add my feature'`
4. Push: `git push origin feature/my-feature`
5. Open a pull request

**Development commands:**

```
git clone https://github.com/Uzziahlukeka/telegrammonitor.git
cd telegrammonitor
composer install
composer test        # run test suite
composer analyse     # PHPStan static analysis
composer format      # Laravel Pint code style
```

---

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT License](LICENSE.md).

---

💖 Made with love by [Uzziah Lukeka](https://github.com/Uzziahlukeka)

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance92

Actively maintained with recent releases

Popularity26

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 56.2% 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 ~34 days

Recently: every ~67 days

Total

15

Last Release

43d ago

Major Versions

v0.1.9.2 → v1.0.02026-04-01

### Community

Maintainers

![](https://www.gravatar.com/avatar/0c60a7476f54a95b4e406d4754f377ec19c39ee9c91a8e80c52d82ba57af3ab9?d=identicon)[uzziahlukeka](/maintainers/uzziahlukeka)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (365 commits)")[![Uzziahlukeka](https://avatars.githubusercontent.com/u/102746022?v=4)](https://github.com/Uzziahlukeka "Uzziahlukeka (50 commits)")[![mvdnbrk](https://avatars.githubusercontent.com/u/802681?v=4)](https://github.com/mvdnbrk "mvdnbrk (46 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (23 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (22 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (16 commits)")[![pforret](https://avatars.githubusercontent.com/u/474312?v=4)](https://github.com/pforret "pforret (16 commits)")[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (14 commits)")[![patinthehat](https://avatars.githubusercontent.com/u/5508707?v=4)](https://github.com/patinthehat "patinthehat (10 commits)")[![riasvdv](https://avatars.githubusercontent.com/u/3626559?v=4)](https://github.com/riasvdv "riasvdv (9 commits)")[![crynobone](https://avatars.githubusercontent.com/u/172966?v=4)](https://github.com/crynobone "crynobone (8 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (8 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (7 commits)")[![thecaliskan](https://avatars.githubusercontent.com/u/13554944?v=4)](https://github.com/thecaliskan "thecaliskan (5 commits)")[![claude](https://avatars.githubusercontent.com/u/81847?v=4)](https://github.com/claude "claude (5 commits)")[![irfanm96](https://avatars.githubusercontent.com/u/42065936?v=4)](https://github.com/irfanm96 "irfanm96 (5 commits)")[![IGedeon](https://avatars.githubusercontent.com/u/694313?v=4)](https://github.com/IGedeon "IGedeon (4 commits)")[![yaroslawww](https://avatars.githubusercontent.com/u/23663794?v=4)](https://github.com/yaroslawww "yaroslawww (3 commits)")[![jessarcher](https://avatars.githubusercontent.com/u/4977161?v=4)](https://github.com/jessarcher "jessarcher (3 commits)")[![koossaayy](https://avatars.githubusercontent.com/u/6431084?v=4)](https://github.com/koossaayy "koossaayy (3 commits)")

---

Tags

laravellogspackagephp8telegramlaravelmonitoringnotificationslogsmarkdownrealtimetelegramActivity Logsuzhlaraveltelegramlogstelegram monitordirect messagecritical eventsthreaded discussions

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/uzhlaravel-telegramlogs/health.svg)

```
[![Health](https://phpackages.com/badges/uzhlaravel-telegramlogs/health.svg)](https://phpackages.com/packages/uzhlaravel-telegramlogs)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[spatie/laravel-health

Monitor the health of a Laravel application

87512.0M167](/packages/spatie-laravel-health)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k15.1M132](/packages/laravel-pulse)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M200](/packages/laravel-ai)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45444.2k1](/packages/pressbooks-pressbooks)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5022.0k](/packages/simplestats-io-laravel-client)

PHPackages © 2026

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