Yii2 module, provide a cli to send log to elasticsearch asynchronously use redis as a local buffer
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 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 . ']',
],
],
],
],
],
................
],Run the following to enable log streaming from redis to elasticsearch
php yii streamlog/sender/start