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

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

vsemayki/monolog-mysql
======================

A handler for Monolog that sends messages to MySQL

3.0.0(9y ago)2332MITPHP

Since Sep 13Pushed 9y ago2 watchersCompare

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

READMEChangelogDependencies (1)Versions (8)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 `monolog` table. The class further is added extra attributes - `channel`, `level`, `ip`, `created_at` and `user_agent`, which are stored in a separate database fields, and can be used for later analyzing and sorting.

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

[](#installation)

monolog-mysql is available via composer:

```
composer require vsemayki/monolog-mysql:^2.0
```

Usage
=====

[](#usage)

First of all, import `dump.sql`.

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
- **$level** can be any of the standard Monolog logging levels. Use Monologs statically defined contexts. *Defaults to Logger::INFO*
- **$bubble** *Defaults to true*

Examples
========

[](#examples)

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

```
