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

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

jadb/cakephp-monolog
====================

CakePHP Monolog Plugin

2.0.0(11y ago)5518.9k↓20%15[2 issues](https://github.com/jadb/cakephp-monolog/issues)MITPHPPHP &gt;=5.3.0

Since Feb 12Pushed 9y ago3 watchersCompare

[ Source](https://github.com/jadb/cakephp-monolog)[ Packagist](https://packagist.org/packages/jadb/cakephp-monolog)[ Docs](https://github.com/jadb/cakephp-monolog)[ RSS](/packages/jadb-cakephp-monolog/feed)WikiDiscussions master Synced 1mo ago

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

[![Build Status](https://camo.githubusercontent.com/f8dd5c27f9d4709abc3a86fa732aaa9fdcfe07155a91155ad967bb7b890c0fca/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f6a6164622f63616b657068702d6d6f6e6f6c6f672e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/jadb/cakephp-monolog)

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

[](#cakephp-monolog-plugin)

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.

First, add this plugin as a requirement to your `composer.json`:

```
{
	"require": {
		"cakephp/monolog": "*"
	}
}

```

And then update:

```
php composer.phar update

```

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`:

```
include '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', array(
	'engine' => 'Monolog.Monolog',
	'channel' => 'app',
	'handlers' => array(
		'Stream' => array(
			LOGS . 'debug.log',
			'formatters' => array(
				'Line' => array("%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', array(
	'engine' => 'Monolog.Monolog',
	'channel' => 'app',
	'handlers' => array(
		'RotatingFile' => array(
			LOGS . 'logstash.log',
			30,
			'formatters' => array(
				'Logstash' => array('web', env('SERVER_ADDR'))
			),
			'processors' => array('MemoryPeakUsage')
		),
		'Stream' => array(
			LOGS . 'logstash.log',
			'formatters' => array(
				'Line' => array("%datetime% %channel% %level_name%: %message% %context% %extra%\n")
			),
			'processors' => array('MemoryUsage', 'Web')
		),
		'CakeEmail' => array(
			'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

39

—

LowBetter than 86% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity40

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 77.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 ~45 days

Recently: every ~52 days

Total

13

Last Release

4305d ago

Major Versions

1.4.2 → 2.0.02014-08-04

### Community

Maintainers

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

---

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)")[![vincent-richard](https://avatars.githubusercontent.com/u/428212?v=4)](https://github.com/vincent-richard "vincent-richard (1 commits)")

---

Tags

plugincakephpmonolog

### Embed Badge

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

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

###  Alternatives

[lordsimal/cakephp-sentry

Sentry plugin for CakePHP

12270.3k](/packages/lordsimal-cakephp-sentry)[vojtasvoboda/oc-errorlogger-plugin

Sends an error from your OctoberCMS application directly to email, HipChat, Slack, NewRelic and more.

153.3k](/packages/vojtasvoboda-oc-errorlogger-plugin)

PHPackages © 2026

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