PHP code example of xincheng / yii-trace

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

    

xincheng / yii-trace example snippets


    
composer 

main.php

    use Xincheng\YiiTrace\Bootstrap;
        
    [
        'bootstrap'  => [Bootstrap::class],
        ...
    ]


echo Yii::$app->params['trace_id'];

echo Yii::$app->traceId->getTraceId();

log.php 

    'traceLevel' => YII_DEBUG ? 3 : 0,
    'targets' => [
        [
            'class'       => 'yii\log\FileTarget',
            'levels'      => ['error', 'warning', 'info'],
            ...
            'prefix'      => function ($message) {
                return sprintf('[%s]', Yii::$app->params['trace_id']);
            }
        ],
    ]