1. Go to this page and download the library: Download dobryak/phpsyslognet 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/ */
dobryak / phpsyslognet example snippets
use SyslogNet\SyslogNet;
use SyslogNet\Severity;
use SyslogNet\Facility;
use SyslogNet\Formatters\FormatterRFC5424;
use SyslogNet\Transports\Socket;
$syslog = new SyslogNet(
Socket::createUDP('127.0.0.1', 514),
new FormatterRFC5424(),
Facility::DAEMON,
'myService'
);
$syslog->send(Severity::CRIT, 'My test message');
use SyslogNet\SyslogNet;
use SyslogNet\Severity;
use SyslogNet\Transports\Socket;
use SyslogNet\StructuredDataElement;
$sys = new SyslogNet(Socket::createUDP('127.0.0.1', 514));
$message = $sys->createMessage(Severity::CRIT, 'My test message');
$message->setAppName('myService');
$message->setHostName('myHostName');
$message->setMsgId("m1");
$sd1 = new StructuredDataElement('id1');
$sd1['key1'] = 'value1';
$sd1['key2'] = 'value2';
$sd2 = new StructuredDataElement('id2');
$sd2['key1'] = 'value1';
$sd2['key2'] = 'value2';
$message->addSDElement($sd1);
$message->addSDElement($sd2);
$sys->sendMessage($message);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.