Skip to content

phucnguyenvn/yii2-stream-log

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

yii2-stream-log

Yii2 module, provide a cli to send log to elasticsearch asynchronously use redis as a local buffer

Installation

The preferred way to install this extension is through composer.

Either run

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

or add

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

to the require section of your composer.json file.

Configure

Configure config/console.php and config/web.php as follows

  'bootstrap' => [
      'log',
      'streamlog',
  ],
  'modules' => [
     ................
     'streamlog' => [
         'class'     => 'macfly\streamlog\Module',
         'redis'     => [
             'hostname'  => REDIS_HOST,
             'port'      => REDIS_PORT,
             'database'  => REDIS_LOG_DB,
         ],
         'redisTarget'    => [
             'exportInterval' => 1,
             'logVars'        => [],
             'logUser'        => true,
             'logApp'         => true,
             'logTracker'     => true,
             'logUserIp'      => true,
             'logSession'     => true,
             'userNameAt'     => 'username',
         ],
         'elasticsearchTarget' => [
            'db' => [
                'class'             => 'yii\elasticsearch\Connection',
                'autodetectCluster' => false,
                'defaultProtocol'   => 'https',
                'nodes'             => [
                    [
                        'http_address' => 'inet[/' . ELASTICSEARCH_HOST . ':' . ELASTICSEARCH_PORT . ']',
                    ],
                ],
            ],
        ],
    ],
    ................
  ],

Usage

Run the following to enable log streaming from redis to elasticsearch

php yii streamlog/sender/start

About

Yii2 module provide a cli to send log to elasticsearch asynchronously use redis as a local buffer

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • PHP 100.0%