outl1ne/laravel-elastic-logger 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

outl1ne/laravel-elastic-logger

最新稳定版本:1.2.0

Composer 安装命令:

composer require outl1ne/laravel-elastic-logger

包简介

Laravel Elastic Cloud logging for MessageLogged event.

README 文档

README

This package will listen to the Illuminate\Log\Events\MessageLogged event and queue the log data to be sent to Elastic Kibana index by your queue handler.

It will listen to all Log events and will also handle exceptions separately.

Requirements

- PHP >=8.0
- laravel/framework ^8.7 || ^9.0

Dependencies

"elasticsearch/elasticsearch": "^8.5"

Important notice

Do not log Queue::before / after events. This will cause an infinite loop of logging and will cause your application to crash.

In general be careful about the possibility of log loops.

Tested with redis and database queue drivers.

If you're working on Google cloud, consider setting up stackkits laravel-google-cloud-tasks-queue

Installation

Install package

composer require outl1ne/laravel-elastic-logger

Configure the environment variables for the package

ELASTIC_ENABLED=true # only 'true' value will enable MessageLogged event being listened
ELASTIC_INDEX= # index where to send the logs
ELASTIC_CLOUD_ID= # your elastic instance cloud ID
ELASTIC_API_KEY= # your elastic API key
ELASTIC_EXCLUDE_LOG_LEVELS= # comma separated log levels to be excluded, IE: "info,warning"
ELASTIC_LIFECYCLE_POLICY= # lifecycle policy name for setting: body.settings.index.lifecycle.name. if not assigned not set.

Make sure your queue handler is configured properly

Cheat sheet / quick guide to set up Elastic.

Elastic offers 14 day free trial.

This package will auto-generate the indexes for you based on the ELASTIC_INDEX value. It will create indexes in the pattern of: ELASTIC_INDEX + _ + d-m-Y

  1. Create an account
  2. Create a new instance.
  3. Create a new Kibana Data view. Choose a name and match the index pattern with the index name you created. Kibana allows wildcards.
Choose the "datetime" field as the Timestamp field! This is important to allow convenient filtering based on the timestamp.

Elastic is able to create a new index on the fly but you cannot change the datetime field for the timestamp later, which will result in not having a proper timestamp filter.

Save the data view and view your newly created data view in the "Discover" section in the Analytics.

What the future brings

  • lifecycle policy management

License

This project is open-sourced software licensed under the MIT license.

统计信息

  • 总下载量: 2.81k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-12-29