Skip to main content

Syslog client implementation (RFC 3164/RFC 5424)

Project description

pysyslogclient

Syslog client library for Python 2.7 / 3.x (UNIX/Windows) following

TCP and UDP as transport is possible. If TCP is used, on every log message, that is send to the specified server, and a connection error occured, the message will be dismissed and reconnect will be tried for the next message.

Usage

A small CLI client is implemented in cli.py. To call it, run

python -m pysyslogclient.cli

To setup the client for RFC 5424 over TCP to send to localhost on port 514:

>>> from pysyslogclient import *
>>> client = SyslogClientRFC5424("localhost", 514, proto="TCP")

or for RFC 3164:

>>> client = SyslogClientRFC3164("localhost", 514, proto="TCP")

Log the message “Hello syslog server” with standard severity INFO as facility USER. As program name SyslogClient the PID of the called python interpreter is used.

>>> client.log("Hello syslog server")

To specify more options, call log with more arguments. For example to log a the message as program Logger with PID 1 as facility SYSTEM with severity EMERGENCY, call log the following way:

>>> client.log("Hello syslog server", facility=FAC_SYSTEM, severity=SEV_EMERGENCY, program="Logger", pid=1)

To disconnect the client, call

>>> client.close()

Author

License

BSD 2-Clause

Repository

Project details


Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page