ennnnny / laravel-es-log
Elasticsearch logger handler
v1.0.7
2020-11-20 01:39 UTC
Requires
- php: ^7.2
- ext-json: *
- elasticsearch/elasticsearch: ^7.0
- laravel/framework: ^6.0|^7.0
- monolog/monolog: ^2.0
README
Elasticsearch logger for Laravel
Installation
$ composer require ennnnny/laravel-es-log $ php artisan vendor:publish --tag=ennnnny.es_log
Config
You can modify config in config/logger.php
.
Now we can add the channel
of channels
in config/logging.php
file.
'channels' => [ 'elastic' => [ 'driver' => 'monolog', 'handler' => \Monolog\Handler\ElasticsearchHandler::class, 'handler_with' => [ 'options' => config('es_log.options'), 'level' => config('es_log.level'), 'bubble' => config('es_log.bubble') ], 'formatter' => \Eslog\Formatter\EslogFormatter::class, ], ],
Now define the environment variable in .env
file like this:
LOG_CHANNEL=elastic
ELASTICSEARCH_LOG_LEVEL=200
ELASTICSEARCH_HOST=localhost
ELASTICSEARCH_PORT=9200
ELASTICSEARCH_SCHEME=http
ELASTICSEARCH_USER=
ELASTICSEARCH_PASS=