PHPackages                             zatxm/yii2-monolog - 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. zatxm/yii2-monolog

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

zatxm/yii2-monolog
==================

PHP's yii2 uses monolog as log component

3.1.1(2y ago)0126↓100%[1 PRs](https://github.com/zatxm/yii2-monolog/pulls)MITPHPPHP &gt;=8.0

Since Oct 16Pushed 2y ago1 watchersCompare

[ Source](https://github.com/zatxm/yii2-monolog)[ Packagist](https://packagist.org/packages/zatxm/yii2-monolog)[ RSS](/packages/zatxm-yii2-monolog/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (7)Used By (0)

Yii2 monolog
============

[](#yii2-monolog)

Yii2 monolog是将monolog日志库应用于yii2框架

Usage
=====

[](#usage)

composer require zatxm/yii2-monolog，用于php8+

composer require zatxm/yii2-monolog:"^2.0"，用于php7.2+

```
use Monolog\Handler\StreamHandler;
use Monolog\Logger;

$logger = new Logger('my_logger');
$logger->pushHandler(new StreamHandler(__DIR__.'/my_app.log', Logger::Debug));

return [
    // ...
    'bootstrap' => ['log'],
    // ...
    'components' => [
        // ...
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => \Zatxm\YiiMonolog\MonologTarget::class,
                    'extractTrace' => false, //记录堆栈，可以不配置，默认false
                    'logger' => '', //要用原生的monolog一定保留此键，空字符系统会生成monolog logger
                    // 'logger' => $logger, //或者用这个自己定义的monolog logger
                    // 'logger' => function () {
                    //     $logger = new Logger('my_logger');
                    //     $logger->pushHandler(new StreamHandler(__DIR__.'/my_app.log', Logger::Debug));
                    //     return $logger;
                    // } // 或者用闭包
                    'levels' => ['error', 'warning']
                ]
            ],
        ]
    ],
];
```

Yii自带方法快捷使用:

```
Yii::info('Info message');
Yii::error('Error message');
```

原生的monolog使用，具体用法可查看[monolog库](https://github.com/Seldaek/monolog):

```
Yii::$app->monolog->info('My logger is now ready');
```

License
=======

[](#license)

MIT

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Every ~0 days

Total

6

Last Release

937d ago

Major Versions

2.0.0 → 3.0.02023-10-17

2.x-dev → 3.1.12023-10-18

PHP version history (2 changes)2.0.0PHP &gt;=5.6

3.0.0PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/261b444d45e7c3985e763197811f598d2ae49ce7727fd5e9970fdd92532a40ad?d=identicon)[zatxm](/maintainers/zatxm)

---

Top Contributors

[![zatxm](https://avatars.githubusercontent.com/u/66353899?v=4)](https://github.com/zatxm "zatxm (5 commits)")

---

Tags

phpyii2componentmonolog

### Embed Badge

![Health badge](/badges/zatxm-yii2-monolog/health.svg)

```
[![Health](https://phpackages.com/badges/zatxm-yii2-monolog/health.svg)](https://phpackages.com/packages/zatxm-yii2-monolog)
```

###  Alternatives

[logtail/monolog-logtail

Logtail handler for Monolog

233.2M3](/packages/logtail-monolog-logtail)[mero/yii2-monolog

The Monolog integration for the Yii framework.

42186.1k](/packages/mero-yii2-monolog)

PHPackages © 2026

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