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

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

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

Monitor Laravel daily log files and send error notifications via email

v1.0.0(3w ago)03MITPHPPHP ^7.3|^8.0|^8.1|^8.2|^8.3

Since May 18Pushed 3w agoCompare

[ Source](https://github.com/shyambaldha/laravel-log-monitor)[ Packagist](https://packagist.org/packages/eheuristic/laravel-log-monitor)[ Docs](https://github.com/eheuristic/laravel-log-monitor)[ RSS](/packages/eheuristic-laravel-log-monitor/feed)WikiDiscussions development Synced 1w ago

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

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

[](#laravel-log-monitor)

[![Laravel](https://camo.githubusercontent.com/0d5b53c37aa259058a1d5f524c3619b3ddd4592cff9e009889cb100182368e98/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d38253230746f25323031312d7265642e737667)](https://laravel.com)[![PHP](https://camo.githubusercontent.com/972b840d9163498d88f90dbadd724a8de7bd81f38b94703db3faae0448d61c4d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d372e332532422d626c75652e737667)](https://php.net)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)

A comprehensive Laravel package that monitors daily log files and sends beautiful email notifications when errors are detected. Perfect for keeping your development and production teams informed about application health.

✨ Features
----------

[](#-features)

- 📧 **Multiple Recipients** - Send reports to unlimited email addresses
- 🔍 **Smart Error Detection** - Monitors emergency, alert, critical, and error levels
- 📊 **Beautiful HTML Emails** - Professional email template with error details and stack traces
- 📎 **Log File Attachments** - Automatically attaches log files (with configurable size limits)
- ⏰ **Flexible Scheduling** - Run daily, hourly, or on custom schedules
- ⚙️ **Highly Configurable** - Extensive configuration options
- 🎯 **Conditional Sending** - Only send emails when errors are found (configurable)
- 🔄 **Laravel 8-11 Compatible** - Works seamlessly across all modern Laravel versions
- 💪 **Production Ready** - Battle-tested error handling and logging

📋 Requirements
--------------

[](#-requirements)

- PHP 7.3 or higher
- Laravel 8.x, 9.x, 10.x, or 11.x
- Configured mail driver (SMTP, Mailgun, SES, etc.)

🚀 Installation
--------------

[](#-installation)

### Step 1: Install via Composer

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

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

### Step 2: Publish Configuration

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

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

This creates `config/log-monitor.php`.

### Step 3: Configure Environment Variables

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

Add to your `.env` file:

```
LOG_MONITOR_ENABLED=true
LOG_MONITOR_RECIPIENTS=admin@example.com,dev@example.com,support@example.com
LOG_MONITOR_ONLY_ERRORS=true
LOG_MONITOR_FROM_ADDRESS=noreply@example.com
LOG_MONITOR_FROM_NAME="Laravel Log Monitor"
```

**Important:** Replace email addresses with your actual recipients!

### Step 4: Schedule the Command

[](#step-4-schedule-the-command)

Add to `app/Console/Kernel.php`:

```
protected function schedule(Schedule $schedule)
{
    // Send yesterday's log report daily at 1:00 AM
    $schedule->command('log:send-report')
             ->dailyAt('01:00')
             ->timezone('Asia/Kolkata'); // Adjust to your timezone
}
```

### Step 5: Set Up Cron (Production)

[](#step-5-set-up-cron-production)

Add to your server's crontab:

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

📖 Usage
-------

[](#-usage)

### Manual Command Execution

[](#manual-command-execution)

Send yesterday's report:

```
php artisan log:send-report
```

Send report for a specific date:

```
php artisan log:send-report --date=2025-01-22
```

Force send even if no errors found:

```
php artisan log:send-report --force
```

### Testing the Package

[](#testing-the-package)

1. **Generate test errors:**

```
php artisan tinker
```

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

Log::error('Test error message');
Log::critical('Critical test error');
Log::emergency('Emergency test error');
exit
```

2. **Send test report:**

```
php artisan log:send-report --date=2025-01-23 --force
```

3. **Check your email!** 📬

⚙️ Configuration
----------------

[](#️-configuration)

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

### Basic Configuration

[](#basic-configuration)

```
'enabled' => true,  // Enable/disable monitoring
'recipients' => env('LOG_MONITOR_RECIPIENTS', ''),  // Email addresses
'send_only_on_errors' => true,  // Only send when errors exist
```

### Log Levels to Monitor

[](#log-levels-to-monitor)

```
'monitor_levels' => [
    'emergency',
    'alert',
    'critical',
    'error',
    // Add 'warning', 'notice', 'info', 'debug' if needed
],
```

### Email Customization

[](#email-customization)

```
'subject_template' => '[{app_name}] Log Report - {date} ({error_count} errors)',
'max_file_size_mb' => 10,  // Max attachment size
```

📧 Email Template
----------------

[](#-email-template)

The package includes a beautiful, responsive HTML email template featuring:

- **Summary Section** - Total errors and breakdown by level
- **Error Details** - Color-coded error levels with timestamps
- **Stack Traces** - Full stack traces for debugging
- **File Information** - Log file path and size
- **Smart Truncation** - Shows top 20 errors, notes if more exist

### Customizing the Email Template

[](#customizing-the-email-template)

Publish the views:

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

Edit: `resources/views/vendor/log-monitor/emails/log-report.blade.php`

🔧 Advanced Usage
----------------

[](#-advanced-usage)

### Custom Scheduling

[](#custom-scheduling)

```
// Hourly reports
$schedule->command('log:send-report')->hourly();

// Every 6 hours
$schedule->command('log:send-report')->everySixHours();

// Multiple times per day
$schedule->command('log:send-report')->dailyAt('09:00');
$schedule->command('log:send-report')->dailyAt('17:00');

// Weekdays only
$schedule->command('log:send-report')->dailyAt('09:00')->weekdays();
```

### Queue Support

[](#queue-support)

For large log files, use queues:

```
// In your scheduler
$schedule->command('log:send-report')->dailyAt('01:00')->runInBackground();
```

### Custom Log Paths

[](#custom-log-paths)

```
// In config/log-monitor.php
'log_path' => storage_path('custom-logs'),
```

🌍 Timezone Configuration
------------------------

[](#-timezone-configuration)

Common timezone settings:

```
// India
->timezone('Asia/Kolkata')

// US Eastern
->timezone('America/New_York')

// US Pacific
->timezone('America/Los_Angeles')

// UK
->timezone('Europe/London')

// UTC
->timezone('UTC')
```

🔍 How It Works
--------------

[](#-how-it-works)

1. **Scheduled Execution** - Laravel's task scheduler runs the command at the configured time
2. **Log Analysis** - The package analyzes the previous day's log file
3. **Error Extraction** - Extracts errors matching configured log levels with full stack traces
4. **Conditional Check** - Determines if email should be sent based on configuration
5. **Email Generation** - Creates beautiful HTML email with error details
6. **Multi-Recipient Send** - Sends to all configured email addresses
7. **Optional Attachment** - Attaches log file if size is within limits

**Timeline Example:**

- **Jan 23** - Your app generates logs → `laravel-2025-01-23.log`
- **Jan 24 at 1:00 AM** - Command runs and analyzes Jan 23 logs
- **Jan 24 at 1:00 AM** - Email sent to all recipients with Jan 23 errors

🛠️ Troubleshooting
------------------

[](#️-troubleshooting)

### No emails received?

[](#no-emails-received)

1. **Test mail configuration:**

```
php artisan tinker
```

```
Mail::raw('Test', function($msg) {
    $msg->to('test@example.com')->subject('Test');
});
```

2. **Check recipients:** Verify `LOG_MONITOR_RECIPIENTS` in `.env`
3. **Check log file exists:** `ls -lh storage/logs/`
4. **Run manually with force:** `php artisan log:send-report --force`
5. **Check Laravel logs:** `tail -f storage/logs/laravel-*.log`

### Scheduler not running?

[](#scheduler-not-running)

1. **Verify cron:** `crontab -l`
2. **List scheduled tasks:** `php artisan schedule:list`
3. **Test manually:** `php artisan schedule:run`
4. **Check timezone:** Ensure timezone matches your server

### Log file not found?

[](#log-file-not-found)

1. **Check logging configuration:** Review `config/logging.php`
2. **Verify daily channel:** Ensure using 'daily' or 'stack' with daily
3. **Check permissions:** `chmod -R 775 storage/logs`

📊 Configuration Reference
-------------------------

[](#-configuration-reference)

OptionTypeDefaultDescription`enabled`boolean`true`Enable/disable monitoring`recipients`string`''`Comma-separated emails`log_path`string`storage/logs`Log directory path`monitor_levels`arraySee configLog levels to monitor`send_only_on_errors`boolean`true`Send only if errors exist`date_format`string`Y-m-d`Log file date format`subject_template`stringSee configEmail subject template`max_file_size_mb`integer`10`Max attachment size (MB)`from_address`string`MAIL_FROM_ADDRESS`Sender email`from_name`string`MAIL_FROM_NAME`Sender name🤝 Contributing
--------------

[](#-contributing)

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

📄 License
---------

[](#-license)

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

🙏 Credits
---------

[](#-credits)

Developed with ❤️ for Laravel developers who want to stay informed about their application's health.

📞 Support
---------

[](#-support)

- **Issues:** [GitHub Issues](https://github.com/shyambaldha/laravel-log-monitor/issues)
- **Email:**
    -
    -
- **Documentation:** [Full Documentation](https://github.com/shyambaldha/laravel-log-monitor)

🔗 Related Packages
------------------

[](#-related-packages)

- [Laravel Telescope](https://laravel.com/docs/telescope) - For development debugging
- [Sentry for Laravel](https://docs.sentry.io/platforms/php/guides/laravel/) - For production error tracking
- [Laravel Log Viewer](https://github.com/rap2hpoutre/laravel-log-viewer) - Web-based log viewer

---

**Star ⭐ this repository if you find it helpful!**

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance95

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

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

22d ago

### Community

Maintainers

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

---

Top Contributors

[![shyambaldha](https://avatars.githubusercontent.com/u/68725482?v=4)](https://github.com/shyambaldha "shyambaldha (2 commits)")

---

Tags

loglaravelloggingemailerrornotificationmonitor

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[sentry/sentry-laravel

Laravel SDK for Sentry (https://sentry.io)

1.4k122.6M183](/packages/sentry-sentry-laravel)[spatie/laravel-health

Monitor the health of a Laravel application

88011.3M149](/packages/spatie-laravel-health)[laravel/ai

The official AI SDK for Laravel.

9782.1M153](/packages/laravel-ai)[propaganistas/laravel-disposable-email

Disposable email validator

6012.9M7](/packages/propaganistas-laravel-disposable-email)[yadahan/laravel-authentication-log

Laravel Authentication Log provides authentication logger and notification for Laravel.

417662.2k5](/packages/yadahan-laravel-authentication-log)[saasscaleup/laravel-log-alarm

Laravel log Alarm help you to set up alarm when errors occur in your system and send you a notification via Slack and email

26927.9k](/packages/saasscaleup-laravel-log-alarm)

PHPackages © 2026

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