vmorozov/laravel_fluentd_logger
最新稳定版本:v1.1.1
Composer 安装命令:
composer require vmorozov/laravel_fluentd_logger
包简介
Provides ability to use fluentd as log driver.
关键字:
README 文档
README
This package provides ability to use fluentd as log driver. It also add additional logging capabilities such as:
- Request log
- DB Query log
- Queue Jobs log
- Log tracing
Installation
You can install the package via composer:
composer require vmorozov/laravel_fluentd_logger
You can publish the config file with:
php artisan vendor:publish --tag="laravel_fluentd_logger-config"
Add middlewares to app/Http/Kernel.php:
protected $middleware = [ // ... other middlewares here \Vmorozov\LaravelFluentdLogger\Middleware\LogRequestMiddleware::class, \Vmorozov\LaravelFluentdLogger\Middleware\ContinueTraceMiddleware::class, ];
Add fluentd log channel to config/logging.php:
// ...some exisiting channels 'fluentd' => [ 'driver' => 'fluentd', 'level' => env('LOG_LEVEL', 'debug'), ],
Add ENV vars with fluentd configs:
FLUENTD_HOST=127.0.0.1 FLUENTD_PORT=24224
Configuration
In config file laravel_fluentd_logger.php you can make some adjustments:
- Disable some features
'features_enabled' => [ 'request_log' => false, 'db_query_log' => false, 'queue_log' => false, ],
- Overwrite default fluentd log handler
// optionally override \Vmorozov\LaravelFluentdLogger\Logs\FluentHandler class to customize behaviour 'handler' => SomeCustomHandler::class,
- Change log tag format
'tagFormat' => '{{app_name}}.{{level_name}}',
- Overwrite some options for fluentd sdk classes
/** @see https://github.com/fluent/fluent-logger-php/blob/master/src/FluentLogger.php */ 'options' => [], /** @see https://github.com/fluent/fluent-logger-php/blob/master/src/PackerInterface.php */ // specified class name 'packer' => null,
Fluentd config samples
- simple stdout output:
<match your_app_name_from_env.**>
type stdout
</match>
- output to elasticsearch + stdout:
# sendlog to the elasticsearch
# the host must match to the elasticsearch
# container service
<match your_app_name_from_env.**>
@type copy
<store>
@type elasticsearch
host elasticsearch
port 9200
logstash_format true
logstash_prefix fluentd
logstash_dateformat %Y-%m-%d
include_tag_key true
type_name access_log
tag_key @log_name
flush_interval 1s
log_es_400_reason false
</store>
<store>
@type stdout
</store>
</match>
- config for fluentd to accept data using port:
# bind fluentd on IP 0.0.0.0
# port 24224
<source>
@type forward
port 24224
bind 0.0.0.0
</source>
More info about fluentd configuration can be found in official fluentd documentation.
Monolog processors
You can add processors to the monolog handlers by adding them to the processors array within the laravel_fluentd_logger.php config.
config/laravel_fluentd_logger.php:
'processors' => [CustomProcessor::class],
CustomProcessor.php:
class CustomProcessor { public function __invoke($record) { $record['extra']['level'] = $record['level_name']; return $record; } }
Testing
composer test
Credits
License
The MIT License (MIT). Please see License File for more information.
vmorozov/laravel_fluentd_logger 适用场景与选型建议
vmorozov/laravel_fluentd_logger 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11 次下载、GitHub Stars 达 1, 最近一次更新时间为 2022 年 12 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「debugging」 「laravel」 「logs」 「advanced logging」 「fluentd」 「request log」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 vmorozov/laravel_fluentd_logger 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vmorozov/laravel_fluentd_logger 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 vmorozov/laravel_fluentd_logger 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The tenancy/tenancy logs mutations
A PHP package that takes a snapshot of your application and allows you to retrieve it later to help with debugging.
Laravel Database Query Logger and debug helper.
Laravel 5.x.x library for integration Monolog Sentry
Pacote simplificado para persistência de logs
Change logs for orchid platform.
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-12-09