PHPackages                             debugger84/zf2-graylog - 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. debugger84/zf2-graylog

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

debugger84/zf2-graylog
======================

A Zend\\Log writer and formatter helps you add Graylog logging to your ZF2 application.

2.2.0(8y ago)01.6k1MITPHP

Since Jan 7Pushed 8y ago1 watchersCompare

[ Source](https://github.com/debugger84/ZF2Graylog)[ Packagist](https://packagist.org/packages/debugger84/zf2-graylog)[ Docs](https://github.com/debugger84/ZF2Graylog)[ RSS](/packages/debugger84-zf2-graylog/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (3)Versions (5)Used By (0)

Graylog2 for Zend Framework 2
=============================

[](#graylog2-for-zend-framework-2)

A `Zend\Log` writer and formatter helps you add Graylog logging to your ZF2 application, using [bzikarsky/gelf-php](https://github.com/Graylog2/gelf-php): the newer version of deprecated [Graylog2/gelf-php](https://github.com/Graylog2/gelf-php) library.

Install
-------

[](#install)

```
composer require debugger84/zf2-graylog:dev-master

```

Add values of graylog connection to your config

```
    'graylog' => [
        'host' => 'http://graylog.local',
        'port' => 12222,
        'facility' => 'Your project name'
    ],

```

Rewrite factory for Zend Logger interface

```
\Zend\Log\LoggerInterface::class => \ZF2Graylog\Factory\LoggerFactory::class,

```

Usage
-----

[](#usage)

I added a method to a custom base controller:

```
class Base extends \Zend\Mvc\Controller\AbstractActionController {
    private $logger;

    protected function getLogger() {
        if (!isset($this->logger)) {
            $this->logger = new \Zend\Log\Logger;

            // __construct($facility, $hostname, $port)
            $writer = new \ZF2Graylog\Log\Writer\Graylog2('ZF2', '127.0.0.1');
            $this->logger->addWriter($writer);
        }

        return $this->logger;
    }
}

```

Which can then be used as usual:

```
$this->getLogger()->info('Informative message');

```

The formatter should (or will) support error logging (as below) by mapping the following attributes to their respective GELF fields:

```
$logger = new \Zend\Log\Logger;
$writer = new \ZF2Graylog\Log\Writer\Graylog2('ZF2', '127.0.0.1');
$logger->addWriter($writer);

Zend\Log\Logger::registerErrorHandler($logger);

Zend\Log        GELFMessage
--------------------------------------------------------------------------------
message         message, full_message, short_message (unless present in $values)
errno           level
file            file
line            line
context         additional fields (to be tested)

```

Additional fields that are associated with GELF fields:

- `full` (message) is mapped to `full_message` (if present, otherwise `message`)
- `short` (message) is mapped to `short_message` (if present, otherwise `message`)
- `version` is mapped to `version` (not set if not present)
- `facility` is mapped to `facility`. A default facility is set in the writer.
- Additional fields are mapped as additional fields.

Todo
----

[](#todo)

- Write a composer.json that includes the [Graylog2/gelf-php](https://github.com/Graylog2/gelf-php) lib.
- Docblocks.
- Further testing of different events.
- Check errno maps to the correct severity level when used as an errorHandler.

License
-------

[](#license)

TBC, will probably be MIT.

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 71.4% 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 ~819 days

Total

3

Last Release

3284d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3206371?v=4)[Andrey](/maintainers/debugger84)[@debugger84](https://github.com/debugger84)

---

Top Contributors

[![stacyhorton](https://avatars.githubusercontent.com/u/629310?v=4)](https://github.com/stacyhorton "stacyhorton (5 commits)")[![ealebed](https://avatars.githubusercontent.com/u/8081901?v=4)](https://github.com/ealebed "ealebed (2 commits)")

---

Tags

logloggingzf2

### Embed Badge

![Health badge](/badges/debugger84-zf2-graylog/health.svg)

```
[![Health](https://phpackages.com/badges/debugger84-zf2-graylog/health.svg)](https://phpackages.com/packages/debugger84-zf2-graylog)
```

###  Alternatives

[monolog/monolog

Sends your logs to files, sockets, inboxes, databases and various web services

21.4k997.8M7.9k](/packages/monolog-monolog)[symfony/monolog-bundle

Symfony MonologBundle

2.9k258.2M1.7k](/packages/symfony-monolog-bundle)[sentry/sentry

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

1.9k240.0M315](/packages/sentry-sentry)[sentry/sentry-laravel

Laravel SDK for Sentry (https://sentry.io)

1.3k122.6M186](/packages/sentry-sentry-laravel)[sentry/sdk

This is a meta package of sentry/sentry. We recommend using sentry/sentry directly.

327137.6M163](/packages/sentry-sdk)[hedii/laravel-gelf-logger

A Laravel package to send logs to a gelf compatible backend like graylog

1353.6M11](/packages/hedii-laravel-gelf-logger)

PHPackages © 2026

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