hitman/es-log

There is no license information available for the latest version (1.0.3) of this package.

log to elasticsearch

1.0.3 2019-11-09 10:02 UTC

This package is not auto-updated.

Last update: 2025-05-04 11:30:48 UTC


README

日志记录工具

安装

composer require hitman/eslog:dev-master

使用

Step1 config/app.php 添加

Hitman\Elasticsearch\EsLogServiceProvider::class,

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

Step2 生成配置文件 config/es.php

php artisan vendor:publish

Step3 修改配置

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

Step4 使用

// 使用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); // 自定义类型日志