Package: rfc5424-logging-handler
An up-to-date,RFC 5424compliant syslog handler for the Python logging framework.Free software: BSD LicenseHomepage:https://github.com/jobec/rfc5424-logging-handlerDocumentation:http://rfc5424-logging-handler.readthedocs.org/FeaturesRFC 5424Compliant.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, …).InstallationPython package:pip install rfc5424-logging-handlerUsageAfter installing you can use this package like this:importloggingfromrfc5424loggingimportRfc5424SysLogHandlerlogger=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 messageNote the UTF8 Byte order mark (BOM) preceding the message. While required byRFC 5424 section 6.4if 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 themsg_as_utf8parameter toFalselike this:sh=Rfc5424SysLogHandler(address=('10.0.0.1',514),msg_as_utf8=False)For more examples, have a look at thedocumentationChangelog1.4.3- 2019/05/19Changed#34Allow enterprise ID to contain sub-identifiers.Fixed#31Correct handling of failed connection attempt in TCP transport handler.1.4.2- 2019/04/08Changed#32addresscan now also be a list, making loading settings form a config file possible.AddedPython 3.7 tests and support.1.4.1- 2019/02/16Fixed#29Fix AttributeError when using TLS connection.1.4.0- 2019/01/30Added#27Make it possible to log to streams as an alternate transport.Added API documentation.ChangedSyslog facilities and framing options have moved from theRfcSysLogHandlerclass
to module level variables.You may have to adjust your references to them.1.3.0- 2018/10/19Added#23Add support for TLS/SSL1.2.1- 2018/09/21Fixed#21Registered structured data IDs where also suffixed with an enterprise ID.Added#22Addutc_timestampparameter to allow logging in UTC time.1.1.2- 2018/02/03Fixed#15When logging to/dev/logwith python 2.7, the connection was permanently lost when the local syslog server
was restarted.#16Theextrainfo of a message did not overwrite that of the logging adapter instance.1.1.1- 2017/12/08Fixed#14Fixed handling ofextraparameter in logging adapter.1.1.0- 2017/11/24AddedThemsgparameter for the logger handler can now be absent allowing “structured data only” messages.FixedCorrect the automatic value of thehostnamewhen the value is anything other thenNILVALUEThe syslog message is now empty in conformance with RFC5424 when it’s value isNoneor an empty string.1.0.3- 2017/10/08No functional changes. Only documentation was changed.AddedLogstash configuration example for RFC5424.ChangedMoved most of the documentation out of the readme file.1.0.2- 2017/08/31FixedPackage description rendering on PyPi due to bugpypa/wheel#1891.0.1- 2017/08/30Added#12: It’s now possible to send syslog messages asMSG-ANYwhich suppresses the UTF-8 byte order mark (BOM) when sending messages.1.0.0- 2017/05/30Changed#10: Procid, appname and hostname can now be set per message, both with the handler as well as with the adapterNoteThis release has a slight change in behaviour. Setting one of the appnama, hostname of procid message to None or an
empty string will cause it to be filled in automatically. Previously, setting it to an empty string caused it to
be set to NILVALUE (a - ). You now need to set it explicilty to NILVALUE if you want to omit it from the message.0.2.0- 2017/01/27FixedBetter input handlingBetter sanitizing of invalid input0.1.0- 2017/01/22Added#4: Adapter class to make it easier to log message IDs or structured dataLogging of EMERGENCY, ALERT and NOTICE syslog levels by using the adapter classExtensive test suite0.0.2- 2017/01/18Added#5Introduced Python 2.7 compatibility0.0.1 - 2017/01/11Initial release