PHP code example of alan / yii2-monolog

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

    

alan / yii2-monolog example snippets


   'log' => [
               'traceLevel' => YII_DEBUG ? 3 : 0,
               'flushInterval' => 10,
               'targets' => [
                   [
                       'class' => 'common\log\MonologComponent',
                       'levels' => ['error', 'warning', 'info', 'trace', 'profile'],
                       'except' => [
                           'yii\base\*',
                       ],
                       'exportInterval' => 1,
                       'logVars' => [],
                       'channels' => [
                           'main' => [
                               'handler' => [
                                   [
                                       'class' => 'Monolog\Handler\StreamHandler',
                                       'stream' => '@app/runtime/logs/log_' . date('Y-m-d') . '.log',
                                       'level' => 'debug',
                                       'formatter' => [
                                           'class' => 'Monolog\Formatter\LogstashFormatter',
                                           'applicationName' => 'shanghu-backend',
                                           'systemName' => 'shanghu-test',
                                       ],
                                   ],
                               ],
                               'processor' => [
                                   \yii2\monolog\LogIdProcessor::instance(), //生成logId
                               ],
                           ],
                       ],
                   ]
               ],
           ],
   

   \yii2\monolog\LogIdProcessor::instance()->refresh();