nulpunkt/monolog-elasticsearch-logstashformat

Use the logstash formatter with elasticsearch

1.0.1 2016-03-07 07:32 UTC

This package is auto-updated.

Last update: 2024-11-17 14:38:29 UTC


README

This handler lets you put logs into Elasticsearch in the Logstash format, which makes visualization with Kibana very easy.

Recommended setup

$client = new Elasticsearch\Client(['hosts' => ['http://example.com:9200']]);
$formatter = new Monolog\Formatter\LogstashFormatter('application', null, null, '', 1);
$handler = new Monolog\ElasticLogstashHandler($client, ['type' => 'invoicing-logs']);
$handler->setFormatter($formatter);


$log = new Monolog\Logger('invoicing');
$log->pushHandler($handler);
$log->warn('new sale', ['user_id' => 42, 'product_id' => 7537]);