PHPackages                             xincheng/yii-trace - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. xincheng/yii-trace

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

xincheng/yii-trace
==================

yii log append trace id

v1.0.0(1y ago)0111MITPHPPHP &gt;=7.0

Since Jul 18Pushed 1y ago1 watchersCompare

[ Source](https://github.com/thinksvip/yii-trace)[ Packagist](https://packagist.org/packages/xincheng/yii-trace)[ RSS](/packages/xincheng-yii-trace/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

yii-trace-id
============

[](#yii-trace-id)

使用
--

[](#使用)

### 安装

[](#安装)

```

composer require xincheng/yii-trace
```

### 配置

[](#配置)

```
main.php

    use Xincheng\YiiTrace\Bootstrap;

    [
        'bootstrap'  => [Bootstrap::class],
        ...
    ]
```

```
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']);
            }
        ],
    ]

```

### 获取TraceId

[](#获取traceid)

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

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

### 使用外部TraceId

[](#使用外部traceid)

> header里需要设置： x-request-id

### 日志示例

[](#日志示例)

2024-07-16 15:48:41 \[36fb958d-3c5d-2928-a8be-2f77b2e50d8a\]\[info\]\[backend\\modules\\v1\\service\\base\\OrderStrategyService::getShipping\]

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 50% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

664d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8e7046d7c428a426b16e15e5eddc4c432781ec8037e2ddde5ac277548b8f4b82?d=identicon)[thinksvip](/maintainers/thinksvip)

---

Top Contributors

[![BaiNight](https://avatars.githubusercontent.com/u/45897338?v=4)](https://github.com/BaiNight "BaiNight (1 commits)")[![thinksvip](https://avatars.githubusercontent.com/u/23026450?v=4)](https://github.com/thinksvip "thinksvip (1 commits)")

---

Tags

traceid

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/xincheng-yii-trace/health.svg)

```
[![Health](https://phpackages.com/badges/xincheng-yii-trace/health.svg)](https://phpackages.com/packages/xincheng-yii-trace)
```

###  Alternatives

[bedezign/yii2-audit

Yii2 Audit records and displays web/cli requests, database changes, php/js errors and associated data.

201657.4k4](/packages/bedezign-yii2-audit)[mito/yii2-sentry

Yii 2 extension for Sentry

92377.7k](/packages/mito-yii2-sentry)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
