Skip to content
lennartkoopmann edited this page Jul 29, 2012 · 13 revisions
<?php

require('GELFMessage.php');
require('GELFMessagePublisher.php');

$message = new GELFMessage();
$message->setShortMessage('something is broken.');
$message->setFullMessage("lol full message!");
$message->setHost('somehost'); // Set a host or application name.
$message->setLevel(GELFMessage::CRITICAL); // According to syslog levels.
$message->setFacility('some-facility'); // Any String or an Integer according to syslog facility
                           // numbers (You can set and overwrite facility names in the web interface)
                           // Example: $message->setFacility("some-backend");
$message->setFile('/var/www/example.php');
$message->setLine(1337);
$message->setAdditional("something", "foo");
$message->setAdditional("something_else", "bar");

$publisher = new GELFMessagePublisher('127.0.0.1', 12201); // Third parameter is optional: 'LAN', 'WAN' or custom
                                                           // chunk size. Defines size (byte) of chunks. Set to
                                                           // to 'WAN' if sending over Internet. 'WAN' is standard
                                                           // if nothing is set.

$publisher->publish($message);

Short message and host are the only required fields, everything else is optional.

Clone this wiki locally