PHPackages                             dvsa/mot-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. dvsa/mot-logger

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

dvsa/mot-logger
===============

Unified logging utility for DVSA MOT applications, powered by Monolog.

v3.3.0(2mo ago)012.1k↑57.1%21MITPHPPHP ^8.2CI passing

Since May 31Pushed 2mo ago6 watchersCompare

[ Source](https://github.com/dvsa/mot-logger)[ Packagist](https://packagist.org/packages/dvsa/mot-logger)[ RSS](/packages/dvsa-mot-logger/feed)WikiDiscussions main Synced yesterday

READMEChangelog (1)Dependencies (31)Versions (13)Used By (1)

DVSA MOT Logger
===============

[](#dvsa-mot-logger)

Unified logging utility for DVSA MOT applications, powered by Monolog.

Overview
--------

[](#overview)

This library provides a unified logging solution for the DVSA MOT applications, consolidating functionality from two legacy packages:

- **dvsa/mot-logger** - The original code base stored under this repository, featuring database logging with Doctrine SQL query.
- **dvsa/mot-application-logger** - MVC event listeners for request/response/exception logging

### Features

[](#features)

- **Monolog-based logging** - Built on Monolog 3.x for robust logging capabilities
- **Doctrine DBAL support** - Log SQL queries to database
- **MVC Event Listeners** - Automatic request, response and exception logging via Laminas
- **Environment-aware log levels** - Different log levels per environment (dev, int, prod, etc.)
- **Sensitive data masking** - Automatic masking of passwords and sensitive fields
- **Backward compatible** - Works with legacy service names and configurations

Requirements
------------

[](#requirements)

- PHP 8.2+
- Monolog 3.x
- Doctrine DBAL 3.x or 4.x
- PSR Container 1.0 or 2.0
- Laminas EventManager 3.15+
- Laminas HTTP 3.0+
- Laminas MC 3.8+

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

[](#installation)

```
composer require dvsa/mot-logger
```

Configuration
-------------

[](#configuration)

### Log Levels by Environment

[](#log-levels-by-environment)

The library supports environment-aware log levels. The environment can be set explicitly or auto-detected rom the `APP_ENV` environment variable.

Configuration resolution order for each writer:

1. Writer-level environment-specific level
2. Writer-level fixed level
3. Global environment levels
4. Default level (debug)

```
return [
    'mot_logger' => [
        'channel' => 'my_app',
        'environment' => 'dev',
        'environment_levels' => [
            'dev' => 'debug',
            'int' => 'ifo',
            'prod' => 'critical',
        ],
    ],
];
```

### Writers

[](#writers)

The library supports multiple log writers including StreamHandler for console output and DatabaseWriter for database logging.

```
'writers' => [
    [
        'type' => 'stream',
        'path' => '/var/log/app/application.log',
        'formatter' => 'pipe',
        'level' => 'info',
    ],
],
```

### Sensitive Data

[](#sensitive-data)

Sensitive fields such as passwords, secrets, and tokens are automatically masked in log output. The mask character and fields to mask are configurable.

```
'mot_logger' => [
    'mask_credentials' => [
        'mask' => '****',
        'fields' => ['password', 'secret', 'token'],
    ],
],
```

### Token Inclusion Control

[](#token-inclusion-control)

By default, authentication tokens are NOT included in log metadata for the security purpose. For the debugging process, you can enable token logging globally:

```
'mot_logger' => [
    'include_tokens' => true,
],
```

Loggers
-------

[](#loggers)

### MotLogger

[](#motlogger)

The main logger class that provides structured logging with metadata support. It includes identity provider integration for tracking user information and token service support for API authentication context.

### ConsoleLogger

[](#consolelogger)

Specialized logger for console applications that automatically logs to stdout at INFO level. Ideal for CLI commands and background jobs.

### SystemLogger

[](#systemlogger)

Logger that writes to PHP's error\_log function. Suitable for system-level errors and critical application failures.

MVC Event Listeners
-------------------

[](#mvc-event-listeners)

The library automatically registers several listeners when used in a Laminas MVC application:

ListenerEventPurposeRequestListenerrouteCaptures incoming HTTP request details including URI, method, parameters, and user informationResponseListenerfinishLog response details including status code, content type, and execution timeApiRequestListenerrouteCaputres API-specific request data including authorization headers and request UUIDsApiClientRequestListenershared eventLogs outbound API client requests to external servicesExceptionListenerrouteCaputers and logs application exceptions with full stack tracesListeners are automatically attached in Module::onBootstrap() when the application is not running in console mode.

Migration from Legacy Packages
------------------------------

[](#migration-from-legacy-packages)

This library consolidates two previous packages into one:

- **dvsa/mot-logger** - The original code base stored under this repository, featuring database logging with Doctrine SQL query.
- **dvsa/mot-application-logger** - MVC event listeners for request/response

### Step 1: Update Composer Dependencies

[](#step-1-update-composer-dependencies)

Remove the old packages:

```
composer remove dvsa/mot-logger dvsa/mot-application-logger
```

Install the new package:

```
composer require dvsa/mot-logger
```

### Step 2: Update Configuration

[](#step-2-update-configuration)

The root configuration key changed from `dvsa_application_logger` or `dvsa_logger` to `mot_logger`. The library will still detect and convert legacy configuration keys for backward compatibility.

```
// Old (dvsa_application_logger)
return [
    'dvsa_application_logger' => [...],
];

// New
return [
    'mot_logger' => [...],
];
```

### Step 3: Update Class References (Optional)

[](#step-3-update-class-references-optional)

The main logger class has been moved:

Old ClassNew Class`DvsaLogger\Logger\Logger``DvsaLogger\Logger\MotLogger``DvsaApplicationLogger\Logger\Logger``DvsaLogger\Logger\MotLogger`Legacy service names are still supported via aliases, so existing code will continue to work without changes.

### Step 4: PHP Version

[](#step-4-php-version)

Ensure your application is running PHP 8.2 or higher. This is a required minimum for the new library.

### Configuration Keys

[](#configuration-keys)

Legacy configuration keys are automatically detected and converted to the new format. The new configuration uses `mot_logger` as the root key.

### New Features

[](#new-features)

- Constructor property promotion for cleaner implementation, following modern PHP practices.
- Environment auto-detection from APP\_ENV environment variable, with fallback to default levels if not set.
- Per-writer log level configuration for fine-grained control.
- Token inclusion control for security/privacy compliance.
- Full PHP 8.2+ strict typing throughout the codebase for improved reliability and developer experience.

Architecture
------------

[](#architecture)

```
src/
├── Contract/       # Interface defining logger contracts
|── Factory/         # Service factories for DI
├── Formatter/         # Log formatters (JSON, Pipe-delimited)
├── Handler/           # onolog handlers for various outputs
├── Helper/            # Utility classes for logging support
|── Listener/            # MVC event listeners for auto-logging
├── Logger/             # Main logger classes (MotLogger, ConsoleLogger, SystemLogger)
├── Processor/         # Monolog processors for data transformation and enrichment
├── Service/           # Services such as Doctrine query logging

```

Development
-----------

[](#development)

### Running Tests

[](#running-tests)

```
composer test
```

Running tests with code coverage requires Xdebug or PCOV to be installed and enabled in your PHP environment.

```
composer test-coverage
```

### Coding Standards

[](#coding-standards)

PHPStan and Psalm are configured for static analysis. Code style is enforced via PHP\_CodeSniffer using DVSA coding standards.

```
composer phpcs
```

```
composer phpstan
```

```
composer psalm
```

License
-------

[](#license)

MIT License. See LICENSE file for details.

###  Health Score

51

—

FairBetter than 95% of packages

Maintenance85

Actively maintained with recent releases

Popularity26

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor3

3 contributors hold 50%+ of commits

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

Recently: every ~228 days

Total

7

Last Release

80d ago

Major Versions

v1.0.1 → v2.0.02023-10-13

v2.0.0 → v3.0.02024-07-10

PHP version history (3 changes)v1.0.0PHP ^8.0

v2.0.0PHP ^8.1

v3.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/6ac141ec696a70dbc4b8c1c7541cd1bfc06e99617f2484d7631ed43cb48d2f6b?d=identicon)[dvsa](/maintainers/dvsa)

---

Top Contributors

[![caoimheb](https://avatars.githubusercontent.com/u/9531189?v=4)](https://github.com/caoimheb "caoimheb (5 commits)")[![PapaZouk](https://avatars.githubusercontent.com/u/106058501?v=4)](https://github.com/PapaZouk "PapaZouk (3 commits)")[![ccurran01](https://avatars.githubusercontent.com/u/32199652?v=4)](https://github.com/ccurran01 "ccurran01 (2 commits)")[![jennifer-choo](https://avatars.githubusercontent.com/u/113026728?v=4)](https://github.com/jennifer-choo "jennifer-choo (2 commits)")[![aaronlong](https://avatars.githubusercontent.com/u/5321346?v=4)](https://github.com/aaronlong "aaronlong (1 commits)")[![waringr](https://avatars.githubusercontent.com/u/79579024?v=4)](https://github.com/waringr "waringr (1 commits)")[![mateuszc-kainos](https://avatars.githubusercontent.com/u/20680998?v=4)](https://github.com/mateuszc-kainos "mateuszc-kainos (1 commits)")[![sdh100shaun](https://avatars.githubusercontent.com/u/79883?v=4)](https://github.com/sdh100shaun "sdh100shaun (1 commits)")[![UndermountainK](https://avatars.githubusercontent.com/u/143088690?v=4)](https://github.com/UndermountainK "UndermountainK (1 commits)")

---

Tags

loggingmonologdvsaMOT

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/dvsa-mot-logger/health.svg)

```
[![Health](https://phpackages.com/badges/dvsa-mot-logger/health.svg)](https://phpackages.com/packages/dvsa-mot-logger)
```

###  Alternatives

[magento/community-edition

Magento 2 (Open Source)

12.2k53.6k13](/packages/magento-community-edition)[wheelpros/fitment-platform-api

Magento 2 (Open Source)

12.1k1.2k](/packages/wheelpros-fitment-platform-api)[shlinkio/shlink

A self-hosted and PHP-based URL shortener application with CLI and REST interfaces

5.1k5.2k](/packages/shlinkio-shlink)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)[concrete5/core

Concrete core subtree split

20166.1k51](/packages/concrete5-core)[kokspflanze/bjy-authorize

Laminas\\Acl based firewall system for Mezzio dispatch protection

20199.4k4](/packages/kokspflanze-bjy-authorize)

PHPackages © 2026

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