PHPackages                             harmonicdigital/doctrine-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. harmonicdigital/doctrine-dbal-logger

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

harmonicdigital/doctrine-dbal-logger
====================================

A customisable and flexible logging middleware alternative for Doctrine DBAL

v1.0.1(8mo ago)11MITPHPPHP &gt;=8.2CI passing

Since Sep 8Pushed 8mo agoCompare

[ Source](https://github.com/Harmonic-Digital-Ltd/doctrine-dbal-logger)[ Packagist](https://packagist.org/packages/harmonicdigital/doctrine-dbal-logger)[ RSS](/packages/harmonicdigital-doctrine-dbal-logger/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (6)Versions (3)Used By (0)

Doctrine DBAL Logger Middleware [![CI](https://github.com/Harmonic-Digital-Ltd/doctrine-dbal-logger/actions/workflows/php.yml/badge.svg)](https://github.com/Harmonic-Digital-Ltd/doctrine-dbal-logger/actions/workflows/php.yml)
=================================================================================================================================================================================================================================

[](#doctrine-dbal-logger-middleware-)

A more flexible logging middleware for Doctrine DBAL that provides database operation logging with configurable log levels and messages.

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

[](#installation)

```
composer require harmonicdigital/doctrine-dbal-logger
```

Basic Usage
-----------

[](#basic-usage)

The middleware can be used as a drop-in replacement for the built-in DBAL logging middleware.

```
use Doctrine\DBAL\Configuration;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DriverManager;
use HarmonicDigital\DoctrineDbal\Logging\Middleware;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;

// Create your PSR-3 logger
$logger = new Logger('doctrine');
$logger->pushHandler(new StreamHandler('doctrine.log', Logger::DEBUG));

// Create the middleware
$middleware = new Middleware($logger);

// Configure DBAL with the middleware
$configuration = new Configuration();
$configuration->setMiddlewares([$middleware]);

// Create your connection
$connection = DriverManager::getConnection([
    'driver' => 'pdo_sqlite',
    'path' => ':memory:',
], $configuration);
```

Custom Log levels
-----------------

[](#custom-log-levels)

Sometimes, you may want to log certain database operations at a different levels to the defaults. E.g. you may want connection to be a `debug` level, but rollback to to be a warning.

Instead of passing a `Logger` instance to the middleware, you can pass a `DoctrineLogger` instance, with customised log levels. Additionally, you may want to change the log message for a certain action.

You pass the overriding levels and messages to the `DoctrineLogger` constructor.

### Example

[](#example)

```
use HarmonicDigital\DoctrineDbal\Logging\DoctrineLogger;
use HarmonicDigital\DoctrineDbal\Logging\DoctrineLoggerInterface;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;

// Create your PSR-3 logger
$logger = new Logger('doctrine');
$logger->pushHandler(new StreamHandler('doctrine.log', Logger::DEBUG));
$middleware = new Middleware(new DoctrineLogger(
    $logger,
    [
        // Overriding log levels
        DoctrineLoggerInterface::LOG_CONNECT => Logger::DEBUG,
        DoctrineLoggerInterface::LOG_ROLL_BACK => Logger::WARNING,
    ],
    [
        // Overriding log messages
        DoctrineLoggerInterface::LOG_ROLL_BACK => 'Rolling back transaction',
    ],
));
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance61

Regular maintenance activity

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 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 ~0 days

Total

2

Last Release

246d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/135672?v=4)[Rick Ogden](/maintainers/rickogden)[@rickogden](https://github.com/rickogden)

---

Top Contributors

[![rickogden](https://avatars.githubusercontent.com/u/135672?v=4)](https://github.com/rickogden "rickogden (2 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/harmonicdigital-doctrine-dbal-logger/health.svg)

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

###  Alternatives

[sentry/sentry

PHP SDK for Sentry (http://sentry.io)

1.9k227.1M273](/packages/sentry-sentry)[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2222.9M248](/packages/open-telemetry-sdk)[bacula-web/bacula-web

The open source web based reporting and monitoring tool for Bacula

1537.5k](/packages/bacula-web-bacula-web)[pagemachine/typo3-formlog

Form log for TYPO3

23225.3k6](/packages/pagemachine-typo3-formlog)

PHPackages © 2026

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