kphcdr /
laravel 日志添加跟踪 ID
v1.1.0
2024-08-23 06:17 UTC
Requires
Requires (Dev)
- illuminate/log: ^8.83
- illuminate/support: ^6|^7|^8|^9
- phpunit/phpunit: ^8.4|^9.0
This package is auto-updated.
Last update: 2024-09-23 06:26:52 UTC
README
使用方法
配置
logger.php
'stdout' => [
'driver' => 'monolog',
'handler' => StreamHandler::class,
'with' => [
'stream' => 'php://stdout',
],
'tap' => [\Trace\TraceInvoke::class], #new line
],
在 http 中
添加到 webMiddleware 组
使用 WithTraceHttpMiddleware::class
在作业中
public function middleware()
{
return [WithTraceJobMiddleware::class];
}
跟踪
设置头部 X-Trace-Id 为任何字符串
示例
[2022-06-20 20:37:49] local.INFO: hello 跟踪 ID [62b06a1d42fe8]