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

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

iampersistent/monolog-mysql
===========================

A handler for Monolog that sends messages to MySQL

v1.0.4(9y ago)010MITPHP

Since Sep 13Pushed 7y ago1 watchersCompare

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

READMEChangelogDependencies (1)Versions (7)Used By (0)

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.

Homepage:

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

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 71.1% 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 ~220 days

Total

5

Last Release

3376d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bd5a2c6deedf2f52379d21fa55c9f5c6d0999b0ac1ca2ca2f33293e229107bfe?d=identicon)[iampersistent](/maintainers/iampersistent)

---

Top Contributors

[![waza-ari](https://avatars.githubusercontent.com/u/4508976?v=4)](https://github.com/waza-ari "waza-ari (27 commits)")[![stefandoorn](https://avatars.githubusercontent.com/u/4903082?v=4)](https://github.com/stefandoorn "stefandoorn (6 commits)")[![kermorgant](https://avatars.githubusercontent.com/u/10561580?v=4)](https://github.com/kermorgant "kermorgant (2 commits)")[![clement-garrigou](https://avatars.githubusercontent.com/u/10114508?v=4)](https://github.com/clement-garrigou "clement-garrigou (1 commits)")[![dzuelke](https://avatars.githubusercontent.com/u/27900?v=4)](https://github.com/dzuelke "dzuelke (1 commits)")[![squirrelcrmhub](https://avatars.githubusercontent.com/u/21302229?v=4)](https://github.com/squirrelcrmhub "squirrelcrmhub (1 commits)")

---

Tags

logloggingdatabasemysqlmonolog

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/iampersistent-monolog-mysql/health.svg)](https://phpackages.com/packages/iampersistent-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)
