{"id":13684063,"url":"https://github.com/dereuromark/CakePHP-DatabaseLog","last_synced_at":"2025-04-30T20:33:00.109Z","repository":{"id":8306846,"uuid":"9851701","full_name":"dereuromark/CakePHP-DatabaseLog","owner":"dereuromark","description":"DatabaseLog CakePHP plugin to log into DB instead of files. Better to filter and search.","archived":false,"fork":false,"pushed_at":"2024-10-23T16:02:51.000Z","size":398,"stargazers_count":43,"open_issues_count":0,"forks_count":21,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-23T21:41:16.945Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dereuromark.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-05-04T09:06:35.000Z","updated_at":"2024-10-23T16:02:54.000Z","dependencies_parsed_at":"2024-01-20T21:22:36.766Z","dependency_job_id":"d2287bab-0a3b-4abf-bf86-75bf2c04c456","html_url":"https://github.com/dereuromark/CakePHP-DatabaseLog","commit_stats":{"total_commits":308,"total_committers":13,"mean_commits":"23.692307692307693","dds":0.6558441558441559,"last_synced_commit":"1d9e1af808072e7aa3ff9aa1f573b1e87778ad3f"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dereuromark%2FCakePHP-DatabaseLog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dereuromark%2FCakePHP-DatabaseLog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dereuromark%2FCakePHP-DatabaseLog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dereuromark%2FCakePHP-DatabaseLog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dereuromark","download_url":"https://codeload.github.com/dereuromark/CakePHP-DatabaseLog/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224224771,"owners_count":17276428,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T14:00:24.404Z","updated_at":"2025-04-30T20:33:00.096Z","avatar_url":"https://github.com/dereuromark.png","language":"PHP","funding_links":[],"categories":["Auditing / Logging","Logging","Plugins"],"sub_categories":["Auditing / Logging"],"readme":"#  CakePHP DatabaseLog Plugin\n\n[![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)\n[![Coverage Status](https://img.shields.io/codecov/c/github/dereuromark/CakePHP-DatabaseLog/master.svg)](https://codecov.io/github/dereuromark/CakePHP-DatabaseLog/branch/master)\n[![Latest Stable Version](https://poser.pugx.org/dereuromark/CakePHP-DatabaseLog/v/stable.svg)](https://packagist.org/packages/dereuromark/CakePHP-DatabaseLog)\n[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%208.1-8892BF.svg)](https://php.net/)\n[![License](https://poser.pugx.org/dereuromark/CakePHP-DatabaseLog/license.svg)](LICENSE)\n[![Total Downloads](https://poser.pugx.org/dereuromark/CakePHP-DatabaseLog/d/total.svg)](https://packagist.org/packages/dereuromark/CakePHP-DatabaseLog)\n\nDatabaseLog engine for CakePHP applications.\n\nThis branch is for **CakePHP 5.0+**. See [version map](https://github.com/dereuromark/CakePHP-DatabaseLog/wiki#cakephp-version-map) for details.\n\n## Features\n\n- Easy setup and almost no dependencies.\n- Detailed log infos added for both Web and CLI log entries.\n- Defaults to SQLite as single app application lightweight approach.\n- Ideal for multi-server or serverless applications where logging to a file is just not convenient.\n- If DB is used, fallback to SQLite in case the DB is not reachable.\n- Simple admin interface to view/delete logs included.\n- Basic monitoring and alert system included.\n- Export to TXT files possible.\n\n### Log Rotation\nWhile 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.\n\nThis plugin internally combines log entries of the exact same \"content\" into a single row with an increased count.\nAdditionally, you would want to add a cronjob triggered cleanup shell to keep the total size and row count below a certain threshold.\n\n## Demo\nClone and install the [sandbox app](https://github.com/dereuromark/cakephp-sandbox), create some errors and browse the admin backend for the logs overview.\n\nOr just attach it to your app directly. Time needed: 5 minutes.\n\n## Install\n\n### Composer (preferred)\n```\ncomposer require dereuromark/cakephp-databaselog\n```\n\n## Setup\nLoad the plugin:\n```\nbin/cake plugin load DatabaseLog\n```\n\nYou can simply modify the existing config entries in your `config/app.php`:\n ```php\n\t'Log' =\u003e [\n\t\t'debug' =\u003e [\n\t\t\t'className' =\u003e 'DatabaseLog.Database',\n\t\t],\n\t\t'error' =\u003e [\n\t\t\t'className' =\u003e 'DatabaseLog.Database',\n\t\t],\n\t\t...\n\t],\n```\nThis will use the `database_log` connection and an SQLite file database by default, stored in your `logs` folder.\n\n### Using an actual database (optional)\nCreate a config setting in your `config/app.php` what database connection it should log to:\n```php\n'DatabaseLog' =\u003e [\n\t'connection' =\u003e 'custom',\n],\n```\nIt is recommended to not use the same connection as your production server (`default`) because when the DB is not reachable logging to it will\nalso not be possible. In that case it will fall back to SQLite file logging on this server instance, though.\n\nOnce the connection is reachable, the database table (defaulting to `database_logs`) will be automatically\ncreated. No need to manually run any migration or SQL script here.\n\nYou can also manually create the table beforehand, if you prefer:\n```\nbin/cake Migrations migrate -p DatabaseLog\n```\nIf you use a custom connection, make sure to set the connection here for migrations:\n```\nbin/cake Migrations migrate -p DatabaseLog -c custom\n```\n\nFully tested so far are PostgreSQL and MySQL, but by using the ORM all major databases should be supported.\n\nFor default connection usage only:\nYou can also just copy the migration file(s) into your app `/config/Migrations/`, modify if needed,\nand then run it as part of your app migrations.\n\n## Usage\n\nAnywhere in your app where you call `$this-\u003elog()` or `Log::write()` the DatabaseLog engine will be used.\n```php\n$this-\u003elog('This is a detailed message logged to the database', 'error');\n// or\nLog::write('error', 'This is a detailed message logged to the database');\n```\nThere is also a browsable web backend you can view your logs with.\n\nSee [Docs](/docs) for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdereuromark%2FCakePHP-DatabaseLog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdereuromark%2FCakePHP-DatabaseLog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdereuromark%2FCakePHP-DatabaseLog/lists"}