weckx/

wcx-syslog

简单的 PHP Syslog 消息库

dev-master 2014-02-04 15:29 UTC

This package is not auto-updated.

Last update: 2024-09-28 14:27:48 UTC


README

提供简单的类,用于根据 RFC5424 或 RFC3164 将消息发送到任意 syslog 服务器。可以使用 TCP 或 UDP 发送消息。通过创建新的传输类进行扩展。

示例用法

//It's usually better to use the BSD format since it's widely supported
use Wcx\Syslog\Message\Bsd as SyslogMessage;

//Create the message
$message = new SyslogMessage();

//Set basic message values
$message->setPriority(SyslogMessage::PRIORITY_NOTICE)
        ->setFacility(SyslogMessage::FACILITY_USER)
        ->setAppName('wcx-syslog')
        ->setMsg('Test message');

//Send to host 192.168.0.1 using UDP
$message->send('192.168.0.1');

//Send to 10.0.0.1 on port 5140 using TCP
$message->send('10.0.0.1:5140', new Wcx\Syslog\Transport\Tcp());