Skip to content

ennnnny/laravel-es-log

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

laravel-es-log

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=

Credits