class Poco::Net::RemoteSyslogChannel

Overview

This Channel implements remote syslog logging over UDP according to RFC 5424 “The Syslog Protocol” and RFC 5426 “Transmission of syslog messages over UDP”. More…

#include <RemoteSyslogChannel.h>

class RemoteSyslogChannel: public Poco::Channel
{
public:
    // enums

    enum
    {
        SYSLOG_PORT = 514,
    };

    enum Facility;
    enum Severity;

    // fields

    static const std::string BSD_TIMEFORMAT;
    static const std::string SYSLOG_TIMEFORMAT;
    static const std::string PROP_NAME;
    static const std::string PROP_FACILITY;
    static const std::string PROP_FORMAT;
    static const std::string PROP_LOGHOST;
    static const std::string PROP_HOST;

    // construction

    RemoteSyslogChannel();

    RemoteSyslogChannel(
        const std::string& address,
        const std::string& name,
        int facility = SYSLOG_USER,
        bool bsdFormat = false
        );

    // methods

    virtual
    void
    open();

    virtual
    void
    close();

    virtual
    void
    log(const Message& msg);

    virtual
    void
    setProperty(
        const std::string& name,
        const std::string& value
        );

    virtual
    std::string
    getProperty(const std::string& name) const;

    static
    void
    registerChannel();

protected:
    // methods

    static
    int
    getPrio(const Message& msg);
};

Inherited Members

public:
    // methods

    virtual
    void
    setProperty(
        const std::string& name,
        const std::string& value
        ) = 0;

    virtual
    std::string
    getProperty(const std::string& name) const = 0;

    void
    duplicate() const;

    void
    release() const;

    int
    referenceCount() const;

    virtual
    void
    open();

    virtual
    void
    close();

    virtual
    void
    log(const Message& msg) = 0;

    virtual
    void
    setProperty(
        const std::string& name,
        const std::string& value
        );

    virtual
    std::string
    getProperty(const std::string& name) const;

Detailed Documentation

This Channel implements remote syslog logging over UDP according to RFC 5424 “The Syslog Protocol” and RFC 5426 “Transmission of syslog messages over UDP”.

In addition, RemoteSyslogListener also supports the “old” BSD syslog protocol, as described in RFC 3164.

Construction

RemoteSyslogChannel()

Creates a RemoteSyslogChannel.

RemoteSyslogChannel(
    const std::string& address,
    const std::string& name,
    int facility = SYSLOG_USER,
    bool bsdFormat = false
    )

Creates a RemoteSyslogChannel with the given target address, name, and facility.

If bsdFormat is true, messages are formatted according to RFC 3164.

Methods

virtual
void
open()

Opens the RemoteSyslogChannel.

virtual
void
close()

Closes the RemoteSyslogChannel.

virtual
void
log(const Message& msg)

Sends the message’s text to the syslog service.

virtual
void
setProperty(
    const std::string& name,
    const std::string& value
    )

Sets the property with the given value.

The following properties are supported:

* name:      The name used to identify the source of log messages.
* facility:  The facility added to each log message. See the Facility enumeration for a list of supported values.
             The LOG_ prefix can be omitted and values are case insensitive (e.g. a facility value "mail" is recognized as SYSLOG_MAIL)
* format:    "bsd"/"rfc3164" (RFC 3164 format) or "new"/"rfc5424" (default)
* loghost:   The target IP address or host name where log messages are sent. Optionally, a port number (separated
             by a colon) can also be specified.
* host:      (optional) Host name included in syslog messages. If not specified, the host's real domain name or
             IP address will be used.
virtual
std::string
getProperty(const std::string& name) const

Returns the value of the property with the given name.

static
void
registerChannel()

Registers the channel with the global LoggingFactory.