Install Monolog (opens new window) (any logger that implements the PSR/Log
interface works)
{
"require": {
...
"elasticsearch/elasticsearch" : "~5.0",
"monolog/monolog": "~1.0"
}
}
1
2
3
4
5
6
7
2
3
4
5
6
7
Create a log object and inject it into the client
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
$logger = new Logger('name');
$logger->pushHandler(new StreamHandler('path/to/your.log', Logger::WARNING));
$client = ClientBuilder::create() // Instantiate a new ClientBuilder
->setLogger($logger) // Set your custom logger
->build(); // Build the client object
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
Refs:
- https://www.elastic.co/guide/en/elasticsearch/client/php-api/master/enabling_logger.html
Comment