macfly/yii2-stream-log

此包已被废弃,不再维护。未建议替代包。

Yii2模块,提供命令行工具以异步将日志发送到Elasticsearch,并使用Redis作为本地缓冲区

安装量: 16,275

依赖者: 0

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 1

类型:yii2-extension

0.1.7 2021-01-06 04:53 UTC

This package is auto-updated.

Last update: 2023-04-13 03:40:37 UTC


README

Yii2模块,提供命令行工具以异步将日志发送到Elasticsearch,并使用Redis作为本地缓冲区

安装

安装此扩展的首选方式是通过composer

运行以下命令之一:

php composer.phar require --prefer-dist "macfly/yii2-stream-log" "*"

或者

"macfly/yii2-stream-log": "*"

将以下内容添加到你的composer.json文件的require部分。

配置

按照以下方式配置config/console.phpconfig/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