PHPackages                             laravel-log-monitor/log-monitor - 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. laravel-log-monitor/log-monitor

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

laravel-log-monitor/log-monitor
===============================

Real-time Laravel log monitoring with Telegram alerts

v1.2.0(5mo ago)02MITPHPPHP ^8.0

Since Dec 10Pushed 5mo agoCompare

[ Source](https://github.com/bdmotaleb/laravel-log-monitor)[ Packagist](https://packagist.org/packages/laravel-log-monitor/log-monitor)[ Docs](https://github.com/bdmotaleb/laravel-log-monitor)[ RSS](/packages/laravel-log-monitor-log-monitor/feed)WikiDiscussions main Synced 1mo ago

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

Laravel Log Monitor
===================

[](#laravel-log-monitor)

A Laravel package that monitors log files in real-time and sends alerts through Telegram when specific log levels appear.

Features
--------

[](#features)

- 🔍 **Real-time log monitoring** - Continuously watches Laravel log files
- 📱 **Telegram alerts** - Get instant notifications on your phone
- 🎯 **Level-based filtering** - Configure which log levels trigger alerts
- ⚡ **Efficient tailing** - Uses efficient file streaming (similar to `tail -f`)
- 🔄 **Auto rotation detection** - Automatically switches to new daily log files
- 🚫 **Throttling** - Prevents duplicate alerts for the same error
- 🧪 **Tested** - Includes unit tests for core functionality

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

[](#installation)

### Step 1: Install via Composer

[](#step-1-install-via-composer)

```
composer require laravel-log-monitor/log-monitor
```

### Step 2: Publish Configuration

[](#step-2-publish-configuration)

```
php artisan vendor:publish --tag=log-monitor-config
```

### Step 3: Configure Environment Variables

[](#step-3-configure-environment-variables)

Add these to your `.env` file:

```
# Telegram Configuration
LOG_MONITOR_TELEGRAM_ENABLED=true
LOG_MONITOR_TELEGRAM_TOKEN=your_bot_token_here
LOG_MONITOR_TELEGRAM_CHAT_ID=your_chat_id_here

# Optional: Custom log path
LOG_MONITOR_PATH=/path/to/logs

# Optional: Throttling (default: enabled, 5 minutes)
LOG_MONITOR_THROTTLE_ENABLED=true
LOG_MONITOR_THROTTLE_MINUTES=5
```

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

[](#getting-telegram-credentials)

### Bot Token

[](#bot-token)

1. Open Telegram and search for [@BotFather](https://t.me/BotFather)
2. Send `/newbot` command
3. Follow the instructions to create your bot
4. Copy the bot token (looks like: `123456789:ABCdefGHIjklMNOpqrsTUVwxyz`)

### Chat ID

[](#chat-id)

1. Send a message to your bot
2. Visit: `https://api.telegram.org/bot/getUpdates`
3. Look for `"chat":{"id":123456789}` in the JSON response
4. Copy the chat ID number

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

[](#configuration)

Edit `config/log-monitor.php` to customize monitoring:

```
'levels' => [
    'critical' => ['telegram'],  // Send critical logs to Telegram
    'error' => ['telegram'],     // Send errors to Telegram
    'warning' => [],             // Don't send warnings
    'notice' => ['telegram'],    // Custom level example
],
```

Usage
-----

[](#usage)

### Start Monitoring

[](#start-monitoring)

Run the artisan command to start monitoring:

```
php artisan log-monitor:watch
```

This will continuously monitor your log files and send alerts when configured log levels are detected.

**Note:** By default, the watcher only processes **new** log entries added after it starts. To process existing log entries on startup, use:

```
php artisan log-monitor:watch --process-existing
```

This is useful when you first start the monitor or want to catch up on recent logs.

### Running as a Daemon

[](#running-as-a-daemon)

For production, you should run this as a daemon or use a process manager like Supervisor.

#### Using Supervisor

[](#using-supervisor)

Create `/etc/supervisor/conf.d/laravel-log-monitor.conf`:

```
[program:laravel-log-monitor]
process_name=%(program_name)s
command=php /path/to/your/project/artisan log-monitor:watch
autostart=true
autorestart=true
user=www-data
redirect_stderr=true
stdout_logfile=/path/to/your/project/storage/logs/log-monitor.log
```

**Note:** For production, don't use `--process-existing` in Supervisor as it will process all logs every time the service restarts. Only use it manually when you need to catch up on existing logs.

Then reload Supervisor:

```
sudo supervisorctl reread
sudo supervisorctl update
sudo supervisorctl start laravel-log-monitor
```

#### Using systemd

[](#using-systemd)

Create `/etc/systemd/system/laravel-log-monitor.service`:

```
[Unit]
Description=Laravel Log Monitor
After=network.target

[Service]
Type=simple
User=www-data
WorkingDirectory=/path/to/your/project
ExecStart=/usr/bin/php artisan log-monitor:watch
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
```

Enable and start:

```
sudo systemctl enable laravel-log-monitor
sudo systemctl start laravel-log-monitor
```

Command Options
---------------

[](#command-options)

```
# Process existing logs on startup (then continue monitoring)
php artisan log-monitor:watch --process-existing

# Run once and exit (useful for testing)
php artisan log-monitor:watch --once

# Stop on first error
php artisan log-monitor:watch --stop-on-error
```

Log Format
----------

[](#log-format)

The package expects Laravel's standard log format:

```
[2025-12-09 16:05:50] production.WARNING: Something went wrong
[2025-12-09 16:06:14] production.ERROR: Database connection failed
[2025-12-09 16:06:55] production.CRITICAL: Payment API down

```

Message Format
--------------

[](#message-format)

Telegram messages are formatted as:

```
🚨 CRITICAL detected in production

⏰ Time: 2025-12-09 16:06:55
📝 Message:
Payment API down

```

Throttling
----------

[](#throttling)

The package includes throttling to prevent spam. By default, the same log message won't trigger an alert more than once every 5 minutes.

You can configure this in `config/log-monitor.php`:

```
'throttle' => [
    'enabled' => true,
    'minutes' => 5,  // Change this value
],
```

Testing
-------

[](#testing)

Run the test suite:

```
composer test
```

Or with PHPUnit directly:

```
vendor/bin/phpunit
```

Architecture
------------

[](#architecture)

### Services

[](#services)

- **LogParser**: Parses log lines and extracts timestamp, environment, level, and message
- **LogWatcher**: Monitors log files, handles rotation, and processes new entries
- **TelegramNotifier**: Sends formatted messages to Telegram
- **ThrottleManager**: Prevents duplicate alerts

### Facade

[](#facade)

You can use the facade in your code:

```
use LaravelLogMonitor\Facades\LogMonitor;

// Get the watcher instance
$watcher = LogMonitor::getWatcher();
```

Troubleshooting
---------------

[](#troubleshooting)

### No alerts are being sent

[](#no-alerts-are-being-sent)

1. Check that Telegram credentials are correct in `.env`
2. Verify the log levels are configured in `config/log-monitor.php`
3. Check that the log file exists and is readable
4. Review Laravel logs for any errors

### Bot not responding

[](#bot-not-responding)

1. Make sure you've sent at least one message to your bot
2. Verify the chat ID is correct
3. Check that the bot token is valid

### File permission issues

[](#file-permission-issues)

Make sure the web server user can read the log files:

```
chmod 644 storage/logs/laravel-*.log
```

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

[](#requirements)

- PHP &gt;= 8.1
- Laravel &gt;= 10.0
- Guzzle HTTP Client (for Telegram API)

License
-------

[](#license)

MIT

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

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

Support
-------

[](#support)

For issues and questions, please open an issue on GitHub.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance72

Regular maintenance activity

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

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

3

Last Release

158d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/10c31b64d81699fa421400a88cca259bd162714a9270d97cab84644dcfdac502?d=identicon)[bdmotaleb](/maintainers/bdmotaleb)

---

Top Contributors

[![bdmotaleb](https://avatars.githubusercontent.com/u/34369086?v=4)](https://github.com/bdmotaleb "bdmotaleb (12 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/laravel-log-monitor-log-monitor/health.svg)

```
[![Health](https://phpackages.com/badges/laravel-log-monitor-log-monitor/health.svg)](https://phpackages.com/packages/laravel-log-monitor-log-monitor)
```

###  Alternatives

[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[yadahan/laravel-authentication-log

Laravel Authentication Log provides authentication logger and notification for Laravel.

416632.8k5](/packages/yadahan-laravel-authentication-log)[inspector-apm/inspector-laravel

Code Execution Monitoring, built for developers.

2332.0M2](/packages/inspector-apm-inspector-laravel)[marvinlabs/laravel-discord-logger

Logging to a discord channel in Laravel

2081.1M2](/packages/marvinlabs-laravel-discord-logger)[larabug/larabug

Laravel 6.x/7.x/8.x/9.x/10.x/11.x/12.x/13.x bug notifier

299549.3k1](/packages/larabug-larabug)[honeybadger-io/honeybadger-laravel

Honeybadger Laravel integration

431.2M](/packages/honeybadger-io-honeybadger-laravel)

PHPackages © 2026

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