PHP code example of sllhsmile / hyperf-log
1. Go to this page and download the library: Download sllhsmile/hyperf-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/ */
sllhsmile / hyperf-log example snippets
use Sllhsmile\HyperfLog\Formatter\CustomizeJsonFormatter;
'default' => [
'handler' => [
// 按宿主项目需要配置 handler。
],
'formatter' => [
'class' => CustomizeJsonFormatter::class,
],
],
'redislog' => [
'enabled' => true,
'handlers' => ['default'],
],
'apilog' => [
'enabled' => true,
'handlers' => ['default'],
],
'sdklog' => [
'enabled' => true,
'response_enabled' => false,
'handlers' => ['default'],
],
'dblog' => [
'enabled' => true,
'response_enabled' => false,
'handlers' => ['default'],
],
'filename' => env('APP_ENV') === 'local'
? BASE_PATH . '/runtime/logs/file.log'
: env('HY_LOG_PATH') . '/file.log',
return [
'request_id_header' => 'x-b3-traceid',
'request_id_context_key' => 'x-b3-traceid',
'request_start_header' => 'x-request-start-time',
'request_start_context_key' => 'request_start_time',
'guzzle' => [
// 可选:未声明时使用 Guzzle 默认行为。
// 'timeout' => 10,
// 'connect_timeout' => 10,
],
];
bash
php bin/hyperf.php vendor:publish sllhsmile/hyperf-log --id=trace-log-config
text
workspace/
├── package/Sllhsmile/hyperf-log/ # 本包独立 Git 仓库
└── php-hyperf/ # 宿主项目