PHP code example of mlehner / gelf-php

1. Go to this page and download the library: Download mlehner/gelf-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mlehner / gelf-php example snippets


// Create a Message and set your logging information.
$message = new Message();
$message->setFullMessage('Your full log mesage');
$message->setHost('example.com');
$message->setLevel(3); // List of supported levels: http://en.wikipedia.org/wiki/Syslog#Severity_levels
$message->setShortMessage('Short message');
$message->setTimestamp(time());
$message->setVersion('1.2.3');
// The following values are deprecated and will be transferred as additionals.
$message->setFile('foo.php');
$message->setLine(42);
$message->setFacility('server42');

// Create a Publisher and send the message to your GELF server.
// Beware: Hostnames need a DNS lookup, which might be slow!
$publisher = new MessagePublisher('192.168.99.99');
$publisher->publish($message);
bash
$ php composer.phar