tomatophp / laravel-logstash
Elastic Logstash integration for Laravel Apps
Fund package maintenance!
Requires
- php: ^8.2
- guzzlehttp/guzzle: ^7.8
- laravel/framework: ^12.0|^13.0
- monolog/monolog: ^3.0
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.24
- orchestra/testbench: ^10.0|^11.0
- pestphp/pest: ^4.0|^5.0
- pestphp/pest-plugin-laravel: ^4.0|^5.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-17 13:38:41 UTC
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
composer require tomatophp/laravel-logstash
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:
LOGSTASH_HOST=https://logstash.example.com:8080 LOG_CHANNEL=logstash
To keep your local log file as well, add logstash to the stack channel instead:
LOG_CHANNEL=stack LOG_STACK=single,logstash
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:
php artisan vendor:publish --tag="laravel-logstash-config"
To customise the channel, define it yourself in config/logging.php; the package will not overwrite it. Channel keys override the package config:
'logstash' => [ 'driver' => 'custom', 'via' => \TomatoPHP\LaravelLogstash\Logs\LogStashLogger::class, 'url' => env('LOGSTASH_HOST'), 'level' => 'error', 'queue' => true, 'queue_connection' => 'redis', 'queue_name' => 'logs', ],
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
composer test
Code Style
if you like to fix the code style just use this command
composer format
PHPStan
if you like to check the code by PHPStan just use this command
composer analyse
Other Filament Packages
Checkout our Awesome TomatoPHP
