kriss / yii2-redis-log
Yii2 log redisTarget
Installs: 34 922
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 1
Open Issues: 0
Type:yii2-extension
Requires
- yiisoft/yii2: ^2.0
- yiisoft/yii2-redis: ^2.0
This package is auto-updated.
Last update: 2024-12-10 14:47:34 UTC
README
Yii2 log for redisTarget and dump redisLog to FileTarget.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist kriss/yii2-redis-log -vvv
or add
"kriss/yii2-redis-log": "*"
to the require section of your composer.json
file.
Simple Usage
- config config file
'log' => [ 'targets' => [ [ 'class' => 'kriss\log\RedisTarget', 'redis' => [ 'hostname' => 'localhost', 'port' => 6379, ], // If you have configured the redis yii\redis\Connection as an application component,use bwlow //'redis' => 'redis', 'key' => 'yii.log', 'levels' => ['error', 'warning'], ], ] ]
- use Yii common Logger component like :
Yii::error('this is en error');
- now you see log in your redis
Dump Redis Log to File
- config
'log' => [ 'targets' => [ [ 'class' => 'kriss\log\RedisTarget', 'redis' => 'redis', 'key' => 'yii.log', 'dumpFileTarget' => [ 'logFile' => '@common/runtime/logs/error.log', ], 'levels' => ['error', 'warning'], ], ] ]
2.1. Dump One
$dumper = new Dump2File([ 'redisTargetKey' => 'yii.log', ]); $dumper->dump();
2.2. Dump From Yii Log Target
$targets = Yii::$app->log->targets; foreach ($targets as $target) { if ($target instanceof RedisTarget) { $dumper = new Dump2File([ 'redisTarget' => $target, 'count' => 1000 ]); $dumper->dump(); } }