PHPackages                             gupalo/monolog-dbal-logger - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. gupalo/monolog-dbal-logger

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

gupalo/monolog-dbal-logger
==========================

Monolog Handler for DBAL

1.9.0(4mo ago)016.7k↓19.4%1MITPHPPHP &gt;=8.4

Since Jul 23Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/gupalo/monolog-dbal-logger)[ Packagist](https://packagist.org/packages/gupalo/monolog-dbal-logger)[ RSS](/packages/gupalo-monolog-dbal-logger/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (10)Versions (33)Used By (1)

Monolog Handler for DBAL
========================

[](#monolog-handler-for-dbal)

Installation
------------

[](#installation)

Add to your project via composer:

```
composer require gupalo/monolog-dbal-logger

```

Create log table.

```
CREATE TABLE `_log` (
    `id`                    bigint UNSIGNED NOT NULL AUTO_INCREMENT,
    `created_at`            datetime NOT NULL,
    `level`                 smallint NOT NULL DEFAULT 0,
    `level_name`            enum('debug','info','notice','warning','error','critical','alert','emergency') NULL DEFAULT NULL,
    `channel`               varchar(255) NOT NULL DEFAULT '',
    `message`               varchar(1024) NOT NULL DEFAULT '',
    `context`               text NULL DEFAULT NULL,
    PRIMARY KEY (`id`),
    INDEX `log_created_at_level` (`created_at`, `level`) USING BTREE
) DEFAULT CHARACTER SET=utf8mb4 COLLATE=utf8mb4_general_ci;

```

Example
-------

[](#example)

`$connection` is `Doctrine\DBAL\Connection`

```
$handler = new \Gupalo\MonologDbalLogger\MonologDbalLogger($connection);
$logger = new \Monolog\Logger();
$logger->pushHandler($handler);

$logger->addWarning('You might not read the docs', ['page' => 17, 'username' => 'guest']);

```

Symfony
-------

[](#symfony)

Configuration example:

`services.yaml`

```
Gupalo\MonologDbalLogger\Symfony\ErrorLogListener:
    tags: [ {name: 'kernel.event_subscriber'} ]

monolog.dbal_handler:
    class: 'Gupalo\MonologDbalLogger\MonologDbalLogger'
    public: true
    bind:
        $connection: '@doctrine.dbal.default_connection'
        $level: 200
    tags: ['monolog.logger']

```

`monolog.yaml`

```
monolog:
    handlers:
        db:
            type: service
            id: 'monolog.dbal_handler' # note - no "@"
            channels: ["!event", "!request", "!security"]

```

Configure
---------

[](#configure)

Params in `MonologDbalLogger::__construct`:

- `string $table = '_log'`: table name
- `int $maxRows = 100000`: if you have more rows than `$maxRows` then cleaner will eventually (1 in 1000 chances) remove them

Extend
------

[](#extend)

You may extend `MonologDbalLogger` and add your own logic. See `MyMonologDbalLogger` as an example. If you add additional fields, remember to change table creation SQL.

Table:

```
CREATE TABLE `_log` (
    `id`                    bigint UNSIGNED NOT NULL AUTO_INCREMENT,
    `created_at`            datetime NOT NULL,
    `level`                 smallint NOT NULL DEFAULT 0,
    `level_name`            enum('debug','info','notice','warning','error','critical','alert','emergency') NULL DEFAULT NULL,
    `channel`               varchar(255) NOT NULL DEFAULT '',
    `message`               varchar(1024) NOT NULL DEFAULT '',
    `context`               text NULL DEFAULT NULL,
    `method`                varchar(255) NULL DEFAULT NULL,
    `cmd`                   varchar(255) NULL DEFAULT NULL,
    `uid`                   varchar(32) NULL DEFAULT NULL,
    `count`                 int NULL DEFAULT NULL,
    `time`                  float NULL DEFAULT NULL,
    `exception_class`       varchar(1024) NULL DEFAULT NULL,
    `exception_message`     varchar(1024) NULL DEFAULT NULL,
    `exception_line`        varchar(1024) NULL DEFAULT NULL,
    `exception_trace`       text NULL,
    PRIMARY KEY (`id`),
    INDEX `log_created_at_level` (`created_at`, `level`) USING BTREE
) DEFAULT CHARACTER SET=utf8mb4 COLLATE=utf8mb4_general_ci;

```

EasyAdmin
---------

[](#easyadmin)

Add to menu

```
yield MenuItem::linkToCrud('Log', 'fa-solid fa-file-waveform', Log::class);

```

Add to `config/packages/doctrine.yaml`

```
doctrine:
    orm:
        mappings:
            # ...here is "App", add below
            Gupalo:
                is_bundle: false
                dir: '%kernel.project_dir%/vendor/gupalo/monolog-dbal-logger/src/Entity'
                prefix: 'Gupalo\MonologDbalLogger\Entity'
                alias: Gupalo

```

Create controller. Override if needed

```
class LogCrudController extends \Gupalo\MonologDbalLogger\EasyAdmin\Controller\LogCrudController
{
}

```

Add to `config/services.yaml`

```
services:
    Gupalo\MonologDbalLogger\Repository\LogRepository:
        tags: [ 'doctrine.repository_service' ]

```

Other
-----

[](#other)

See `tests`.

###  Health Score

53

—

FairBetter than 97% of packages

Maintenance76

Regular maintenance activity

Popularity25

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity83

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 100% 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 ~64 days

Recently: every ~90 days

Total

32

Last Release

129d ago

PHP version history (3 changes)1.0.0PHP &gt;=7.4

1.4.0PHP &gt;=8.1

1.9.0PHP &gt;=8.4

### Community

Maintainers

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

---

Top Contributors

[![luchaninov](https://avatars.githubusercontent.com/u/3829796?v=4)](https://github.com/luchaninov "luchaninov (34 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/gupalo-monolog-dbal-logger/health.svg)

```
[![Health](https://phpackages.com/badges/gupalo-monolog-dbal-logger/health.svg)](https://phpackages.com/packages/gupalo-monolog-dbal-logger)
```

###  Alternatives

[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

81733.7k](/packages/flow-php-flow)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)

PHPackages © 2026

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