laravel-logstash
Elastic Logstash integration for Laravel Apps
composer require tomatophp/laravel-logstash- elasticsearch
- laravel
- log-channel
- logging
- logstash
Readme

Laravel Logstash Log Channel
Elastic Logstash log channel for Laravel apps. Every log record is formatted with Monolog's LogstashFormatter and posted as JSON to a Logstash HTTP input, through a queued job by default.
Compatibility
| Version | Laravel | PHP | Branch |
|---|---|---|---|
| 2.x | 12.x, 13.x | 8.2+ | master |
| 1.x | 10.x, 11.x | 8.1+ | v1 |
Installation
The service provider is auto-discovered and registers a logstash log channel. Add the Logstash HTTP input URL (host with port) to your .env and use the channel:
To keep your local log file as well, add logstash to the stack channel instead:
When LOGSTASH_HOST is empty nothing is sent. A failing or unreachable Logstash never throws, so logging can not break your app.
Queue
Records are sent by the TomatoPHP\LaravelLogstash\Jobs\NotifyLogstash job, so run a queue worker (or use the sync queue). To send directly over HTTP during the request, set LOGSTASH_QUEUE=false.
Configuration
| Env | Default | Description |
|---|---|---|
LOGSTASH_HOST | null | Logstash HTTP input URL |
LOGSTASH_LEVEL | debug | Minimum level sent to Logstash |
LOGSTASH_QUEUE | true | Send through the queued job |
LOGSTASH_QUEUE_CONNECTION | null | Queue connection for the job (app default) |
LOGSTASH_QUEUE_NAME | null | Queue name for the job (app default) |
LOGSTASH_TIMEOUT | 5 | HTTP timeout in seconds |
You can publish the config file with:
To customise the channel, define it yourself in config/logging.php; the package will not overwrite it. Channel keys override the package config:
Changelog
Please see CHANGELOG for more information on what has changed recently.
Security
Please see SECURITY for more information about security.
Credits
License
The MIT License (MIT). Please see License File for more information.
Testing
if you like to run PEST testing just use this command
Code Style
if you like to fix the code style just use this command
PHPStan
if you like to check the code by PHPStan just use this command
Other Filament Packages
Checkout our Awesome TomatoPHP