An up-to-date, RFC5424-Compliant syslog handler for the Python logging framework
Project description
An up-to-date, RFC 5424 compliant syslog handler for the Python logging framework.
Free software: BSD License
Documentation: http://rfc5424-logging-handler.readthedocs.org/
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.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
Package description rendering on PyPi due to bug pypa/wheel#189
1.0.1 - 2017/08/30
Added
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for rfc5424-logging-handler-1.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1dc2cecfd1f5b0a07e21bae6950c483abd7d6eb4beee866f76f753113ccc7a17 |
|
MD5 | 8e5d415a8ae65ac58a043a62da3cd2f1 |
|
BLAKE2b-256 | 60047aad7583f9f53d94704a1bfb4a9815097d25497ae87413c79bd896368ce7 |
Hashes for rfc5424_logging_handler-1.0.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51c1272b93740479cc4ca66ec32ef09dc94fd1bd2ffe4de5092a0123a29427d3 |
|
MD5 | c4a3c90a059e852a8ba9b0ddb6c9a6fc |
|
BLAKE2b-256 | 7014e2088cb4a69293766d77a3dc4dd9ef6c667ae6b1490af48db39d57e97fc7 |