PHP code example of hitman / es-log

1. Go to this page and download the library: Download hitman/es-log 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/ */

    

hitman / es-log example snippets


Hitman\Elasticsearch\EsLogServiceProvider::class,

// 添加Facade
'EsLog' => Hitman\Elasticsearch\Facade\EsLog::class,


return [
    'hosts' => ['127.0.0.1'], // elasticsearch 地址
    'index' => 'log', // elasticsearch index
    'type' => 'test', // elasticsearch type
    'async' => true, // 是否使用队列异步上传日志
    'queue' => 'default', // 日志对应的队列
];



// 使用DI
$eslog = resolve('eslog');
$eslog->error($data);
$eslog->info($data);
$eslog->event($event, $data);
$eslog->exception($exception);
$eslog->log($type, $data); // 自定义类型日志

## 使用Facade 
use EsLog;
EsLog::error($data);
EsLog::info($data);
EsLog::event($event, $data);
EsLog::exception($exception);
EsLog::log($type, $data); // 自定义类型日志
shell
php artisan vendor:publish