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

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

snakano/cakephp-monolog
=======================

CakePHP Monolog Plugin

2.1.0(6y ago)034.2k↓12%MITPHPPHP &gt;=5.3.0

Since Feb 12Pushed 6y agoCompare

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

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

CakePHP Monolog Plugin (Addtion Datadog processor)
==================================================

[](#cakephp-monolog-plugin-addtion-datadog-processor)

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.

`DatadogProcessor` append Datadog APM Trace ID and Span ID. This processor append the identifiers to all the log messages automatically. See: [https://docs.datadoghq.com/tracing/advanced/connect\_logs\_and\_traces/?tab=php](https://docs.datadoghq.com/tracing/advanced/connect_logs_and_traces/?tab=php)

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`

```
{
	"repositories": [
		{
			"type": "vcs",
			"url": "https://github.com/SNakano/cakephp-monolog"
		}
	],
	"require": {
		"snakano/monolog": "dev-master"
	}
}

```

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:

```
require VENDORS . 'autoload.php';
App::build([
	'Plugin' => [ROOT . DS . 'Plugin' . DS]
]);

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 . 'application.log',
			30
		),
		'Stream' => array(
			LOGS . 'logstash.log',
			'formatters' => array(
				'Line' => array("%datetime% %channel% %level_name%: %message%\n")
			),
			'processors' => array(
				'DatadogProcessor' => array(
					'search' => CakePlugin::path('Monolog') . 'Lib' . DS . 'Log' . DS . 'Processor'
				),
				'MemoryUsage' => array(),
				'Web' => array()
			)
		),
		'CakeEmail' => array(
			'admin@domain.com',
			'ALERT: APPLICATION REQUIRES IMMEDIATE ATTENTION.',
			'default'
		)
	)
));

```

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 70.8% 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 ~200 days

Recently: every ~568 days

Total

14

Last Release

2240d ago

Major Versions

1.4.2 → 2.0.02014-08-04

### Community

Maintainers

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

---

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)")[![SNakano](https://avatars.githubusercontent.com/u/1312539?v=4)](https://github.com/SNakano "SNakano (4 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

cakephp-plugincakephp2datadogdatadog-apmdatadog-logsmonolog-processorplugincakephpmonolog

### Embed Badge

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

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

###  Alternatives

[jadb/cakephp-monolog

CakePHP Monolog Plugin

5518.9k](/packages/jadb-cakephp-monolog)[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)
