PHP code example of airani / yii2-elasticsearch-log

1. Go to this page and download the library: Download airani/yii2-elasticsearch-log library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

airani / yii2-elasticsearch-log example snippets


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