PHP code example of monsterhunter / yii2-log

1. Go to this page and download the library: Download monsterhunter/yii2-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/ */

    

monsterhunter / yii2-log example snippets


'modules'=> [
    'log' => [
        'class' => 'monsterhunter\yii2\log\Module',
        //'layout' =>'@app/views/layouts/main'  //custom layout  
    ]
]

'components' => [
    'log' => [
        'traceLevel' => YII_DEBUG ? 3 : 0,
        'targets' => [
            [
                'class' => 'yii\log\DbTarget',
                'levels' => ['error', 'warning'],
                'except' => ['yii\web\HttpException:404'],
                'prefix' => function () {
                    $url = !Yii::$app->request->isConsoleRequest ? Yii::$app->request->getUrl() : null;
                    return sprintf('[%s][%s]', Yii::$app->id, $url);
                },
                'logVars' => [],
                'logTable' => '{{%system_log}}'
            ],
        ],
    ],
]
bash
  php yii migrate --migrationPath=@yii/log/migrations/