Skip to main content
Documentation Status https://img.shields.io/pypi/v/rfc5424-logging-handler.svg https://img.shields.io/pypi/pyversions/rfc5424-logging-handler.svg https://travis-ci.org/jobec/rfc5424-logging-handler.svg?branch=master https://codecov.io/github/jobec/rfc5424-logging-handler/coverage.svg?branch=master

An up-to-date, RFC 5424 compliant syslog handler for the Python logging framework.

Features

  • RFC 5424 Compliant.

  • Python Logging adapter for easier sending of rfc5424 specific fields.

  • No need for complicated formatting strings.

  • TLS/SSL syslog support.

  • Alternate transports like streams (ex. stderr, stdout, file, …).

Installation

Python package:

pip install rfc5424-logging-handler

Usage

After installing you can use this package like this:

import logging
from rfc5424logging import Rfc5424SysLogHandler

logger = logging.getLogger('syslogtest')
logger.setLevel(logging.INFO)

sh = Rfc5424SysLogHandler(address=('10.0.0.1', 514))
logger.addHandler(sh)

logger.info('This is an interesting message', extra={'msgid': 'some_unique_msgid'})

This will send the following message to the syslog server:

<14>1 2020-01-01T05:10:20.841485+01:00 myserver syslogtest 5252 some_unique_msgid - \xef\xbb\xbfThis is an interesting message

Note the UTF8 Byte order mark (BOM) preceding the message. While required by RFC 5424 section 6.4 if the message is known to be UTF-8 encoded, there are still syslog receivers that cannot handle it. To bypass this limitation, when initializing the handler Class, set the msg_as_utf8 parameter to False like this:

sh = Rfc5424SysLogHandler(address=('10.0.0.1', 514), msg_as_utf8=False)

For more examples, have a look at the documentation

Changelog

1.4.3 - 2019/05/19

Changed

  • #34 Allow enterprise ID to contain sub-identifiers.

Fixed

  • #31 Correct handling of failed connection attempt in TCP transport handler.

1.4.2 - 2019/04/08

Changed

  • #32 address can now also be a list, making loading settings form a config file possible.

Added

  • Python 3.7 tests and support.

1.4.1 - 2019/02/16

Fixed

  • #29 Fix AttributeError when using TLS connection.

1.4.0 - 2019/01/30

Added

  • #27 Make it possible to log to streams as an alternate transport.

  • Added API documentation.

Changed

  • Syslog facilities and framing options have moved from the RfcSysLogHandler class to module level variables. You may have to adjust your references to them.

1.3.0 - 2018/10/19

Added

  • #23 Add support for TLS/SSL

1.2.1 - 2018/09/21

Fixed

  • #21 Registered structured data IDs where also suffixed with an enterprise ID.

Added

  • #22 Add utc_timestamp parameter to allow logging in UTC time.

1.1.2 - 2018/02/03

Fixed

  • #15 When logging to /dev/log with python 2.7, the connection was permanently lost when the local syslog server was restarted.

  • #16 The extra info of a message did not overwrite that of the logging adapter instance.

1.1.1 - 2017/12/08

Fixed

  • #14 Fixed handling of extra parameter in logging adapter.

1.1.0 - 2017/11/24

Added

  • The msg parameter for the logger handler can now be absent allowing “structured data only” messages.

Fixed

  • Correct the automatic value of the hostname when the value is anything other then NILVALUE

  • The syslog message is now empty in conformance with RFC5424 when it’s value is None or an empty string.

1.0.3 - 2017/10/08

No functional changes. Only documentation was changed.

Added

  • Logstash configuration example for RFC5424.

Changed

  • Moved most of the documentation out of the readme file.

1.0.2 - 2017/08/31

Fixed

1.0.1 - 2017/08/30

Added

  • #12: It’s now possible to send syslog messages as MSG-ANY which suppresses the UTF-8 byte order mark (BOM) when sending messages.

1.0.0 - 2017/05/30

Changed

  • #10: Procid, appname and hostname can now be set per message, both with the handler as well as with the adapter

0.2.0 - 2017/01/27

Fixed

  • Better input handling

  • Better sanitizing of invalid input

0.1.0 - 2017/01/22

Added

  • #4: Adapter class to make it easier to log message IDs or structured data

  • Logging of EMERGENCY, ALERT and NOTICE syslog levels by using the adapter class

  • Extensive test suite

0.0.2 - 2017/01/18

Added

  • #5 Introduced Python 2.7 compatibility

0.0.1 - 2017/01/11

  • Initial release

Metadata

Release files for rfc5424-logging-handler 1.4.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rfc5424-logging-handler 1.4.3
File Size Uploaded
rfc5424-logging-handler-1.4.3.tar.gz 16.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rfc5424-logging-handler 1.4.3
File Interpreter ABI Platform
rfc5424_logging_handler-1.4.3-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 31.7 kB

Release files / rfc5424-logging-handler-1.4.3.tar.gz

Download URL rfc5424-logging-handler-1.4.3.tar.gz
Size 16.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9ae14073ef6d76d0c730ad6b6e3aeece841a6d413672d282876c0506dc097257
BLAKE2b-256 checksum
How to use checksums
038709dc32f7297408202b20aff1f68739330105307d3464c6e4d1d197e52810
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.6

Release files / rfc5424_logging_handler-1.4.3-py2.py3-none-any.whl

Download URL rfc5424_logging_handler-1.4.3-py2.py3-none-any.whl
Size 15.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
eaba528e47fba3e2845d52d559885cbc27a37db42a9d265ea539b3b4452d3057
BLAKE2b-256 checksum
How to use checksums
c545c4393bb4cff2c5ad9bd836139cb9e4b6c39e787ef8a0e0a3b85a942b6581
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.6

Release history Release notifications | RSS feed

This release

1.4.3 This release

2 release files

1.4.2

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.1

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page