https://github.com/jobec/rfc5424-logging-handler
An RFC5424-Compliant Syslog Handler for the Python Logging Framework
https://github.com/jobec/rfc5424-logging-handler
logging python rfc-5424 rfc5424 syslog
Last synced: 2 months ago
JSON representation
An RFC5424-Compliant Syslog Handler for the Python Logging Framework
- Host: GitHub
- URL: https://github.com/jobec/rfc5424-logging-handler
- Owner: jobec
- License: bsd-3-clause
- Created: 2017-01-09T21:12:33.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-05-18T14:31:02.000Z (almost 3 years ago)
- Last Synced: 2025-10-24T07:45:24.809Z (6 months ago)
- Topics: logging, python, rfc-5424, rfc5424, syslog
- Language: Python
- Size: 123 KB
- Stars: 50
- Watchers: 7
- Forks: 23
- Open Issues: 14
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.rst
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
Python rfc5424 syslog logging handler
=====================================
.. image:: https://readthedocs.org/projects/rfc5424-logging-handler/badge/?version=latest
:target: https://rfc5424-logging-handler.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
.. image:: https://img.shields.io/pypi/v/rfc5424-logging-handler.svg
:target: https://pypi.python.org/pypi/rfc5424-logging-handler
.. image:: https://img.shields.io/pypi/pyversions/rfc5424-logging-handler.svg
:target: https://pypi.python.org/pypi/rfc5424-logging-handler#downloads
.. image:: https://travis-ci.org/jobec/rfc5424-logging-handler.svg?branch=master
:target: https://travis-ci.org/jobec/rfc5424-logging-handler
.. image:: https://codecov.io/github/jobec/rfc5424-logging-handler/coverage.svg?branch=master
:target: https://codecov.io/github/jobec/rfc5424-logging-handler?branch=master
An up-to-date, `RFC 5424 `_ compliant syslog handler for the Python logging framework.
* Free software: BSD License
* Homepage: https://github.com/jobec/rfc5424-logging-handler
* 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.
* 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:
.. code-block:: python
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:
.. code-block:: python
sh = Rfc5424SysLogHandler(address=('10.0.0.1', 514), msg_as_utf8=False)
For more examples, have a look at the `documentation `_