定制 kriss/yii2-redis-log 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

kriss/yii2-redis-log

最新稳定版本:v1.3

Composer 安装命令:

composer require kriss/yii2-redis-log

包简介

Yii2 log redisTarget

README 文档

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

  1. 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'],
        ],
    ]
]
  1. use Yii common Logger component like :
Yii::error('this is en error');
  1. now you see log in your redis

Dump Redis Log to File

  1. 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();
    }
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-08-03