dobryak / phpsyslognet
PHP Syslog client that conforms to the RFC5424 syslog standard and supports TCP/UDP transports
v1.0.0
2020-11-28 13:38 UTC
Requires
- php: ^5.6
- ext-ctype: *
- ext-mbstring: *
- ext-sockets: *
Requires (Dev)
- phpunit/phpunit: ^5.7
This package is not auto-updated.
Last update: 2024-10-18 04:21:46 UTC
README
PHP syslog clinet that conforms to the RFC 5424 syslog standard and supports UDP and TCP transports as well as UNIX domain sockets.
USAGE
Simple way:
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');
Advanced way:
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);