Could we help you? Please click the banners. We are young and desperately need the money
In the fast-paced world of web development, staying on top of application errors can mean the difference between a smooth user experience and frustrated customers. For Laravel developers, log files are a critical yet often underutilized resource for maintaining application health. The Laravel Log Monitor package by LEXO GmbH transforms these cryptic log files into actionable insights, helping you identify and resolve issues before they impact your users.
Laravel's robust logging system captures a wealth of information about your application's performance and errors. However, manually sifting through these logs is time-consuming and inefficient. Important error patterns can easily go unnoticed until they escalate into major problems.
Consider these common scenarios:
Without proper monitoring, these issues can persist for days or even weeks before being addressed. The Laravel Log Monitor package solves this problem by providing automated monitoring and alerting for your application logs.
The Laravel Log Monitor package is an open-source solution developed by LEXO GmbH that seamlessly integrates with Laravel's existing logging system. Its primary purpose is to monitor your application's log files and send notifications when predefined error thresholds are exceeded. Notifications can be sent to Mattermost adn/or E-Mail.
By implementing Laravel Log Monitor, you'll transform your passive log files into an active monitoring system that keeps you informed about your application's health.
Link to GitHub page of LEXO Laravel Log Monitor.
First, you'll need to install the package via Composer:
composer require lexo/laravel-log-monitor
After installation, you can optionally publish the configuration file:
php artisan vendor:publish --tag=laravel-log-monitor-config
This will create a config/log-monitor.php file where you can customize the package's behavior.
Configure the package by adding these variables to your .env file:
LARAVEL_LOG_MONITOR_ENABLED=true
# Environments where monitoring is active (comma-separated)
LARAVEL_LOG_MONITOR_ENVIRONMENTS=production,local
# Mattermost integration settings
LARAVEL_LOG_MONITOR_MATTERMOST_URL=https://your-mattermost-url.tld
LARAVEL_LOG_MONITOR_MATTERMOST_TOKEN=your-mattermost-token
LARAVEL_LOG_MONITOR_MATTERMOST_CHANNEL=mattermost-channel-id
# Email notification recipients (comma-separated)
LARAVEL_LOG_MONITOR_EMAIL_RECIPIENTS=email1@website.tld,email2@website.tld
By default:
Only the production environment is monitored. Email notifications serve as a backup if Mattermost notifications fail.
To enable simultaneous Mattermost and email notifications, set in .env file:
LARAVEL_LOG_MONITOR_EMAIL_SEND_AS_BACKUP=false
The complete list of configuration options is available in the config file.
You can set Mattermost notification priority using the llm context key in your log messages:
Log::critical('test error', [
'llm' => [
'priority' => 'important',
'alert' => true
],
'something' => 'else'
]);
Notes:
Publish the configuration file to customize settings:
php artisan vendor:publish --tag=laravel-log-monitor-config
Customize the notification templates by publishing the view files:
php artisan vendor:publish --tag=laravel-log-monitor-views-email
Customize the notification templates by publishing the view files:
php artisan vendor:publish --tag=laravel-log-monitor-views-mattermost