PHPackages                             daoandco/cakephp-logging - 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. daoandco/cakephp-logging

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

daoandco/cakephp-logging
========================

Cakephp plugin for Log user's action in database

v1.1.1(10y ago)4773PHPPHP &gt;=5.4.16

Since Apr 27Pushed 8y ago2 watchersCompare

[ Source](https://github.com/DaoAndCo/cakephp-logging)[ Packagist](https://packagist.org/packages/daoandco/cakephp-logging)[ RSS](/packages/daoandco-cakephp-logging/feed)WikiDiscussions master Synced today

READMEChangelog (4)Dependencies (2)Versions (6)Used By (0)

Logging plugin for CakePHP 3.x
==============================

[](#logging-plugin-for-cakephp-3x)

Log user's action in your Database. This plugin is composed of a Component and a Log engine. This plugin is compatible with core logs of CakePHP.

------------------------------------
====================================

[](#------------------------------------)

This project is no longer maintained
====================================

[](#this-project-is-no-longer-maintained)

------------------------------------
====================================

[](#-------------------------------------1)

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

[](#requirements)

- PHP version 5.4.16 or higher
- CakePhp 3.0 or higher

Installation
------------

[](#installation)

You can install this plugin into your CakePHP application using [composer](http://getcomposer.org).

The recommended way to install composer packages is:

```
composer require daoandco/cakephp-logging

```

Loading the Plugin like that

```
// In config/bootstrap.php
Plugin::load('Logging', ['bootstrap' => true, 'routes' => false]);
```

Create table log : execute shema in `config/shema/logs.sql` (you can change the table name)

```
CREATE TABLE `logs` (
    `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
    `created` DATETIME NOT NULL,
    `level` VARCHAR(50) NOT NULL,
    `scope` VARCHAR(50) NULL DEFAULT NULL,
    `user_id` INT(10) UNSIGNED NULL DEFAULT NULL,
    `message` TEXT NULL,
    `context` TEXT NULL,
    PRIMARY KEY (`id`),
    INDEX `user_id` (`user_id`),
    INDEX `scope` (`scope`),
    INDEX `level` (`level`)
)
COLLATE='utf8_general_ci'
;
```

Quick Start
-----------

[](#quick-start)

If you want just replace default config you can change Log's config in your `app` file

```
// In config/app.php
'Log' => [
	'debug' => [
		'className' => 'Logging.Database',
        'levels' => ['notice', 'info', 'debug'],
    ],
    'error' => [
        'className' => 'Logging.Database',
        'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'],
    ],
],
```

For writing to logs see

```
use Cake\Log\Log;

Log::write('debug', 'Something did not work');
```

Or you can use LogComponent in your controllers. The component store by default `request` and `session` in context field.

```
$this->loadComponent('Logging.Log');

$this->Log->write('debug', 'myScope', 'Message');
```

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

[](#configuration)

### Options

[](#options)

- **className :** `'Logging.Database'`
- **model :** Model name (default: `'Logging.Logs'`)
- **table :** table name (default: `'logs'`)
- **levels :** logging levels (default: `'[]'` = all levels) [More infos](http://book.cakephp.org/3.0/en/core-libraries/logging.html#using-levels)
- **scopes:** logging scopes (default: `'[]'` = all scopes) [More infos](http://book.cakephp.org/3.0/en/core-libraries/logging.html#logging-scopes)
- **requiredScope :** if true no store logs if scope is empty (default `false`)
- **userId :** path where is stored user id in Session (default `Auth.User.id`)

### Use cases

[](#use-cases)

Edit `config/app.php`

#### Write everything with the plugin

[](#write-everything-with-the-plugin)

```
// In config/app.php
'Log' => [
	'debug' => [
		'className' => 'Logging.Database',
        'levels' => ['notice', 'info', 'debug'],
    ],
    'error' => [
        'className' => 'Logging.Database',
        'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'],
    ],
],
```

#### Write cake log in file and write application log with the plugin

[](#write-cake-log-in-file-and-write-application-log-with-the-plugin)

With this configuration the scope is required when you write in a log

```
'Log' => [
    'debug' => [
        'className' => 'Cake\Log\Engine\FileLog',
        'path' => LOGS,
        'file' => 'debug',
        'levels' => ['notice', 'info', 'debug'],
        'scopes' => false,
        'url' => env('LOG_DEBUG_URL', null),
    ],
    'error' => [
        'className' => 'Cake\Log\Engine\FileLog',
        'path' => LOGS,
        'file' => 'error',
        'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'],
        'scopes' => false,
        'url' => env('LOG_ERROR_URL', null),
    ],
    'app' => [
        'className'     => 'Logging.Database',
        'requiredScope' => true,
    ],
],
```

Writing to Logs :

```
// With Cake\Log\Log;
Log::write('debug', 'Something did not work', ['scope'=>['myScope']]);

// Or with component
$this->Log->write('debug', 'myScope', 'Something did not work');
```

Component
---------

[](#component)

```
// Load component
$this->loadComponent('Logging.Log');
```

### Configuration

[](#configuration-1)

- **request:** if true store `$this->request` in Context (default: `'false'`)
- **session:** if true store `$_SESSION` Context (default: `'false'`)
- **ip:** if true store `$this->request->clientIp()` Context (default: `'false'`)
- **referer:** if true store `$this->request->referer()` Context (default: `'false'`)
- **vars:** store more datas (ex : `['plugin' => $this->plugin]`

### Methods

[](#methods)

- `write($level, $scope, $message, $context, $config)`Log a message
- `emergency($scope, $message, $context, $config)`Log a emergency message
- `alert($scope, $message, $context, $config)`Log a alert message
- `critical($scope, $message, $context, $config)`Log a critical message
- `error($scope, $message, $context, $config)`Log a error message
- `warning($scope, $message, $context, $config)`Log a warning message
- `notice($scope, $message, $context, $config)`Log a notice message
- `debug($scope, $message, $context, $config)`Log a debug message
- `info($scope, $message, $context, $config)`Log a info message

### Parameters

[](#parameters)

- **levels :** (string) logging levels (`'emergency'|'alert'|'critical'|'error'|'warning'|'notice'|'debug'|'info'`) [More infos](http://book.cakephp.org/3.0/en/core-libraries/logging.html#using-levels)
- **scope :** (string|array) logging scopes [More infos](http://book.cakephp.org/3.0/en/core-libraries/logging.html#logging-scopes)
- **message:** (string) log message
- **context:** (array) Additional data to be used for logging the message
- **config:** change base config (ex request, session...)

### Use

[](#use)

```
// Basic usage
$this->Log->write('debug', 'myScope', 'Something did not work');

// With convenience methods
$this->Log->emergency('myScope', 'My message');
$this->Log->alert('myScope', 'My message');
$this->Log->critical('myScope', 'My message');
$this->Log->error('myScope', 'My message');
$this->Log->warning('myScope', 'My message');
$this->Log->notice('myScope', 'My message');
$this->Log->debug('myScope', 'My message');
$this->Log->info('myScope', 'My message');

// Add datas
$this->Log->info('myScope', 'My message', ['key1' => 'value1', 'key2' => 'value2']);

// Save request
$this->Log->info('myScope', 'My message', [], ['request' => true]);

// Save session
$this->Log->info('myScope', 'My message', [], ['session' => true]);

// Save ip
$this->Log->info('myScope', 'My message', [], ['ip' => true]);

// Save referer url
$this->Log->info('myScope', 'My message', [], ['referer' => true]);

// Don't save userId
$this->Log->info('myScope', 'My message', ['userId' => null];

// Force userId if different to $_SESSION
$this->Log->info('myScope', 'My message', ['userId' => 2];

// No scope
$this->Log->info(null, 'My message');

// Multi scope = multi lines in bdd
$this->Log->info(['scope1', 'scope2'], 'My message');
```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity62

Established project with proven stability

 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

4

Last Release

3715d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5025797?v=4)[Flavien Beninca](/maintainers/ozee31)[@ozee31](https://github.com/ozee31)

---

Top Contributors

[![ozee31](https://avatars.githubusercontent.com/u/5025797?v=4)](https://github.com/ozee31 "ozee31 (14 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/daoandco-cakephp-logging/health.svg)

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

###  Alternatives

[cakephp/bake

Bake plugin for CakePHP

11211.7M190](/packages/cakephp-bake)[dereuromark/cakephp-tools

A CakePHP plugin containing lots of useful and reusable tools

333972.2k49](/packages/dereuromark-cakephp-tools)[dereuromark/cakephp-queue

The Queue plugin for CakePHP provides deferred task execution.

308914.0k25](/packages/dereuromark-cakephp-queue)[dereuromark/cakephp-ide-helper

CakePHP IdeHelper Plugin to improve auto-completion

1882.3M40](/packages/dereuromark-cakephp-ide-helper)[dereuromark/cakephp-tinyauth

A CakePHP plugin to handle user authentication and authorization the easy way.

131237.3k13](/packages/dereuromark-cakephp-tinyauth)[dereuromark/cakephp-setup

A CakePHP plugin containing lots of useful management tools

35184.7k2](/packages/dereuromark-cakephp-setup)

PHPackages © 2026

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