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

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

nwservices/laravel-telegram-logger
==================================

A Laravel package that monitors laravel.log and sends Telegram notifications when errors occur

2.0.0(5mo ago)0401MITPHPPHP ^8.1

Since Dec 15Pushed 5mo agoCompare

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

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

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

[](#laravel-telegram-logger)

A Laravel package that monitors your `laravel.log` file and sends Telegram notifications when errors occur. Get instant alerts in your Telegram chat when critical errors happen in your Laravel application.

Features
--------

[](#features)

- Monitors `storage/logs/laravel.log` for new errors
- Scheduled task runs via Laravel scheduler (e.g., every minute)
- Only alerts on NEW errors (tracks file position to avoid duplicates)
- Configurable log levels (ERROR, CRITICAL, ALERT, EMERGENCY)
- Environment-based notifications (only send in production/staging)
- Rate limiting to prevent spam from duplicate errors
- Formatted messages with emojis for quick visual identification
- Handles multi-line log entries (stack traces)
- Detects log rotation automatically

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

[](#requirements)

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

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

[](#installation)

Install the package via Composer:

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

The service provider will be automatically registered through Laravel's package auto-discovery.

Publish the configuration file (optional):

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

Getting a Telegram Bot Token
----------------------------

[](#getting-a-telegram-bot-token)

1. Open Telegram and search for [@BotFather](https://t.me/BotFather)
2. Start a conversation and send `/newbot`
3. Follow the prompts to name your bot
4. BotFather will provide you with a token like `123456789:ABCdefGHIjklMNOpqrsTUVwxyz`
5. Save this token for your environment configuration

Getting Your Chat ID
--------------------

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

### For Personal Notifications

[](#for-personal-notifications)

1. Search for [@userinfobot](https://t.me/userinfobot) on Telegram
2. Start a conversation with it
3. It will reply with your user ID (a number like `123456789`)

### For Group Notifications

[](#for-group-notifications)

1. Add your bot to the group
2. Send a message in the group
3. Visit `https://api.telegram.org/bot/getUpdates`
4. Look for the `chat` object and find the `id` field (it will be negative for groups, like `-123456789`)

### For Channel Notifications

[](#for-channel-notifications)

1. Add your bot as an administrator to the channel
2. Use the channel's username with an `@` prefix (e.g., `@mychannel`)
3. Or use the channel ID (find it using the getUpdates method after posting)

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

[](#configuration)

Add these environment variables to your `.env` file:

```
TELEGRAM_LOGGER_BOT_TOKEN=your-bot-token-here
TELEGRAM_LOGGER_CHAT_ID=your-chat-id-here

# Optional settings
TELEGRAM_LOGGER_PROJECT_NAME="${APP_NAME}"
TELEGRAM_LOGGER_ENVIRONMENT="${APP_ENV}"
TELEGRAM_LOGGER_NOTIFY_ENVIRONMENTS=production,staging
TELEGRAM_LOGGER_THROTTLE=60

# Log monitoring settings
TELEGRAM_LOGGER_LOG_PATH=storage/logs/laravel.log
TELEGRAM_LOGGER_MONITOR_LEVELS=ERROR,CRITICAL,ALERT,EMERGENCY
TELEGRAM_LOGGER_POSITION_STORAGE=cache
```

Setting Up the Scheduler
------------------------

[](#setting-up-the-scheduler)

The package provides an artisan command that monitors your log file. You need to schedule it to run periodically.

### Laravel 11+ (routes/console.php)

[](#laravel-11-routesconsolephp)

```
use Illuminate\Support\Facades\Schedule;

Schedule::command('telegram:monitor-log')
    ->everyMinute()
    ->withoutOverlapping()
    ->runInBackground();
```

### Laravel 10 (app/Console/Kernel.php)

[](#laravel-10-appconsolekernelphp)

```
protected function schedule(Schedule $schedule): void
{
    $schedule->command('telegram:monitor-log')
        ->everyMinute()
        ->withoutOverlapping()
        ->runInBackground();
}
```

Make sure your server's cron is set up to run Laravel's scheduler:

```
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
```

Artisan Command
---------------

[](#artisan-command)

### Basic Usage

[](#basic-usage)

```
# Run the log monitor (typically via scheduler)
php artisan telegram:monitor-log

# Test without sending (dry run)
php artisan telegram:monitor-log --dry-run

# Reset the position tracker (start fresh)
php artisan telegram:monitor-log --reset

# Monitor a custom log file
php artisan telegram:monitor-log --log-path=/var/log/myapp/app.log

# Monitor specific levels only
php artisan telegram:monitor-log --levels=ERROR,CRITICAL
```

### Command Options

[](#command-options)

OptionDescription`--log-path`Path to log file (default: `storage/logs/laravel.log`)`--levels`Comma-separated log levels to monitor (default: from config)`--dry-run`Parse and display errors without sending to Telegram`--reset`Reset the file position trackerConfiguration Options
---------------------

[](#configuration-options)

OptionDefaultDescription`bot_token``''`Your Telegram bot token from BotFather`chat_id``''`The Telegram chat/group/channel ID to send messages to`project_name``APP_NAME`Project name displayed in notifications`environment``APP_ENV`Environment name displayed in notifications`notify_environments``['production', 'staging']`Only send notifications in these environments`throttle``60`Seconds to wait before sending duplicate messages`log_path``storage/logs/laravel.log`Path to the log file to monitor`monitor_levels``ERROR,CRITICAL,ALERT,EMERGENCY`Log levels to monitor`position_storage``cache`Where to store file position (`cache` or `file`)How It Works
------------

[](#how-it-works)

1. The `telegram:monitor-log` command runs on a schedule (e.g., every minute)
2. It reads `laravel.log` from the last saved position
3. Parses new content for log entries matching configured levels (e.g., `.ERROR`)
4. Sends Telegram notifications for each matching entry
5. Saves the new file position to avoid re-processing
6. Automatically detects log rotation and resets position

Log Level Emojis
----------------

[](#log-level-emojis)

Messages are prefixed with emojis for quick visual identification:

LevelEmojiEmergency🆘Alert🔔Critical🔴Error🚨Warning⚠️Notice📝Infoℹ️Debug🔍Example Message
---------------

[](#example-message)

```
🚨 ERROR

Project: My Laravel App
Environment: production
Time: 2025-01-15 14:30:45

Message:
SQLSTATE[HY000] [2002] Connection refused
#0 /var/www/app/Database/Connection.php(42): PDO->__construct()
#1 /var/www/app/Database/Manager.php(123): Connection->connect()
...

Context:
{
    "environment": "production"
}

```

Testing
-------

[](#testing)

To test if your configuration is working:

```
# Add a test error to your log file
echo "[$(date '+%Y-%m-%d %H:%M:%S')] production.ERROR: Test error from Laravel Telegram Logger" >> storage/logs/laravel.log

# Run the monitor in dry-run mode
php artisan telegram:monitor-log --dry-run

# Or run it for real
php artisan telegram:monitor-log
```

Security
--------

[](#security)

- Never commit your bot token to version control
- Use environment variables for all sensitive configuration
- Consider using a dedicated bot for each project
- Be mindful of what information appears in your logs

License
-------

[](#license)

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

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance73

Regular maintenance activity

Popularity16

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

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 ~0 days

Total

4

Last Release

152d ago

Major Versions

1.2.0 → 2.0.02025-12-18

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/105536639?v=4)[jondev1995](/maintainers/jondev1995)[@jondev1995](https://github.com/jondev1995)

---

Top Contributors

[![jondev1995](https://avatars.githubusercontent.com/u/105536639?v=4)](https://github.com/jondev1995 "jondev1995 (5 commits)")

---

Tags

laravelnotificationsloggertelegramerror handlinglog-monitor

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[illuminated/console-logger

Logging and Notifications for Laravel Console Commands.

8674.9k](/packages/illuminated-console-logger)[marvinlabs/laravel-discord-logger

Logging to a discord channel in Laravel

2081.1M2](/packages/marvinlabs-laravel-discord-logger)[guanguans/laravel-exception-notify

Monitor exception and report to the notification channels(Log、Mail、AnPush、Bark、Chanify、DingTalk、Discord、Gitter、GoogleChat、IGot、Lark、Mattermost、MicrosoftTeams、NowPush、Ntfy、Push、Pushback、PushBullet、PushDeer、PushMe、Pushover、PushPlus、QQ、RocketChat、ServerChan、ShowdocPush、SimplePush、Slack、Telegram、WeWork、WPush、XiZhi、YiFengChuanHua、ZohoCliq、ZohoCliqWebHook、Zulip).

14642.7k1](/packages/guanguans-laravel-exception-notify)[jackmartin/telegram-logger-errors

Telegram logger errors package laravel

1331.3k](/packages/jackmartin-telegram-logger-errors)[hryha/laravel-request-logger

A Laravel package to log requests and responses

102.2k](/packages/hryha-laravel-request-logger)

PHPackages © 2026

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