Skip to main content

An up-to-date, RFC5424-Compliant syslog handler for the Python logging framework

Project description

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.

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.1.2 - 2017/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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rfc5424-logging-handler-1.1.2.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rfc5424_logging_handler-1.1.2-py2.py3-none-any.whl (13.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file rfc5424-logging-handler-1.1.2.tar.gz.

File metadata

File hashes

Hashes for rfc5424-logging-handler-1.1.2.tar.gz
Algorithm Hash digest
SHA256 a78a0a42b19e44215cd8a5be4ab42bfd3593c0c30a9cbfde9478e398f502ea00
MD5 6292ea5f6f39576a075adb43a467b6f6
BLAKE2b-256 6da272ecd1e945fa973ccaa394b9e9f97e8d9e46a8b95dac1fbb3d8abd3ba6d7

See more details on using hashes here.

File details

Details for the file rfc5424_logging_handler-1.1.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for rfc5424_logging_handler-1.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 0fa181ba9ef4b517c938c90608f4c3a5c1abf3ea29250f0df294bef439ba2c9e
MD5 11d032be39dba39226bb4dd42cfa0263
BLAKE2b-256 51097ad17d735bac63efec3945e5e010a58b9800114bdd5e59cb3d677361e6a6

See more details on using hashes here.

Supported by

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