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

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

denoby/laravel-telegram-logger
==============================

Laravel package for sending logs and messages to Telegram

v1.1.5(3w ago)11.0kMITPHPPHP ^8.1

Since Nov 29Pushed 3mo agoCompare

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

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

Laravel Telegram Logger
=======================

[](#laravel-telegram-logger)

[English](README.md) · [Русский](README.ru.md)

[![release](https://camo.githubusercontent.com/7d31b6764e5613f68fb3e556ddd745b1bd57fc0571d3630716548f94af39ab4f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64656e6f62792f6c61726176656c2d74656c656772616d2d6c6f676765723f6c6162656c3d72656c65617365)](https://packagist.org/packages/denoby/laravel-telegram-logger)[![license](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)](LICENSE)[![php](https://camo.githubusercontent.com/1036932dd7fe2ff2b812d59e729bb9d03869656568a6899ca9ed5fd23bfffd13/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d254532253839254135253230382e312d626c7565)](https://camo.githubusercontent.com/1036932dd7fe2ff2b812d59e729bb9d03869656568a6899ca9ed5fd23bfffd13/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d254532253839254135253230382e312d626c7565)[![laravel](https://camo.githubusercontent.com/3f7e6435047c56379e62be4901d74b5b17fa694e1e704f16921f2bf90f002f60/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d31302532302543322542372532303131253230254332254237253230313225323025433225423725323031332d6c6967687467726579)](https://camo.githubusercontent.com/3f7e6435047c56379e62be4901d74b5b17fa694e1e704f16921f2bf90f002f60/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d31302532302543322542372532303131253230254332254237253230313225323025433225423725323031332d6c6967687467726579)

A Laravel package for sending application logs and messages to Telegram.

Features
--------

[](#features)

- Send Laravel logs to Telegram chat/group/channel
- Support for Telegram topics (threads)
- Fluent message builder with photo/video support
- Configurable exception filtering
- User info in log messages
- Markdown formatting

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

[](#installation)

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

The package will auto-register its service provider.

### Publish Configuration

[](#publish-configuration)

```
php artisan vendor:publish --provider="DenoBY\TelegramLogger\ServiceProvider"
```

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

[](#configuration)

Add the following to your `.env` file:

```
TELEGRAM_LOG_TOKEN=your-bot-token
TELEGRAM_LOG_CHAT_ID=your-chat-id
TELEGRAM_LOG_THREAD_ID=optional-thread-id
```

### Getting Your Bot Token

[](#getting-your-bot-token)

1. Open Telegram and search for [@BotFather](https://t.me/BotFather)
2. Send `/newbot` and follow the instructions
3. Copy the token provided

### Getting Your Chat ID

[](#getting-your-chat-id)

1. Add your bot to the group/channel where you want to receive logs
2. Send a message to the group
3. Visit `https://api.telegram.org/bot/getUpdates`
4. Find the `chat.id` in the response

Usage
-----

[](#usage)

### As a Log Channel

[](#as-a-log-channel)

Add the Telegram channel to your `config/logging.php`:

```
'channels' => [
    // ... other channels

    'telegram' => [
        'driver' => 'custom',
        'via' => \DenoBY\TelegramLogger\Logger::class,
        'level' => env('LOG_LEVEL', 'error'),
    ],
],
```

You can add it to your stack:

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

Or use it directly:

```
Log::channel('telegram')->error('Something went wrong!');
```

### As a Tap (Adding to Existing Channels)

[](#as-a-tap-adding-to-existing-channels)

You can add Telegram logging to any existing channel using the `tap` option. This sends logs to both the original channel AND Telegram:

```
'daily' => [
    'driver' => 'daily',
    'path' => storage_path('logs/laravel.log'),
    'level' => 'debug',
    'tap' => [\DenoBY\TelegramLogger\Tap::class],
],
```

The `Tap` class uses the `telegram-logger.level` config value (default: `error`) to filter which logs are sent to Telegram. You can set it via environment variable:

```
TELEGRAM_LOG_LEVEL=error
```

### Per-channel Overrides (thread\_id and level)

[](#per-channel-overrides-thread_id-and-level)

You can override the global `TELEGRAM_LOG_THREAD_ID` and log level on a per-channel basis. This is useful when you want different log categories to go to different topics of the same supergroup.

**Through `Logger` (custom channel):**

```
'channels' => [
    'tg_payments' => [
        'driver' => 'custom',
        'via' => \DenoBY\TelegramLogger\Logger::class,
        'level' => 'info',
        'thread_id' => env('TELEGRAM_PAYMENTS_THREAD_ID'),
    ],

    'tg_queues' => [
        'driver' => 'custom',
        'via' => \DenoBY\TelegramLogger\Logger::class,
        'level' => 'warning',
        'thread_id' => env('TELEGRAM_QUEUES_THREAD_ID'),
    ],
],
```

**Through `Tap` (positional arguments `thread_id,level`):**

```
// both overridden
'tap' => [\DenoBY\TelegramLogger\Tap::class.':42,warning'],

// only thread_id (level falls back to global)
'tap' => [\DenoBY\TelegramLogger\Tap::class.':42'],

// only level (thread_id falls back to global)
'tap' => [\DenoBY\TelegramLogger\Tap::class.':,warning'],

// no overrides — uses global config
'tap' => [\DenoBY\TelegramLogger\Tap::class],
```

If a channel does not set an override, the global `TELEGRAM_LOG_THREAD_ID` / `TELEGRAM_LOG_LEVEL` from `.env` is used.

### Sending Messages Directly

[](#sending-messages-directly)

Use the Facade to send messages:

```
use DenoBY\TelegramLogger\Facades\Telegram;
use DenoBY\TelegramLogger\Message;

// Simple message
Telegram::sendMessageToChat(
    new Message('Hello from Laravel!'),
    config('telegram-logger.chat_id')
);

// With topic (thread)
Telegram::sendMessageToChat(
    new Message('Hello!'),
    config('telegram-logger.chat_id'),
    threadId: config('telegram-logger.thread_id')
);
```

### Building Messages

[](#building-messages)

```
use DenoBY\TelegramLogger\Message;

// Create message with photos
$message = (new Message('Check out these photos!'))
    ->addPhoto('https://example.com/image1.jpg')
    ->addPhoto('https://example.com/image2.jpg');

// Append/prepend text
$message = (new Message('Main content'))
    ->prependText('Header:')
    ->appendText('Footer');
```

### Sending Documents

[](#sending-documents)

```
use DenoBY\TelegramLogger\Facades\Telegram;

Telegram::sendDocument(
    filePath: '/path/to/document.pdf',
    chatId: config('telegram-logger.chat_id'),
    caption: 'Here is your document',
    threadId: config('telegram-logger.thread_id')
);
```

Configuration Options
---------------------

[](#configuration-options)

```
// config/telegram-logger.php

return [
    // Bot token from @BotFather
    'token' => env('TELEGRAM_LOG_TOKEN'),

    // Chat/Group/Channel ID
    'chat_id' => env('TELEGRAM_LOG_CHAT_ID'),

    // Topic ID (for supergroups with topics)
    'thread_id' => env('TELEGRAM_LOG_THREAD_ID'),

    // App info for log messages
    'app_name' => env('APP_NAME', 'Laravel'),
    'app_url' => env('APP_URL'),
    'environment' => env('APP_ENV', 'production'),
    'deploy_branch' => env('DEPLOY_BRANCH'),

    // Exceptions to ignore completely
    'ignore_exceptions' => [
        // \Symfony\Component\Mailer\Exception\TransportException::class,
    ],

    // Exceptions to log without stack trace
    'ignore_stack_trace_for' => [
        // \App\Exceptions\CustomException::class,
    ],

    // Maximum message length (Telegram limit is 4096)
    'max_message_length' => 3040,

    // Include authenticated user info
    'include_user_info' => true,

    // HTTP timeout in seconds
    'timeout' => 5,

    // Minimum log level for TelegramTap
    'level' => env('TELEGRAM_LOG_LEVEL', 'error'),
];
```

Log Message Format
------------------

[](#log-message-format)

Log messages are formatted in Markdown with the following information:

- **App URL** - Clickable link to your application
- **Environment** - Current environment (production, staging, etc.)
- **Log Level** - As a hashtag (#ERROR, #WARNING, etc.)
- **Branch** - Deploy branch (if configured)
- **User ID** - Authenticated user info (if enabled)
- **File** - File and line number where the exception occurred
- **Message** - The log message
- **Stack Trace** - Filtered to show only app-related traces

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance85

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~39 days

Recently: every ~23 days

Total

7

Last Release

25d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7386384?v=4)[Baidak.D](/maintainers/DenoBY)[@DenoBY](https://github.com/DenoBY)

---

Top Contributors

[![DenoBY](https://avatars.githubusercontent.com/u/7386384?v=4)](https://github.com/DenoBY "DenoBY (6 commits)")

---

Tags

laravelloggingphptelegramlaravelloggingloggertelegrammonolog

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[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.

45844.8k1](/packages/pressbooks-pressbooks)[naoray/laravel-github-monolog

Log driver to store logs as github issues

10924.7k](/packages/naoray-laravel-github-monolog)[api-platform/laravel

API Platform support for Laravel

58190.1k21](/packages/api-platform-laravel)[onlime/laravel-http-client-global-logger

A global logger for the Laravel HTTP Client

2040.3k](/packages/onlime-laravel-http-client-global-logger)[forjedio/inertia-table

Backend-driven dynamic tables for Laravel + Inertia.js

272.0k](/packages/forjedio-inertia-table)

PHPackages © 2026

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