PHP code example of ccaglayan / elasticsearch-for-monolog
1. Go to this page and download the library: Download ccaglayan/elasticsearch-for-monolog library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ccaglayan / elasticsearch-for-monolog example snippets
use Elasticsearch\ClientBuilder;
use Monolog\Logger;
$config = ['127.0.0.1:9200'];
$client = ClientBuilder::create()->setHosts($config)->build();
$options = [
'index' => 'logs_monolog',
'type' => 'logs_doc'
];
$handler = new \ElasticSearch4Monolog\Handler\ElasticsearchHandler($client, $options);
$logger = new Logger('monologElastic');
$logger->pushHandler($handler);