PHPackages                             dereuromark/cakephp-databaselog - 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. [Database &amp; ORM](/categories/database)
4. /
5. dereuromark/cakephp-databaselog

ActiveCakephp-plugin[Database &amp; ORM](/categories/database)

dereuromark/cakephp-databaselog
===============================

A CakePHP plugin for storing and viewing application logs in the database

4.4.0(2mo ago)44165.0k↑58.1%212MITPHPPHP &gt;=8.2CI passing

Since Dec 2Pushed 2mo ago5 watchersCompare

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

READMEChangelog (10)Dependencies (13)Versions (44)Used By (2)

CakePHP DatabaseLog Plugin
==========================

[](#cakephp-databaselog-plugin)

[![CI](https://github.com/dereuromark/CakePHP-DatabaseLog/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/dereuromark/CakePHP-DatabaseLog/actions/workflows/ci.yml?query=branch%3Amaster)[![Coverage Status](https://camo.githubusercontent.com/407c2d4b0bd96b1ad1d3ce7abd9d813fe1be4c4aa26e67ac77760087ce1250b1/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6465726575726f6d61726b2f43616b655048502d44617461626173654c6f672f6d61737465722e737667)](https://codecov.io/github/dereuromark/CakePHP-DatabaseLog/branch/master)[![PHPStan](https://camo.githubusercontent.com/f60d96f7c2579690ab6dfa8918f777fe93a02a92301c661eb38a85861a92b780/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230382d627269676874677265656e2e7376673f7374796c653d666c6174)](https://phpstan.org/)[![Latest Stable Version](https://camo.githubusercontent.com/518910335545488978ac61d163fa772bfafa65dc0bbeb74c76cf744593da4b4f/68747470733a2f2f706f7365722e707567782e6f72672f6465726575726f6d61726b2f43616b655048502d44617461626173654c6f672f762f737461626c652e737667)](https://packagist.org/packages/dereuromark/CakePHP-DatabaseLog)[![Minimum PHP Version](https://camo.githubusercontent.com/ec21f169d70b69344c67d6f18fa1a24d20476d2f0cd680e8c4a1534c22f34e5f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230382e322d3838393242462e737667)](https://php.net/)[![License](https://camo.githubusercontent.com/561d0bc9af020ff8149fda9c0df10ee98689afbbb0673f87c7fcecfb8a4cd83a/68747470733a2f2f706f7365722e707567782e6f72672f6465726575726f6d61726b2f43616b655048502d44617461626173654c6f672f6c6963656e73652e737667)](LICENSE)[![Total Downloads](https://camo.githubusercontent.com/e76d02b8281cca5f2ec726bd921de2465cdaae46b7f8d744a4b54e6b40f11743/68747470733a2f2f706f7365722e707567782e6f72672f6465726575726f6d61726b2f43616b655048502d44617461626173654c6f672f642f746f74616c2e737667)](https://packagist.org/packages/dereuromark/CakePHP-DatabaseLog)

DatabaseLog engine for CakePHP applications.

This branch is for **CakePHP 5.2+**. See [version map](https://github.com/dereuromark/CakePHP-DatabaseLog/wiki#cakephp-version-map) for details.

Features
--------

[](#features)

- Easy setup and almost no dependencies.
- Detailed log infos added for both Web and CLI log entries.
- Defaults to SQLite as single app application lightweight approach.
- Ideal for multi-server or serverless applications where logging to a file is just not convenient.
- If DB is used, fallback to SQLite in case the DB is not reachable.
- Simple admin interface to view/delete logs included.
- Basic monitoring and alert system included.
- Export to TXT files possible.

### Log Rotation

[](#log-rotation)

While file handling requires file log rotation and splitting into chunks of (compressed) files, a database approach can more easily keep the logs together in a single database. This is more convinient when looking through them or searching for something specific.

This plugin internally combines log entries of the exact same "content" into a single row with an increased count. Additionally, you would want to add a cronjob triggered cleanup shell to keep the total size and row count below a certain threshold.

Demo
----

[](#demo)

Clone and install the [sandbox app](https://github.com/dereuromark/cakephp-sandbox), create some errors and browse the admin backend for the logs overview.

Or just attach it to your app directly. Time needed: 5 minutes.

Install
-------

[](#install)

### Composer (preferred)

[](#composer-preferred)

```
composer require dereuromark/cakephp-databaselog

```

Setup
-----

[](#setup)

Load the plugin:

```
bin/cake plugin load DatabaseLog

```

You can simply modify the existing config entries in your `config/app.php`:

```
   'Log' => [
   	'debug' => [
   		'className' => 'DatabaseLog.Database',
   	],
   	'error' => [
   		'className' => 'DatabaseLog.Database',
   	],
   	...
   ],
```

This will use the `database_log` connection and an SQLite file database by default, stored in your `logs` folder.

### Using an actual database (optional)

[](#using-an-actual-database-optional)

Create a config setting in your `config/app.php` what database connection it should log to:

```
'DatabaseLog' => [
	'connection' => 'custom',
],
```

It is recommended to not use the same connection as your production server (`default`) because when the DB is not reachable logging to it will also not be possible. In that case it will fall back to SQLite file logging on this server instance, though.

Once the connection is reachable, the database table (defaulting to `database_logs`) will be automatically created. No need to manually run any migration or SQL script here.

You can also manually create the table beforehand, if you prefer:

```
bin/cake Migrations migrate -p DatabaseLog

```

If you use a custom connection, make sure to set the connection here for migrations:

```
bin/cake Migrations migrate -p DatabaseLog -c custom

```

Fully tested so far are PostgreSQL and MySQL, but by using the ORM all major databases should be supported.

For default connection usage only: You can also just copy the migration file(s) into your app `/config/Migrations/`, modify if needed, and then run it as part of your app migrations.

Usage
-----

[](#usage)

Anywhere in your app where you call `$this->log()` or `Log::write()` the DatabaseLog engine will be used.

```
$this->log('This is a detailed message logged to the database', 'error');
// or
Log::write('error', 'This is a detailed message logged to the database');
```

There is also a browsable web backend you can view your logs with.

See [Docs](/docs) for more details.

###  Health Score

66

—

FairBetter than 99% of packages

Maintenance88

Actively maintained with recent releases

Popularity46

Moderate usage in the ecosystem

Community26

Small or concentrated contributor base

Maturity88

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 81.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 ~111 days

Recently: every ~29 days

Total

38

Last Release

61d ago

Major Versions

1.0 → 2.0.02016-09-28

2.7.1 → 3.0.0-beta2020-01-17

2.7.2 → 3.0.02020-06-28

3.2.2 → 4.0.0-RC2023-10-08

PHP version history (8 changes)1.0PHP &gt;=5.2.8

2.0.0PHP &gt;=5.5

2.4.0PHP &gt;=5.6

3.0.0-betaPHP &gt;=7.2

3.2.0PHP &gt;=7.3

3.2.1PHP &gt;=7.4

4.0.0-RCPHP &gt;=8.1

4.3.1PHP &gt;=8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/39854?v=4)[Mark Scherer](/maintainers/dereuromark)[@dereuromark](https://github.com/dereuromark)

---

Top Contributors

[![dereuromark](https://avatars.githubusercontent.com/u/39854?v=4)](https://github.com/dereuromark "dereuromark (284 commits)")[![ravage84](https://avatars.githubusercontent.com/u/625761?v=4)](https://github.com/ravage84 "ravage84 (28 commits)")[![webtechnick](https://avatars.githubusercontent.com/u/26438?v=4)](https://github.com/webtechnick "webtechnick (24 commits)")[![georgeconstantinou](https://avatars.githubusercontent.com/u/1926811?v=4)](https://github.com/georgeconstantinou "georgeconstantinou (3 commits)")[![anvyst](https://avatars.githubusercontent.com/u/227261?v=4)](https://github.com/anvyst "anvyst (2 commits)")[![mamchenkov](https://avatars.githubusercontent.com/u/437928?v=4)](https://github.com/mamchenkov "mamchenkov (2 commits)")[![slamkajs](https://avatars.githubusercontent.com/u/541593?v=4)](https://github.com/slamkajs "slamkajs (2 commits)")[![ishanvyas22](https://avatars.githubusercontent.com/u/17404636?v=4)](https://github.com/ishanvyas22 "ishanvyas22 (1 commits)")[![liviakuenzli](https://avatars.githubusercontent.com/u/7348876?v=4)](https://github.com/liviakuenzli "liviakuenzli (1 commits)")

---

Tags

pluginloggingmonitoringdatabasedebuggingcakephplogsadmin-panel

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dereuromark-cakephp-databaselog/health.svg)

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

###  Alternatives

[analog/analog

Fast, flexible, easy PSR-3-compatible PHP logging package with dozens of handlers.

3451.5M24](/packages/analog-analog)[pgbi/cakephp3-soft-delete

SoftDelete plugin for CakePHP

87291.9k](/packages/pgbi-cakephp3-soft-delete)[lordsimal/cakephp-sentry

Sentry plugin for CakePHP

12270.3k](/packages/lordsimal-cakephp-sentry)[dereuromark/cakephp-setup

A CakePHP plugin containing lots of useful management tools

36162.8k2](/packages/dereuromark-cakephp-setup)[dereuromark/cakephp-translate

A CakePHP plugin for managing translations

1710.4k](/packages/dereuromark-cakephp-translate)

PHPackages © 2026

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