PHPackages                             ftrotter/two-table-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. ftrotter/two-table-monolog-mysql

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

ftrotter/two-table-monolog-mysql
================================

A handler for Monolog that sends messages to MariaDB (or MySQL), split between two tables

v1.0.4(9y ago)0288MITPHP

Since Sep 13Pushed 6y agoCompare

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

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

two-table-monolog-mysql
=======================

[](#two-table-monolog-mysql)

This is a fork of the monolog-mysql project to implement two important features that I need:

- Specify the database, and not just the table(s) on setup.
- Logs to two different tables, one for the messages and another for the context arrays.

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`.

```
"ftrotter/two-table-monolog-mysql": ">0.0.1"

```

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.
- **$database** The name of the database where the logs should be stored
- **$message\_table** The table name where the message logs should be stored
- **$context\_table** The table name where the context logs should be stored
- **$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 TwoMySQLHandler\TwoMySQLHandler;

//Create MysqlHandler
$mySQLHandler = new TwoMySQLHandler($pdo,"log_db", "log_message", "log_context", array('username', 'userid'), \Monolog\Logger::DEBUG);

$context = ['not_sure', 'what_goes_here']; //not clear to me how this works

//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

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 60.4% 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

3374d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/529070a1000481c1ec43116693d5ca874222641f3f6d863bc5c57074f2319be8?d=identicon)[ftrotter](/maintainers/ftrotter)

---

Top Contributors

[![waza-ari](https://avatars.githubusercontent.com/u/4508976?v=4)](https://github.com/waza-ari "waza-ari (29 commits)")[![ftrotter](https://avatars.githubusercontent.com/u/83133?v=4)](https://github.com/ftrotter "ftrotter (8 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)")[![squirrelcrmhub](https://avatars.githubusercontent.com/u/21302229?v=4)](https://github.com/squirrelcrmhub "squirrelcrmhub (1 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)")

---

Tags

logloggingdatabasemysqlmonolog

### Embed Badge

![Health badge](/badges/ftrotter-two-table-monolog-mysql/health.svg)

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