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.0.0(5mo ago)0530MITPHPPHP ^8.1

Since Nov 29Pushed 5mo 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 1mo ago

READMEChangelogDependencies (5)Versions (2)Used By (0)

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

[](#laravel-telegram-logger)

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

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

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

[](#requirements)

- PHP 8.1+
- Laravel 10.x, 11.x, or 12.x

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
```

### 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

37

—

LowBetter than 83% of packages

Maintenance71

Regular maintenance activity

Popularity17

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

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

Unknown

Total

1

Last Release

163d ago

### Community

Maintainers

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

---

Top Contributors

[![DenoBY](https://avatars.githubusercontent.com/u/7386384?v=4)](https://github.com/DenoBY "DenoBY (1 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

[naoray/laravel-github-monolog

Log driver to store logs as github issues

10619.4k](/packages/naoray-laravel-github-monolog)[thecoder/laravel-monolog-telegram

Telegram Handler for Monolog

2939.5k](/packages/thecoder-laravel-monolog-telegram)[shaffe/laravel-mail-log-channel

A package to support logging via email in Laravel

1286.2k](/packages/shaffe-laravel-mail-log-channel)[onlime/laravel-http-client-global-logger

A global logger for the Laravel HTTP Client

1935.1k](/packages/onlime-laravel-http-client-global-logger)[yzen.dev/mono-processor

This Processor will display in the logs bread crumbs by which you can more quickly and accurately identify the cause of the error.

116.1k](/packages/yzendev-mono-processor)

PHPackages © 2026

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