PHPackages                             lemon777/gelf-php - 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. lemon777/gelf-php

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

lemon777/gelf-php
=================

A php implementation to send log-messages to a GELF compatible backend like Graylog2.

1.6.2(7y ago)0766MITPHPPHP &gt;=5.3.9

Since Dec 19Pushed 6y ago1 watchersCompare

[ Source](https://github.com/lemon777/gelf-php)[ Packagist](https://packagist.org/packages/lemon777/gelf-php)[ RSS](/packages/lemon777-gelf-php/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (4)Versions (30)Used By (0)

gelf-php [![Latest Stable Version](https://camo.githubusercontent.com/df2d23418a03f4ae8679180f405530c3a22d012f2a7752e436221792ee32f120/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f677261796c6f67322f67656c662d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/graylog2/gelf-php) [![Total Downloads](https://camo.githubusercontent.com/7a2798916fc660e6fffb2d5248df05da49d6a14ea96f38599dc55218233567b5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f677261796c6f67322f67656c662d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/graylog2/gelf-php)
==================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#gelf-php--)

[![Build Status](https://camo.githubusercontent.com/de5f0b3e1adeaa111b0ba5d976c759fa4c06af7907a7b1599d8c27a26fc45906/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f636f6d2f627a696b6172736b792f67656c662d7068702e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.com/bzikarsky/gelf-php)[![Code Coverage](https://camo.githubusercontent.com/c24981a3267d31eeaa9147adca364ffee49ca112cd76d11515dbdceb366d8d4d/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f627a696b6172736b792f67656c662d7068702e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/bzikarsky/gelf-php/)[![Scrutinizer Quality Score](https://camo.githubusercontent.com/5e294d3f2407d2ba2f157addffd74b913d256a7a2c82f6a6ef8cdd7f27152e21/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f627a696b6172736b792f67656c662d7068702e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/bzikarsky/gelf-php/)

A php implementation to send log-files to a gelf compatible backend like [Graylog2](http://graylog2.org/). This library conforms to the PSR standards in regards to structure ([4](http://www.php-fig.org/psr/psr-4/)), coding-style ([1](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md), [2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)) and logging ([3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md)).

It's a loosely based on the original [Graylog2 gelf-php](https://github.com/Graylog2/gelf-php)and [mlehner's fork](https://github.com/mlehner/gelf-php).

Stable release and deprecation of the original graylog2/gelf-php
----------------------------------------------------------------

[](#stable-release-and-deprecation-of-the-original-graylog2gelf-php)

This implementation became the official PHP GELF library on 2013-12-19 and is now released as `graylog2/gelf-php`. The old library became deprecated at the same time and it's recommended to upgrade.

Since the deprecated library never got a stable release, we decided keep it available as `v0.1`. This means: If you have a project based on the deprecated library but no time to upgrade to version 1.0, we recommend to change your `composer.json` as following:

```
    "require": {
       // ...
       "graylog2/gelf-php": "0.1.*"
       // ...
    }

```

After running an additional `composer update` everything should work as expected.

Usage
-----

[](#usage)

### Recommended installation via composer:

[](#recommended-installation-via-composer)

Add gelf-php to `composer.json` either by running `composer require graylog2/gelf-php` or by defining it manually:

```
"require": {
   // ...
   "graylog2/gelf-php": "~1.5"
   // ...
}

```

Reinstall dependencies: `composer install`

### Examples

[](#examples)

For usage examples, go to [/examples](https://github.com/bzikarsky/gelf-php/tree/master/examples).

### Muting connection and transport errors

[](#muting-connection-and-transport-errors)

Oftentimes projects run into the situation where they don't want to raise exceptions for logging-errors. Since the standard transports like Udp, Tcp and Http can be kind of noise for fwrite/fopen errors, gelf-php provides a `IgnoreErrorTransportWrapper`. This class can decorate any `AbstractTransport` and will mute all exceptions.

How this applies in practice can be seen in the [advanced-example](https://github.com/bzikarsky/gelf-php/blob/master/examples/advanced.php#L18-L20).

If you use gelf-php in conjunction with monolog/symfony, the following snippet should help you with properly setting up your logging backend.

Assumung you have a typical monolog config:

```
monolog:
  handlers:
    graylog:
      type: service
      id: monolog.gelf_handler
      level: debug
```

You only need to properly define the symfony-service `gelf-handler`:

```
services:
  monolog.gelf_handler:
    class: Monolog\Handler\GelfHandler
    arguments: [@gelf.publisher]

  gelf.publisher:
    class: Gelf\Publisher
    arguments: [@gelf.ignore_error_transport]

  gelf.ignore_error_transport:
    class: Gelf\Transport\IgnoreErrorTransportWrapper
    arguments: [@gelf.transport]

  gelf.transport:
    class: Gelf\Transport\UdpTransport # or Tcp, Amp, Http,...
    arguments: [] # ... whatever is required
```

HHVM
----

[](#hhvm)

While HHVM is supported/tested, there are some restrictions to look out for:

- Stream-context support is very limited (as of 2014) - especially regarding SSL - many use-cases might not work as expected (or not at all...)
- `fwrite` does behave a little different

The failing unit-tests are skipped by default when running on HHVM. They are also all annotated with `@group hhvm-failures`. You can force to run those failures by setting `FORCE_HHVM_TESTS=1` in the environment. Therefore you can specifically check the state of HHVM failures by running:

```
FORCE_HHVM_TESTS=1 hhvm vendor/bin/phpunit --group hhvm-failures

```

License
-------

[](#license)

The library is licensed under the MIT license. For details check out the LICENSE file.

Development &amp; Contributing
------------------------------

[](#development--contributing)

You are welcome to modify, extend and bugfix all you like. :-) If you have any questions/proposals/etc. you can contact me on Twitter ([@bzikarsky](https://twitter.com/bzikarsky)) or message me on freenode#graylog2.

### Tools

[](#tools)

1. [composer](http://getcomposer.org), preferably a system-wide installation as `composer`
2. [PHPUnit](http://phpunit.de/manual/current/en/installation.html)
3. Optional: [PHP\_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) for PSR-X-compatibility checks

### Steps

[](#steps)

1. Clone repository and cd into it: `git clone git@github.com:bzikarsky/gelf-php && cd gelf-php`
2. Install dependencies: `composer install`
3. Run unit-tests: `vendor/bin/phpunit`
4. Check PSR compatibility: `vendor/bin/phpcs --standard=PSR2 src tests examples`

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor7

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

Recently: every ~135 days

Total

28

Last Release

2746d ago

Major Versions

0.1.x-dev → 1.0.02013-12-19

1.6.0 → 2.0.x-dev2018-10-31

PHP version history (4 changes)1.0.0PHP ~5.3

1.1.2PHP &gt;=5.3

1.2.1PHP &gt;=5.3.9

2.0.x-devPHP ^7.2

### Community

Maintainers

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

---

Top Contributors

[![steffkes](https://avatars.githubusercontent.com/u/325361?v=4)](https://github.com/steffkes "steffkes (5 commits)")[![carusogabriel](https://avatars.githubusercontent.com/u/16328050?v=4)](https://github.com/carusogabriel "carusogabriel (4 commits)")[![evaldaskocys](https://avatars.githubusercontent.com/u/8693654?v=4)](https://github.com/evaldaskocys "evaldaskocys (3 commits)")[![JeroenDeDauw](https://avatars.githubusercontent.com/u/146040?v=4)](https://github.com/JeroenDeDauw "JeroenDeDauw (3 commits)")[![lemon777](https://avatars.githubusercontent.com/u/12660092?v=4)](https://github.com/lemon777 "lemon777 (3 commits)")[![Seldaek](https://avatars.githubusercontent.com/u/183678?v=4)](https://github.com/Seldaek "Seldaek (3 commits)")[![bzikarsky](https://avatars.githubusercontent.com/u/225374?v=4)](https://github.com/bzikarsky "bzikarsky (3 commits)")[![mrjgreen](https://avatars.githubusercontent.com/u/2183391?v=4)](https://github.com/mrjgreen "mrjgreen (2 commits)")[![matthi4s](https://avatars.githubusercontent.com/u/8943286?v=4)](https://github.com/matthi4s "matthi4s (2 commits)")[![toubsen](https://avatars.githubusercontent.com/u/553786?v=4)](https://github.com/toubsen "toubsen (2 commits)")[![pascalwild](https://avatars.githubusercontent.com/u/14974414?v=4)](https://github.com/pascalwild "pascalwild (2 commits)")[![dbu](https://avatars.githubusercontent.com/u/76576?v=4)](https://github.com/dbu "dbu (2 commits)")[![jacobkiers](https://avatars.githubusercontent.com/u/402504?v=4)](https://github.com/jacobkiers "jacobkiers (1 commits)")[![betweenbrain](https://avatars.githubusercontent.com/u/634119?v=4)](https://github.com/betweenbrain "betweenbrain (1 commits)")[![chrisminett](https://avatars.githubusercontent.com/u/1084019?v=4)](https://github.com/chrisminett "chrisminett (1 commits)")[![chrisnew](https://avatars.githubusercontent.com/u/994286?v=4)](https://github.com/chrisnew "chrisnew (1 commits)")[![Cosmologist](https://avatars.githubusercontent.com/u/966525?v=4)](https://github.com/Cosmologist "Cosmologist (1 commits)")[![Gummibeer](https://avatars.githubusercontent.com/u/6187884?v=4)](https://github.com/Gummibeer "Gummibeer (1 commits)")[![h4cc](https://avatars.githubusercontent.com/u/2981491?v=4)](https://github.com/h4cc "h4cc (1 commits)")[![afoeder](https://avatars.githubusercontent.com/u/1125168?v=4)](https://github.com/afoeder "afoeder (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/lemon777-gelf-php/health.svg)

```
[![Health](https://phpackages.com/badges/lemon777-gelf-php/health.svg)](https://phpackages.com/packages/lemon777-gelf-php)
```

###  Alternatives

[sentry/sentry

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

1.9k240.0M314](/packages/sentry-sentry)[web-auth/webauthn-lib

FIDO2/Webauthn Support For PHP

1237.8M120](/packages/web-auth-webauthn-lib)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[web-auth/webauthn-framework

FIDO2/Webauthn library for PHP and Symfony Bundle.

51090.8k2](/packages/web-auth-webauthn-framework)[illuminate/log

The Illuminate Log package.

6225.0M601](/packages/illuminate-log)[contao/core-bundle

Contao Open Source CMS

1231.6M2.7k](/packages/contao-core-bundle)

PHPackages © 2026

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