2017 © Pedro Peláez
 

cakephp-plugin cakephp-databaselog

CakePHP DatabaseLog Plugin

image

dereuromark/cakephp-databaselog

CakePHP DatabaseLog Plugin

  • Saturday, April 28, 2018
  • by dereuromark
  • Repository
  • 3 Watchers
  • 26 Stars
  • 25,971 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 19 Forks
  • 3 Open issues
  • 14 Versions
  • 15 % Grown

The README.md

CakePHP DatabaseLog Plugin

CI Coverage Status Latest Stable Version Minimum PHP Version License Total Downloads, (*1)

DatabaseLog engine for CakePHP applications., (*2)

This branch is for CakePHP 5.0+. See version map for details., (*3)

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

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., (*4)

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., (*5)

Demo

Clone and install the sandbox app, create some errors and browse the admin backend for the logs overview., (*6)

Or just attach it to your app directly. Time needed: 5 minutes., (*7)

Install

Composer (preferred)

composer require dereuromark/cakephp-databaselog

Setup

Enable the plugin in your Application class: php $this->addPlugin('DatabaseLog'); or just call:, (*8)

bin/cake plugin load DatabaseLog

You can simply modify the existing config entries in your config/app.php: ```php 'Log' => [ 'debug' => [ 'className' => 'DatabaseLog.Database', ], 'error' => [ 'className' => 'DatabaseLog.Database', ], ... ],, (*9)

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

### Using an actual database (optional)
Create a config setting in your `config/app.php` what database connection it should log to:
```php
'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., (*10)

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., (*11)

You can also manually create the table beforehand, if you prefer:, (*12)

bin/cake Migrations migrate -p DatabaseLog

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

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., (*14)

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., (*15)

Usage

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

$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., (*17)

See Docs for more details., (*18)

The Versions

28/04 2018

dev-dereuromark-patch-1

dev-dereuromark-patch-1 https://github.com/dereuromark/CakePHP-DatabaseLog/

CakePHP DatabaseLog Plugin

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin database cakephp logging logs

28/04 2018

dev-master

9999999-dev https://github.com/dereuromark/CakePHP-DatabaseLog/

CakePHP DatabaseLog Plugin

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin database cakephp logging logs

19/04 2018

2.4.0

2.4.0.0 https://github.com/dereuromark/CakePHP-DatabaseLog/

CakePHP DatabaseLog Plugin

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin database cakephp logging logs

11/02 2018

2.3.4

2.3.4.0 https://github.com/dereuromark/CakePHP-DatabaseLog/

CakePHP DatabaseLog Plugin

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin database cakephp logging logs

03/01 2018

2.3.3

2.3.3.0 https://github.com/dereuromark/CakePHP-DatabaseLog/

CakePHP DatabaseLog Plugin

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin database cakephp logging logs

23/12 2017

2.3.2

2.3.2.0 https://github.com/dereuromark/CakePHP-DatabaseLog/

CakePHP DatabaseLog Plugin

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin database cakephp logging logs

04/09 2017

dev-bugfix/tests

dev-bugfix/tests https://github.com/dereuromark/CakePHP-DatabaseLog/

CakePHP DatabaseLog Plugin

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin database cakephp logging logs

23/08 2017

2.3.1

2.3.1.0 https://github.com/dereuromark/CakePHP-DatabaseLog/

CakePHP DatabaseLog Plugin

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin database cakephp logging logs

15/04 2017

2.3.0

2.3.0.0 https://github.com/dereuromark/CakePHP-DatabaseLog/

CakePHP DatabaseLog Plugin

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin database cakephp logging logs

08/01 2017

2.2.0

2.2.0.0 https://github.com/dereuromark/CakePHP-DatabaseLog/

CakePHP DatabaseLog Plugin

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin database cakephp logging logs

10/10 2016

2.1.0

2.1.0.0 https://github.com/dereuromark/CakePHP-DatabaseLog/

CakePHP DatabaseLog Plugin

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin database cakephp logging logs

29/09 2016

2.0.0

2.0.0.0 https://github.com/dereuromark/CakePHP-DatabaseLog/

CakePHP DatabaseLog Plugin

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin database cakephp logging logs

02/12 2014

2.x-dev

2.9999999.9999999.9999999-dev https://github.com/dereuromark/CakePHP-DatabaseLog/

CakePHP DatabaseLog Plugin

  Sources   Download

MIT

The Requires

  • php >=5.2.8

 

plugin database cakephp logging logs

02/12 2014

1.0

1.0.0.0 https://github.com/dereuromark/CakePHP-DatabaseLog/

CakePHP DatabaseLog Plugin

  Sources   Download

MIT

The Requires

  • php >=5.2.8

 

plugin database cakephp logging logs