macfly / yii2-stream-log
此包已被废弃,不再维护。未建议替代包。
Yii2模块,提供命令行工具以异步将日志发送到Elasticsearch,并使用Redis作为本地缓冲区
0.1.7
2021-01-06 04:53 UTC
Requires
- yiisoft/yii2: ~2.0.5
- yiisoft/yii2-elasticsearch: ~2.1.0
- yiisoft/yii2-redis: ^2.0
README
Yii2模块,提供命令行工具以异步将日志发送到Elasticsearch,并使用Redis作为本地缓冲区
安装
安装此扩展的首选方式是通过composer。
运行以下命令之一:
php composer.phar require --prefer-dist "macfly/yii2-stream-log" "*"
或者
"macfly/yii2-stream-log": "*"
将以下内容添加到你的composer.json文件的require部分。
配置
按照以下方式配置config/console.php和config/web.php:
'bootstrap' => [ 'log', 'streamlog', ], 'modules' => [ ................ 'streamlog' => [ 'class' => 'macfly\streamlog\Module', 'redisTarget' => [ 'exportInterval' => 1, 'logVars' => [], 'logUser' => true, 'logApp' => true, 'logTracker' => true, 'logUserIp' => true, 'logSession' => true, 'userNameAt' => 'username', ], 'elasticsearchTarget' => [ 'indexDateFormat' => 'y-MM-dd', // Set date to append to index, will be yii-2018-10-24 ], ], ................ ],
用法
运行以下命令以启用从Redis到Elasticsearch的日志流:
php yii streamlog/sender/start