A php implementation to send log-files to a gelf compatible backend like Graylog2.
This library conforms to the PSR standards in regards to structure (4),
and logging (3).
It's a loosely based on the original Graylog2 gelf-php
and mlehner's fork.
Stable release and deprecation of the original graylog2/gelf-php
This implementation became the official PHP GELF library on 2013-12-19 and is now released as
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:
After running an additional
Recommended installation via composer:
composer update everything should work as expected.
Add gelf-php to
composer.json either by running
composer require graylog2/gelf-php or by defining it manually:
For usage examples, go to /examples.
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
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
The library is licensed under the MIT license. For details check out the LICENSE file.
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) or message me on freenode#graylog2.
- composer, preferably a system-wide installation as
- Optional: PHP_CodeSniffer for PSR-X-compatibility checks
- Clone repository and cd into it:
git clone email@example.com:bzikarsky/gelf-php && cd gelf-php
- Install dependencies:
- Run unit-tests:
- Check PSR compatibility:
vendor/bin/phpcs --standard=PSR2 src tests examples