kphcdr

laravel 日志添加跟踪 ID

v1.1.0 2024-08-23 06:17 UTC

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]