PHP code example of boscowu / laravel-tracelog

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

    

boscowu / laravel-tracelog example snippets


$app->register(boscowu\TraceLog\TraceLogServiceProvider::class);

// tracelog.php

return [
    //填写你的laravel项目中config/logging.php配置文件里channels数组下的日志格式名称
    'channel' => null, //默认null
    //trace-id的前缀设置
    'prefix'  => 'TraceLog:'
];

// logging.php

return [
'channels' => [
        'stack' => [   //填写此名称
            'driver' => 'stack',
            'channels' => ['daily'],
        ],

        'single' => [ //填写此名称
            'driver' => 'single',
            'path' => storage_path('logs/lumen.log'),
            'level' => 'debug',
        ],

        'daily' => [  //填写此名称
            'driver' => 'daily',
            'path' => storage_path('logs/lumen.log'),
            'level' => 'debug',
            'days' => 14,
        ],
];




function something()
{
  //打日志
  TraceLog::log('token1-1', $token);
  //如果设置了中间件trace-id为中间件生成的结果为查询依据
  TraceLog::log('token1-2', $token);
}

bash
php artisan vendor:publish --provider="boscowu\TraceLog\TraceLogServiceProvider"
bash
cp vendor/boscowu/trace-log/config/tracelog.php config/tracelog.php
 tracelog.php