Menü schliessen
Created: December 6th 2025
Categories: Laravel,  Laravel Package,  Php
Author: Miljan Puzovic

Laravel Log Monitor v1.1.0: Pest Testing, PHP 8.4, and Advanced Event System for Reliable Error Tracking

Introduction: Elevating Laravel Error Monitoring

Error tracking and log monitoring are critical for any production Laravel application. Laravel Log Monitor v1.1.0 introduces comprehensive Pest test coverage (72 tests), full PHP 8.4 support, a powerful event system, enhanced multi-channel Mattermost routing, and automatic retry logic for notification delivery.

For the complete installation guide, see our previous blog post.

What's New in v1.1.0

Comprehensive Pest Test Coverage

Version 1.1.0 introduces 72 comprehensive tests built with Pest PHP covering:

  • Service functionality: Message handling, environment filtering, context processing
  • Configuration validation: Mattermost and email settings
  • Event system: All three notification events
  • Multi-channel routing: Single and multiple channel configurations
  • Email notifications: Single and multiple recipients
  • Priority and retry logic: Metadata and retry mechanisms
composer test
# Tests: 72 passed (128 assertions)
# Duration: 1.13s

PHP 8.4 Support

Laravel Log Monitor v1.1.0 now requires PHP 8.4, ensuring compatibility with Laravel 11 and 12. Benefits include improved performance, enhanced type safety and modern language features.

Advanced Event System

Hook into the notification lifecycle with three new events:

1. NotificationSending – Before sending:

use LEXO\LaravelLogMonitor\Events\NotificationSending;

Event::listen(NotificationSending::class, function (NotificationSending $event) {
    Log::info("Preparing to send {$event->channel} notification", [
        'level' => $event->event->level,
        'message' => $event->event->message,
    ]);
});

2. NotificationSent – After successful delivery:

use LEXO\LaravelLogMonitor\Events\NotificationSent;

Event::listen(NotificationSent::class, function (NotificationSent $event) {
    Metrics::increment('log_monitor.notifications.sent', [
        'channel' => $event->channel,
        'level' => $event->event->level,
    ]);
});

3. NotificationFailed – When delivery fails:

use LEXO\LaravelLogMonitor\Events\NotificationFailed;

Event::listen(NotificationFailed::class, function (NotificationFailed $event) {
    if ($event->channel === 'mattermost') {
        Http::post(config('services.slack.webhook'), [
            'text' => "⚠️ Mattermost failed: {$event->exception->getMessage()}",
        ]);
    }
});

Multi-Channel Routing

Send notifications to multiple Mattermost channels simultaneously:

// config/laravel-log-monitor.php
'mattermost' => [
    'enabled' => env('LARAVEL_LOG_MONITOR_MATTERMOST_ENABLED', true),
    'url' => env('LARAVEL_LOG_MONITOR_MATTERMOST_URL', ''),
    'token' => env('LARAVEL_LOG_MONITOR_MATTERMOST_TOKEN', ''),
    'channel_id' => env('LARAVEL_LOG_MONITOR_MATTERMOST_CHANNEL', ''),
    'additional_channels' => [
        'payments' => 'channel-id-payment-team',
        'security' => 'channel-id-security-team',
        'critical' => [
            'channel-id-oncall-pager',
            'channel-id-management',
        ],
    ],
],

Usage:

// Route to specific team
Log::error('Payment gateway timeout', [
    'llm' => ['channel' => 'payments', 'priority' => 'urgent'],
]);

// Broadcast to multiple channels
Log::emergency('Database connection lost', [
    'llm' => ['channel' => ['critical', 'default'], 'priority' => 'urgent'],
]);

Automatic Retry Logic

Configure retry behavior for Mattermost notifications:

LARAVEL_LOG_MONITOR_MATTERMOST_RETRY_TIMES=3
LARAVEL_LOG_MONITOR_MATTERMOST_RETRY_DELAY=100
LARAVEL_LOG_MONITOR_MATTERMOST_TIMEOUT=10

Uses Laravel's HTTP client retry with exponential backoff. If all retries fail, the NotificationFailed event fires and email backup sends automatically.

Installation

Requirements

  • PHP: 8.4.0+
  • Laravel: 10.x, 11.x, or 12.x

Steps

# Install
composer require lexo/laravel-log-monitor

# Publish config (optional)
php artisan vendor:publish --tag=laravel-log-monitor-config

Add to your .env:

LARAVEL_LOG_MONITOR_ENABLED=true
LARAVEL_LOG_MONITOR_ENVIRONMENTS=production,staging

# Mattermost
LARAVEL_LOG_MONITOR_MATTERMOST_ENABLED=true
LARAVEL_LOG_MONITOR_MATTERMOST_URL=https://mattermost.yourcompany.com
LARAVEL_LOG_MONITOR_MATTERMOST_TOKEN=your-bot-token
LARAVEL_LOG_MONITOR_MATTERMOST_CHANNEL=channel-id

# Email
LARAVEL_LOG_MONITOR_EMAIL_ENABLED=true
LARAVEL_LOG_MONITOR_EMAIL_RECIPIENTS=devteam@yourcompany.com
LARAVEL_LOG_MONITOR_EMAIL_SEND_AS_BACKUP=true

Upgrade from v1.0.x

# Verify PHP 8.4+
php -v

# Update
composer update lexo/laravel-log-monitor

# Clear cache
php artisan config:clear && php artisan cache:clear

Breaking change: PHP 8.4 is now required. All other features are backward compatible.

Conclusion

Laravel Log Monitor v1.1.0 delivers production-ready error monitoring with comprehensive test coverage, modern PHP support, a flexible event system, and intelligent multi-channel routing.

The package is available on Packagist and GitHub.

Ready to upgrade? Run composer update lexo/laravel-log-monitor today.