PHPackages                             abryrath/monolog-mysql - 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. abryrath/monolog-mysql

ActiveLibrary[Database &amp; ORM](/categories/database)

abryrath/monolog-mysql
======================

A handler for Monolog that sends messages to MySQL

v1.1.1(6y ago)07921MITPHP

Since Sep 13Pushed 6y agoCompare

[ Source](https://github.com/abryrath/monolog-mysql)[ Packagist](https://packagist.org/packages/abryrath/monolog-mysql)[ Docs](https://github.com/abryrath/monolog-mysql)[ RSS](/packages/abryrath-monolog-mysql/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (2)Versions (9)Used By (1)

monolog-mysql
=============

[](#monolog-mysql)

MySQL Handler for Monolog, which allows to store log messages in a MySQL Table. It can log text messages to a specific table, and creates the table automatically if it does not exist. The class further allows to dynamically add extra attributes, which are stored in a separate database field, and can be used for later analyzing and sorting.

HELP WANTED
===========

[](#help-wanted)

As I do not use this project myself anymore and I do not find the time to maintain this project as it deserves I would be happy to find someone taking it over. Please contact me at  if you'd be interesting to take over that project. Thanks!

Installation
============

[](#installation)

monolog-mysql is available via composer. Just add the following line to your required section in composer.json and do a `php composer.phar update`.

```
"wazaari/monolog-mysql": ">1.0.0"

```

Usage
=====

[](#usage)

Just use it as any other Monolog Handler, push it to the stack of your Monolog Logger instance. The Handler however needs some parameters:

- **$pdo** PDO Instance of your database. Pass along the PDO instantiation of your database connection with your database selected.
- **$table** The table name where the logs should be stored
- **$additionalFields** simple array of additional database fields, which should be stored in the database. The columns are created automatically, and the fields can later be used in the extra context section of a record. See examples below. *Defaults to an empty array()*
- **$level** can be any of the standard Monolog logging levels. Use Monologs statically defined contexts. *Defaults to Logger::DEBUG*
- **$bubble** *Defaults to true*

Examples
========

[](#examples)

Given that $pdo is your database instance, you could use the class as follows:

```
//Import class
use MySQLHandler\MySQLHandler;

//Create MysqlHandler
$mySQLHandler = new MySQLHandler($pdo, "log", array('username', 'userid'), \Monolog\Logger::DEBUG);

//Create logger
$logger = new \Monolog\Logger($context);
$logger->pushHandler($mySQLHandler);

//Now you can use the logger, and further attach additional information
$logger->addWarning("This is a great message, woohoo!", array('username'  => 'John Doe', 'userid'  => 245));
```

License
=======

[](#license)

This tool is free software and is distributed under the MIT license. Please have a look at the LICENSE file for further information.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 63% 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 ~313 days

Recently: every ~431 days

Total

7

Last Release

2379d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/44610614?v=4)[Abry Rath](/maintainers/abryrath)[@abryrath](https://github.com/abryrath)

---

Top Contributors

[![waza-ari](https://avatars.githubusercontent.com/u/4508976?v=4)](https://github.com/waza-ari "waza-ari (29 commits)")[![stefandoorn](https://avatars.githubusercontent.com/u/4903082?v=4)](https://github.com/stefandoorn "stefandoorn (6 commits)")[![abryrathunion](https://avatars.githubusercontent.com/u/42214308?v=4)](https://github.com/abryrathunion "abryrathunion (2 commits)")[![kermorgant](https://avatars.githubusercontent.com/u/10561580?v=4)](https://github.com/kermorgant "kermorgant (2 commits)")[![youaresodalgona](https://avatars.githubusercontent.com/u/32331576?v=4)](https://github.com/youaresodalgona "youaresodalgona (2 commits)")[![nickgravel](https://avatars.githubusercontent.com/u/918742?v=4)](https://github.com/nickgravel "nickgravel (1 commits)")[![squirrelcrmhub](https://avatars.githubusercontent.com/u/21302229?v=4)](https://github.com/squirrelcrmhub "squirrelcrmhub (1 commits)")[![dzuelke](https://avatars.githubusercontent.com/u/27900?v=4)](https://github.com/dzuelke "dzuelke (1 commits)")[![clement-garrigou](https://avatars.githubusercontent.com/u/10114508?v=4)](https://github.com/clement-garrigou "clement-garrigou (1 commits)")[![lpotherat](https://avatars.githubusercontent.com/u/380424?v=4)](https://github.com/lpotherat "lpotherat (1 commits)")

---

Tags

logloggingdatabasemysqlmonolog

###  Code Quality

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/abryrath-monolog-mysql/health.svg)

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

###  Alternatives

[wazaari/monolog-mysql

A handler for Monolog that sends messages to MySQL

140884.1k6](/packages/wazaari-monolog-mysql)[danielme85/laravel-log-to-db

Custom Laravel Log channel handler that can store log events to SQL or MongoDB databases. Uses Laravel native logging functionality.

135934.5k1](/packages/danielme85-laravel-log-to-db)[bradmkjr/monolog-wordpress

A handler for Monolog that sends messages to MySQL via WordPress Functions

2817.1k](/packages/bradmkjr-monolog-wordpress)[karelwintersky/monolog-pdo-handler

A handler for Monolog that stores data via PDO driver to Database

109.0k1](/packages/karelwintersky-monolog-pdo-handler)

PHPackages © 2026

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