mitrm / yii2-logstash
Отправка данных в Logstash
Installs: 1 465
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 1
Open Issues: 0
Type:yii2-extension
Requires
- yiisoft/yii2: *
This package is auto-updated.
Last update: 2024-10-26 07:15:52 UTC
README
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist mitrm/yii2-logstash "*"
or add
"mitrm/yii2-logstash": "*"
to the require section of your composer.json
file.
Usage
В components добавить
Для отправки через tcp
'logstash' => [ 'class' => \mitrm\logstash\LogstashSend::class, 'config' => [ 'class' => \mitrm\logstash\transport\TcpTransport::class, 'socket' => 'tcp://localhost:5000' ], ],
Для отправки через http
'logstash' => [ 'class' => \mitrm\logstash\LogstashSend::class, 'config' => [ 'class' => \mitrm\logstash\transport\HttpTransport::class, 'port' => 5001, 'host' => 'http://localhost' ], ],
Для отправки данных
Yii::$app->logstash->sendLog(['event' => 'orderPay', 'userId' => Yii::$app->user->id]);
Для отправки логов Yii в logstash
'log' => [ 'traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [ [ 'class' => \mitrm\logstash\LogstashTarget::class, 'levels' => ['error', 'warning'], 'logVars' => ['_GET', '_POST', '_SESSION', '_SERVER'], 'clientOptions' => [ 'release' => $params['release_app'] ?? null, ], 'isLogUser' => true, // Добавить в лог ID пользователя 'isLogContext' => false, 'extraCallback' => function ($message, $extra) { $extra['app_id'] = Yii::$app->id; return $extra; }, 'except' => ['order'], ], ], ],