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

ActiveCakephp-plugin[Logging &amp; Monitoring](/categories/logging)

pieceofcake2/monolog
====================

CakePHP 2 Monolog Plugin

v2.0.1(7mo ago)00MITPHPPHP ^8.0CI passing

Since Oct 7Pushed 7mo agoCompare

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

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

CakePHP Monolog Plugin
======================

[](#cakephp-monolog-plugin)

[![GitHub License](https://camo.githubusercontent.com/b5a7b4ec380de3889313f0d4091d5197453392ac63a3755eadacb4e4d5e7a51a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f70696563656f6663616b65322f6d6f6e6f6c6f673f6c6162656c3d4c6963656e7365)](LICENSE)[![Packagist Version](https://camo.githubusercontent.com/376724da0a27ee450111fe2180d198ccae047d8c131b2c82d0748ebb108aa847/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70696563656f6663616b65322f6d6f6e6f6c6f673f6c6162656c3d5061636b6167697374)](https://packagist.org/packages/pieceofcake2/monolog)[![PHP](https://camo.githubusercontent.com/e9bbfc8b127651f7cd6ce9c62e84099d129f17746da7d2cc566a1d612faba2aa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f70696563656f6663616b65322f6d6f6e6f6c6f672f7068703f6c6f676f3d706870266c6f676f436f6c6f723d253233464646464646266c6162656c3d504850266c6162656c436f6c6f723d25323337373742423426636f6c6f723d253233464646464646)](https://camo.githubusercontent.com/e9bbfc8b127651f7cd6ce9c62e84099d129f17746da7d2cc566a1d612faba2aa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f70696563656f6663616b65322f6d6f6e6f6c6f672f7068703f6c6f676f3d706870266c6f676f436f6c6f723d253233464646464646266c6162656c3d504850266c6162656c436f6c6f723d25323337373742423426636f6c6f723d253233464646464646)[![CakePHP](https://camo.githubusercontent.com/82eab10b82b5a799ef873a94fafd4b25947e67980c7e8646232c903db2c54285/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f70696563656f6663616b65322f6d6f6e6f6c6f672f70696563656f6663616b65322f63616b657068703f6c6f676f3d63616b65706870266c6f676f436f6c6f723d253233464646464646266c6162656c3d43616b65504850266c6162656c436f6c6f723d25323344333343343326636f6c6f723d253233464646464646)](https://camo.githubusercontent.com/82eab10b82b5a799ef873a94fafd4b25947e67980c7e8646232c903db2c54285/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f70696563656f6663616b65322f6d6f6e6f6c6f672f70696563656f6663616b65322f63616b657068703f6c6f676f3d63616b65706870266c6f676f436f6c6f723d253233464646464646266c6162656c3d43616b65504850266c6162656c436f6c6f723d25323344333343343326636f6c6f723d253233464646464646)[![CI](https://camo.githubusercontent.com/bd6b24fefca8d0c50b7ef510951d8bdf517185180105e170744edb73753387a5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f70696563656f6663616b65322f6d6f6e6f6c6f672f43492e796d6c3f6c6162656c3d4349)](https://github.com/pieceofcake2/monolog/actions/workflows/CI.yml)[![Codecov](https://camo.githubusercontent.com/0ed9b9960843cdb862d23a78a1b01fd12c77780ee115ce5a8413f419639588c9/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f67682f70696563656f6663616b65322f6d6f6e6f6c6f673f6c6162656c3d436f766572616765)](https://codecov.io/gh/pieceofcake2/monolog)

**This is forked for CakePHP2.**

Despite the very advanced logging system offered in [CakePHP](http://cakephp.org), I still would have had to write a lot more code to be able to handle logs the way I needed. To write the least code possible, I chose to go with the popular monolog library.

Note

The package name changed to jadb/cakephp-monolog, to not violate the cakephp namespace.

Install
-------

[](#install)

Because [monolog](https://github.com/Seldaek/monolog) is a [composer](http://getcomposer.org) [package](https://packagist.org/packages/monolog/monolog) and to avoid having to manually write a lot of includes (vs. auto-loading), I decided to release this also as a composer package and take advantage of the auto-loading magic.

```
composer require pieceofcake2/monolog
```

That's it! You should now be ready to start configuring your channels.

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

[](#configuration)

Start by creating a logging configuration file (i.e. `app/Config/log.php`) that you will include early in your `app/Config/bootstrap.php`:

```
require_once CONFIG . 'log.php';
```

A basic configuration, to replicate what Cake does but using Monolog (to give you a good starting example), would look something like this:

```
CakePlugin::load('Monolog');

CakeLog::config('debug', [
    'engine' => 'Monolog.Monolog',
    'channel' => 'app',
    'handlers' => [
        'Stream' => [
            LOGS . 'debug.log',
            'formatters' => [
                'Line' => ["%datetime% %channel% %level_name%: %message%\n"],
            ],
        ],
    ],
]);
```

Note that with CakePHP versions &lt; 2.4 the engine name should instead be `Monolog.MonologLog`.

Simple, no? But let's really do some serious logging, otherwise why bother moving away from the default [CakePHP logging](http://book.cakephp.org/2.0/en/core-libraries/logging.html) system?

The example below shows how to setup:

- rotating logs that are kept from 30 days and readable by [logstash](http://logstash.net) with memory peak usage info
- normal log file with much more details about the request
- email notifications for critical and alert levels including only the error message

```
CakeLog::config('logstash', [
    'engine' => 'Monolog.Monolog',
    'channel' => 'app',
    'handlers' => [
        'RotatingFile' => [
            LOGS . 'logstash.log',
            30,
            'formatters' => [
                'Logstash' => ['web', env('SERVER_ADDR')]
            ],
            'processors' => ['MemoryPeakUsage'],
        ],
        'Stream' => [
            LOGS . 'logstash.log',
            'formatters' => [
                'Line' => ["%datetime% %channel% %level_name%: %message% %context% %extra%\n"]
            ],
            'processors' => ['MemoryUsage', 'Web'],
        ],
        'CakeEmail' => [
            'admin@domain.com',
            'ALERT: APPLICATION REQUIRES IMMEDIATE ATTENTION.',
            'default',
        ],
    ],
]);
```

The [`CakeEmailHandler`](https://github.com/jadb/monolog/blob/master/src/Monolog/Handler/CakeEmailHandler.php) was [just submitted](https://github.com/Seldaek/monolog/pull/162) to the main [monolog](https://github.com/Seldaek/monolog) repo today. If it is not merged by the time you are reading this, just use [my fork](https://github.com/jadb/monolog).

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance63

Regular maintenance activity

Popularity0

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

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

2

Last Release

223d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/578548?v=4)[TSURU](/maintainers/ttsuru)[@ttsuru](https://github.com/ttsuru)

---

Top Contributors

[![jadb](https://avatars.githubusercontent.com/u/33527?v=4)](https://github.com/jadb "jadb (34 commits)")[![graemetait](https://avatars.githubusercontent.com/u/64014?v=4)](https://github.com/graemetait "graemetait (7 commits)")[![tsjost](https://avatars.githubusercontent.com/u/1737876?v=4)](https://github.com/tsjost "tsjost (2 commits)")[![ttsuru](https://avatars.githubusercontent.com/u/578548?v=4)](https://github.com/ttsuru "ttsuru (1 commits)")[![vincent-richard](https://avatars.githubusercontent.com/u/428212?v=4)](https://github.com/vincent-richard "vincent-richard (1 commits)")

---

Tags

cakephpmonologcakephp2

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[maxbanton/cwh

AWS CloudWatch Handler for Monolog library

42515.3M27](/packages/maxbanton-cwh)[jadb/cakephp-monolog

CakePHP Monolog Plugin

5518.9k](/packages/jadb-cakephp-monolog)[inpsyde/wonolog

Monolog-based logging package for WordPress.

183617.9k7](/packages/inpsyde-wonolog)[phpnexus/cwh

AWS CloudWatch Handler for Monolog library

393.2M7](/packages/phpnexus-cwh)[logtail/monolog-logtail

Logtail handler for Monolog

233.2M3](/packages/logtail-monolog-logtail)[kdyby/monolog

Integration of Monolog into Nette Framework

33684.0k10](/packages/kdyby-monolog)

PHPackages © 2026

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