cesargb/laravel-logs-rotate
Composer 安装命令:
composer require cesargb/laravel-logs-rotate
包简介
Rotate files log with compression
关键字:
README 文档
README
This package allows you to rotate the Laravel record file with compression. This method is useful if you use logger channel single (StreamHandler)
Installation
You can install the package via composer:
composer require cesargb/laravel-logs-rotate
Usage
At this moment, every day at 00:00 your application executes a schedule to rotate the Laravel record files.
Configuration
If you need to change the frequency or another function, you can modify the config file.
You can publish config file with:
php artisan vendor:publish --provider="Cesargb\LaravelLog\RotateServiceProvider" --tag=config
This is the contents of the published config/rotate.php config file:
<?php return [ /* |-------------------------------------------------------------------------- | Compression Enable |-------------------------------------------------------------------------- | | This option defines if the file rotated must be compressed. | If you prefer not compress file, set this value at false. */ 'log_compress_files' => true, /* |-------------------------------------------------------------------------- | Schedule Rotate |-------------------------------------------------------------------------- | | Determine when must be run the cron. | You can disable the schedule change the option enable at false. | You can change the frequency with option cron. | */ 'schedule' => [ 'enable' => true, 'cron' => '0 0 * * *', ], /* |-------------------------------------------------------------------------- | Max Files Rotated |-------------------------------------------------------------------------- | | This value determine the max number of files rotated in the archive folder. | */ 'log_max_files' => env('LOG_MAX_FILES', 30), /* |-------------------------------------------------------------------------- | Minimum Log File Size |-------------------------------------------------------------------------- | | This value determines the minimum size (in bytes) that a log file must | have before it can be rotated. Files smaller than this size will not | be rotated. Set to 0 to disable this check and rotate regardless of size. | */ 'log_min_size' => env('LOG_MIN_SIZE', 0), /* |-------------------------------------------------------------------------- | Truncate Log file |-------------------------------------------------------------------------- | | This option defines if the log file must be truncated after rotated. | If you prefer not truncate file, set this value at false. */ 'truncate' => env('LOG_TRUNCATE', true), /* |-------------------------------------------------------------------------- | Other files to rotated |-------------------------------------------------------------------------- | | Array the other foreign files | | Example: | 'foreign_files' => [ storage_path('/logs/worker.log') | ] | */ 'foreign_files' => [] ];
Performance Tip for Monolog 3.10+
If you are using monolog/monolog:^3.10 or higher, you can disable the truncate option for more efficient log rotation:
'truncate' => false,
With Monolog 3.10+, the rotation process is optimized and truncating is no longer necessary, resulting in better performance. For more details, see monolog PR #1963.
Command
You have a command to rotate other files, rotate:files
php artisan rotate:files --help Description: Rotate files Usage: rotate:files [options] Options: -f, --file[=FILE] Files to rotate (multiple values allowed) -c, --compress[=COMPRESS] Compress the file rotated [default: "true"] -m, --max-files[=MAX-FILES] Max files rotated [default: "5"] -d, --dir[=DIR] Dir where archive the file rotated
Events
Every time a file is rotated one of these events occurs:
RotateWasSuccessful
Cesargb\LaravelLog\Events\RotateWasSuccessful
This event will be fired when rotated was successful.
It has two public properties:
- filename: the full path of file to rotate
- filenameTarget: the full path of file rotated
RotateHasFailed
Cesargb\LaravelLog\Events\RotativeHandler
This event will be fired when an error occurs while rotated
It has two public properties:
- filename: the full path of file to rotate
- exception: an object that extends PHP's Exception class.
About
You can only rotate the logs file was generate with logger channel StreamHandler.
Test
Run test with:
composer test
Upgrading
Please see UPGRADING for details.
Contributing
Any contributions are welcome.
License
The MIT License (MIT). Please see License File for more information.
cesargb/laravel-logs-rotate 适用场景与选型建议
cesargb/laravel-logs-rotate 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 59.31k 次下载、GitHub Stars 达 26, 最近一次更新时间为 2018 年 01 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「compression」 「laravel」 「logs」 「rotate」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 cesargb/laravel-logs-rotate 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cesargb/laravel-logs-rotate 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 cesargb/laravel-logs-rotate 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Asset Management for PHP
Image optimization / compression library. This library is able to optimize png, jpg and gif files in very easy and handy way. It uses optipng, pngquant, pngcrush, pngout, gifsicle, jpegoptim and jpegtran tools.
The tenancy/tenancy logs mutations
Laravel 5.x.x library for integration Monolog Sentry
Pacote simplificado para persistência de logs
Yii2 integration for TinyPng
统计信息
- 总下载量: 59.31k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 26
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-01-31