hitman/es-log

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

log to elasticsearch

Maintainers

Details

github.com/Hitmanv/eslog

Source

Issues

Installs: 378

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/hitman/es-log

1.0.3 2019-11-09 10:02 UTC

This package is not auto-updated.

Last update: 2025-10-19 13:54:55 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); // 自定义类型日志