tuozhongedu / monolog-elasticsearch-logstashformat
Use the logstash formatter with elasticsearch
7.0
2023-02-02 07:56 UTC
Requires
- php: ^5.6.6|^7.0
- elasticsearch/elasticsearch: ~5.0|~6.0|~7.0
- monolog/monolog: ~1.0
This package is not auto-updated.
Last update: 2024-11-21 16:20:13 UTC
README
This handler lets you put logs into Elasticsearch in the Logstash format, which makes visualization with Kibana very easy.
Recommended setup
use Elasticsearch\ClientBuilder; use Monolog\Formatter\LogstashFormatter; use Monolog\ElasticLogstashHandler; $client = ClientBuilder::create()->setHosts( [ 'http://127.0.0.1:9200' ] )->build(); $formatter = new LogstashFormatter('application', null, null, '', 1); $handler = new 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]);
Fork from https://github.com/nulpunkt/monolog-elasticsearch-logstashformat