PHPackages                             michaelmoussa/zend-psr-log - 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. michaelmoussa/zend-psr-log

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

michaelmoussa/zend-psr-log
==========================

PSR3-compliant, backwards-compatible, drop-in replacement for Zend\\Log\\Logger.

2.0.0(9y ago)46.5k1MITPHPPHP ^7.0

Since Oct 16Pushed 9y ago1 watchersCompare

[ Source](https://github.com/michaelmoussa/zend-psr-log)[ Packagist](https://packagist.org/packages/michaelmoussa/zend-psr-log)[ RSS](/packages/michaelmoussa-zend-psr-log/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (9)Versions (5)Used By (0)

[![Build Status](https://camo.githubusercontent.com/a414e014de46adac5f2b126d2fec74d6d9bf722c91db17aba26b60f70532444a/68747470733a2f2f7472617669732d63692e6f72672f6d69636861656c6d6f757373612f7a656e642d7073722d6c6f672e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/michaelmoussa/zend-psr-log)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/299c999b62bc80c9d4fa5c32d63f0a73ba403940acdcd2d94172d72f846904d6/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d69636861656c6d6f757373612f7a656e642d7073722d6c6f672f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/michaelmoussa/zend-psr-log/?branch=master)[![Code Climate](https://camo.githubusercontent.com/c3aabebd4ecef3487a31fd3a3c23e3667573714138d1cefc3e0807f928ee6114/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6d69636861656c6d6f757373612f7a656e642d7073722d6c6f672f6261646765732f6770612e737667)](https://codeclimate.com/github/michaelmoussa/zend-psr-log)[![Code Coverage](https://camo.githubusercontent.com/3e92d8108ebff66e7de9965a63c8561a09662d5ba30eebbc4c6b4400088283de/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d69636861656c6d6f757373612f7a656e642d7073722d6c6f672f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/michaelmoussa/zend-psr-log/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/18f48d0360c6b67882c188b5952ff8fd35b72f6a44ed1f017fb32640d1487b7e/68747470733a2f2f706f7365722e707567782e6f72672f6d69636861656c6d6f757373612f7a656e642d7073722d6c6f672f76657273696f6e2e737667)](https://packagist.org/packages/michaelmoussa/zend-psr-log)[![Latest Unstable Version](https://camo.githubusercontent.com/3d9d3b24e4c64495e0c9e95360937e73565d03e86c517053dca5e5a72b95d650/68747470733a2f2f706f7365722e707567782e6f72672f6d69636861656c6d6f757373612f7a656e642d7073722d6c6f672f762f756e737461626c652e737667)](//packagist.org/packages/michaelmoussa/zend-psr-log)[![License](https://camo.githubusercontent.com/3c85f7c446c247ff45e699720dc0f04bb1fcb08857214d1d7c992bfb57e5ee3f/68747470733a2f2f706f7365722e707567782e6f72672f6d69636861656c6d6f757373612f7a656e642d7073722d6c6f672f6c6963656e73652e737667)](https://packagist.org/packages/michaelmoussa/zend-psr-log)

zend-psr-log
============

[](#zend-psr-log)

Overview
--------

[](#overview)

A number of PHP libraries accept a `Psr\Log\LoggerInterface` for logging messages. Unfortunately, applications using [Zend Framework 2](https://github.com/zendframework/zf2) cannot provide their existing `Zend\Log\Logger` loggers, as they don't comply with [PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md).

In fact, the two interfaces are not compatible, as they declare some common methods with different signatures. For example: [Zend alert](https://github.com/zendframework/zendframework/blob/release-2.1.0/library/Zend/Log/LoggerInterface.php#L28) vs. [Psr alert](https://github.com/php-fig/log/blob/504b915845b0fe47819fcbabbfbea18e95f5cf5c/Psr/Log/LoggerInterface.php#L41).

This library serves as a backwards-compatible replacement for `Zend\Log\Logger` instances that provides a [Psr\\Log](https://github.com/php-fig/log)-compliant interface to the underlying `Zend\Log\Logger` instance. The result is that you can provide either logger depending on the interface required by a given context, while still having all messages go through `Zend\Log\Logger` and benefiting from its robustness.

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

[](#installation)

The only supported method of installation is [Composer](https://getcomposer.org/).

`composer require "michaelmoussa/zend-psr-log"`

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

[](#configuration)

To begin, you must add the `ZendPsrLog` module to your `application.config.php` module list as with any ZF2 application.

```
return [
    'modules' => [
        ...,

        'ZendPsrLog',

        ...
    ],
    ...
];
```

Further configuration depends on how you are presently getting your instances of a `Zend\Log\Logger`.

### "I define a `log` entry in my configuration with `Zend\Log\Logger` as the key, and then let `Zend\Log\LoggerAbstractServiceFactory` do the work."

[](#i-define-a-log-entry-in-my-configuration-with-zendloglogger-as-the-key-and-then-let-zendlogloggerabstractservicefactory-do-the-work)

Then you're done! `ZendPsrLog` adds its own factory for creating `Zend\Log\Logger` instances, which will be invoked before the Abstract Factory.

### "I define a `log` entry in my configuration with a different key, then let `Zend\Log\LoggerAbstractServiceFactory` do the work."

[](#i-define-a-log-entry-in-my-configuration-with-a-different-key-then-let-zendlogloggerabstractservicefactory-do-the-work)

For each key you use, you'll need to add a `'My\Key\Here' => new \ZendPsrLog\LoggerFactory('My\Key\Here')` entry to your service manager config.

### "I define a log key in my configuration with no key, and then have my own `'Zend\Log\Logger' => '...'` factory definition in the service manager config"

[](#i-define-a-log-key-in-my-configuration-with-no-key-and-then-have-my-own-zendloglogger---factory-definition-in-the-service-manager-config)

You need to replace your `'Zend\Log\Logger' => '...'` entry with `'Zend\Log\Logger' => new \ZendPsrLog\LoggerFactory(null)`, as your definition will override the one done by the `ZendPsrLog\LoggerFactory`.

If your custom factory is doing some special logic, you will have to extend `ZendPsrLog\LoggerFactory` on your own to ensure it persists.

### "I use `new \Zend\Log\Logger(...)`."

[](#i-use-new-zendloglogger)

1. Please don't. :) You should be using the `ServiceManager`.
2. Replace `new \Zend\Log\Logger` with `new \ZendPsrLog\Logger`.

Usage
-----

[](#usage)

### As a `Zend\Log\LoggerInterface`

[](#as-a-zendlogloggerinterface)

The `ZendPsrLog\Logger` is an extension of `Zend\Log\Logger`, so any class you have in your application that is presently using a `Zend\Log\Logger` can use the `ZendPsrLog\Logger` without any additional configuration.

### As a `Psr\Log\LoggerInterface`

[](#as-a-psrlogloggerinterface)

Suppose you have a class that requires a `Psr\Log\LoggerInterface` instance:

```
use Psr\Log\LoggerInterface;

class Foo
{
    public function __construct(LoggerInterface $logger) { ... }
}
```

And you obtain an instance of the `ZendPsrLog\Logger`:

```
/** @var \ZendPsrLog\Logger $logger */
$logger = $serviceManager->get('Zend\Log\Logger');
```

Just use the `->getPsrLogger()` method to obtain a `Psr\Log\LoggerInterface` to your existing `Zend\Log\Logger`:

```
$foo = new Foo($logger->getPsrLogger());
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 96.2% 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 ~289 days

Total

4

Last Release

3358d ago

Major Versions

1.0.0-rc2 → 2.0.02017-03-02

PHP version history (2 changes)1.0.0-rc1PHP &gt;=5.3.3

2.0.0PHP ^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/91d3f2058c69f2d3e5396f0d6ecf1bf048e7a83905731530ab6dd4659bb62789?d=identicon)[michaelmoussa](/maintainers/michaelmoussa)

---

Top Contributors

[![michaelmoussa](https://avatars.githubusercontent.com/u/183833?v=4)](https://github.com/michaelmoussa "michaelmoussa (25 commits)")[![adamturcsan](https://avatars.githubusercontent.com/u/6500048?v=4)](https://github.com/adamturcsan "adamturcsan (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/michaelmoussa-zend-psr-log/health.svg)

```
[![Health](https://phpackages.com/badges/michaelmoussa-zend-psr-log/health.svg)](https://phpackages.com/packages/michaelmoussa-zend-psr-log)
```

###  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)[open-telemetry/api

API for OpenTelemetry PHP.

1833.0M214](/packages/open-telemetry-api)[snapshotpl/zf-snap-php-debug-bar

PHP Debug Bar module for Zend Framework 2

3026.1k](/packages/snapshotpl-zf-snap-php-debug-bar)[pagemachine/typo3-formlog

Form log for TYPO3

23225.3k6](/packages/pagemachine-typo3-formlog)[davidhavl/dherrorlogging

Full featured error logging module for ZF2/ZF3 application

1924.5k](/packages/davidhavl-dherrorlogging)

PHPackages © 2026

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