airani/yii2-elasticsearch-log

Yii 2.0 Elasticsearch log target

Installs: 9 757

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 2

Forks: 0

Open Issues: 0

Type:yii2-extension

v1.0.1 2017-10-14 22:13 UTC

This package is auto-updated.

Last update: 2024-04-08 22:38:09 UTC


README

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require -vv --prefer-dist airani/yii2-elasticsearch-log

or add below line to the composer.json and run php composer.phar update -vv --prefer-dist --profile

"airani/yii2-elasticsearch-log": "~1.0"

Usage

Config elasticsearch log target in config file like below code. with set extraFields property in log target config you can set more extra fields to log results.

'components' => [
    // ...
    'log' => [
        'targets' => [
            [
                'class' => 'airani\log\ElasticsearchTarget',
                'levels' => ['error', 'warning'],
                'index' => 'yii',
                'type' => 'log',
                'db' => 'elasticsearch',
                'extraFields' => [
                    'ip' => function ($app) {
                        return $app->request->getUserIP();
                    }
                ]
            ],
        ],
    ],
],