hitman/es-log

该软件包最新版本(1.0.3)没有可用的许可信息。

日志记录到 Elasticsearch

1.0.3 2019-11-09 10:02 UTC

This package is not auto-updated.

Last update: 2024-09-22 08:42:47 UTC


README

日志记录工具

安装

composer require hitman/eslog:dev-master

使用

步骤1 在 config/app.php 中添加

Hitman\Elasticsearch\EsLogServiceProvider::class,

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

步骤2 生成配置文件 config/es.php

php artisan vendor:publish

步骤3 修改配置

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

步骤4 使用

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