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

AbandonedArchivedYii2-extension[Logging &amp; Monitoring](/categories/logging)

sbooker/yii2-monolog
====================

The Monolog integration for the Yii framework.

0.2.2(8y ago)01.7kMITPHP

Since Oct 3Pushed 8y ago1 watchersCompare

[ Source](https://github.com/sbooker/yii2-monolog)[ Packagist](https://packagist.org/packages/sbooker/yii2-monolog)[ RSS](/packages/sbooker-yii2-monolog/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (6)Versions (11)Used By (0)

Monolog for Yii 2
=================

[](#monolog-for-yii-2)

[![SensioLabsInsight](https://camo.githubusercontent.com/e128ebfd699d51e5787c22a41566c6555c1415df10c4211b73cdf3af2f464271/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f39306533633636362d633162382d346162302d383436652d3431333435316264633032332f6d696e692e706e67)](https://insight.sensiolabs.com/projects/90e3c666-c1b8-4ab0-846e-413451bdc023)[![Build Status](https://camo.githubusercontent.com/23946d449922b6f8af42af43bf4f4e6d13e4949c673a9fd2f0517bf7c3bc9c1a/68747470733a2f2f7472617669732d63692e6f72672f6d65726f72616661656c2f796969322d6d6f6e6f6c6f672e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/merorafael/yii2-monolog)[![Coverage Status](https://camo.githubusercontent.com/e328472a83c245fa8f86ebfb2993930c47bee6cc5200ecc2d3cb0fa47e587fbe/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6d65726f72616661656c2f796969322d6d6f6e6f6c6f672f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/merorafael/yii2-monolog?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/9352583d0bb4c47bbd75e73a2bd7245f2cb6a5be9e6c9cadbd6a4fa49d8dc6f6/68747470733a2f2f706f7365722e707567782e6f72672f6d65726f2f796969322d6d6f6e6f6c6f672f762f737461626c652e737667)](https://packagist.org/packages/mero/yii2-monolog)[![Total Downloads](https://camo.githubusercontent.com/be69af19e736ed6b66c421f342d3a0f1c0cbcaf9634f09912e989f6d95c79965/68747470733a2f2f706f7365722e707567782e6f72672f6d65726f2f796969322d6d6f6e6f6c6f672f646f776e6c6f6164732e737667)](https://packagist.org/packages/mero/yii2-monolog)[![License](https://camo.githubusercontent.com/e152caac05d6eafe296ff029c305b4012a0d1da03f03d2a1f3a6f645c5b10ec6/68747470733a2f2f706f7365722e707567782e6f72672f6d65726f2f796969322d6d6f6e6f6c6f672f6c6963656e73652e737667)](https://packagist.org/packages/mero/yii2-monolog)

The [Monolog](https://github.com/Seldaek/monolog) integration for the Yii framework.

Requirements
------------

[](#requirements)

- PHP 5.4 or above
- Yii 2.0.0 or above

Instalation with composer
-------------------------

[](#instalation-with-composer)

1. Open your project directory;
2. Run `composer require sbooker/yii2-monolog` to add Monolog in your project vendor.

Configuration
-------------

[](#configuration)

To configure Monolog component in Yii2, use the structure exemplified below. The channel "main" is required in component and used when no channel is setted to use a logger.

```
return [
    //....
    'components' => [
        'monolog' => [
            'class' => '\Mero\Monolog\MonologComponent',
            'handlers' => [
                'main' => [
                    'type' => 'stream',
                    'path' => '@app/runtime/logs/main.log',
                    'level' => 'debug',
                    'channels' => [ 'main', ]
                ],
            ],
            'processor' = [
                'logProcessor', // id in ServiceLocator or Container
            ]
        ],
    ],
    //....
];
```

You can configure multiple channels and different handlers and processors for each channel.

Handlers
--------

[](#handlers)

You can add handlers in their channels using the array structure or object structure.

### Array structure

[](#array-structure)

Using the array structure, you have a better readability of the configuration of their handlers.

**Example**

```
return [
    //...
    'handler' => [
        [
            'type' => 'stream',
            'path' => '@app/runtime/logs/log_' . date('Y-m-d') . '.log',
            'level' => 'debug'
        ]
    ],
    //...
];
```

**Warning:** this option does not have any existing handlers in monolog. See the [handlers page](docs/handlers.md)more details.

### Object structure

[](#object-structure)

Using the object structure, you will be informing instantiated objects already declared their respective handlers.

**Example**

```
return [
    //...
    'handler' => [
        new \Monolog\Handler\StreamHandler(
            __DIR__.'/../runtime/logs/system.log',
            \Monolog\Logger::DEBUG
        )
    ],
    //...
];
```

Using Yii2 Monolog
------------------

[](#using-yii2-monolog)

To use Yii 2 Monolog simply call the method `getLogger` component informing which channel is used.

**Example**

```
namespace app\controllers;

use Yii;
use \yii\web\Controller;

class ExampleController extends Controller
{

    /**
     * This action register "Hello world" in channel
     * "main"(default when no value is setted on "getLogger" method).
     */
    public function actionFirstExample()
    {
        $monologComponent = Yii::$app->monolog;
        $logger = $monologComponent->getLogger();
        $logger->log('info', 'Hello world');
    }

    /**
     * This action register "Hello world" in channel "channel1".
     */
    public function actionSecondExample()
    {
        $monologComponent = Yii::$app->monolog;
        $logger = $monologComponent->getLogger("channel1");
        $logger->log('info', 'Hello world');
    }

}
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.3% 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 ~27 days

Recently: every ~12 days

Total

10

Last Release

3263d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f97b1f6ea03776dda6e0ec26d1ff3a3309972d65bd1376eb111c2b35017af339?d=identicon)[sbooker](/maintainers/sbooker)

---

Top Contributors

[![merorafael](https://avatars.githubusercontent.com/u/3404989?v=4)](https://github.com/merorafael "merorafael (56 commits)")[![Cayan](https://avatars.githubusercontent.com/u/1619617?v=4)](https://github.com/Cayan "Cayan (2 commits)")[![pingu1](https://avatars.githubusercontent.com/u/6096291?v=4)](https://github.com/pingu1 "pingu1 (2 commits)")

---

Tags

logloggingyii2monolog

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[mero/yii2-monolog

The Monolog integration for the Yii framework.

42186.1k](/packages/mero-yii2-monolog)[rahimi/monolog-telegram

A handler for Monolog that sends messages to Telegram Channels

6980.2k1](/packages/rahimi-monolog-telegram)[mero/telegram-handler

Monolog handler to send log by Telegram

36113.3k](/packages/mero-telegram-handler)[jacklul/monolog-telegram

Monolog handler that sends logs through Telegram bot to any chat in HTML format

2364.7k1](/packages/jacklul-monolog-telegram)[filips123/monolog-phpmailer

PHPMailer handler for Monolog

1365.6k3](/packages/filips123-monolog-phpmailer)

PHPackages © 2026

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