Skip to main content

SysLogHandler with TLS

Project description

Python logging.handler as a drop-in replacement for logging.SysLogHandler with support for sending syslog messages over TCP with TLS.

Installation

pip install tlssysloghandler

Usage

import logging
from tlssysloghandler import TLSSysLogHandler

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

# with default system certificate store
handler1 = TLSSysLogHandler(address=('secure-logging.example.com', 6514),
                            socktype=socket.SOCK_STREAM,
                            secure=True)
logger.addHandler(handler1)

# with custom certificates, via cafile/capath/cadata
# refer to https://docs.python.org/3/library/ssl.html#ssl.create_default_context
handler2 = TLSSysLogHandler(address=('secure-logging.example.com', 6514),
                            socktype=socket.SOCK_STREAM,
                            secure={cafile='/path/to/ca/file'})
logger.addHandler(handler2)

# with custom SSLContext (e.g. for mutual TLS authentication)
context = ssl.create_default_context(
    purpose=ssl.Purpose.SERVER_AUTH, cafile="/path/to/ca/file"
)
context.load_cert_chain(
    certfile="/path/to/client/cert.pem",
    keyfile="/path/to/client/priv.key",
)
handler3 = TLSSysLogHandler(address=('secure-logging.example.com', 6514),
                            socktype=socket.SOCK_STREAM,
                            secure=context)
logger.addHandler(handler3)

# or allow TLS without verification (not recommended)
handler4 = TLSSysLogHandler(address=('secure-logging.example.com', 6514),
                            socktype=socket.SOCK_STREAM,
                            secure="noverify")
logger.addHandler(handler4)

logger.info('Hello, World!')

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

tlssysloghandler-2.0.0.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

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

tlssysloghandler-2.0.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file tlssysloghandler-2.0.0.tar.gz.

File metadata

  • Download URL: tlssysloghandler-2.0.0.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tlssysloghandler-2.0.0.tar.gz
Algorithm Hash digest
SHA256 ee7ed78f858001f096b99e1f118b2c75cf9de65f4a92c9b6a05cca8a44bb98b7
MD5 369e6cbb400e85df34b2e4ffd6dba35a
BLAKE2b-256 b3c0bedb495a9efd4941f3c1632d853868d8cd0455b8cc7d2607ff49c807c942

See more details on using hashes here.

Provenance

The following attestation bundles were made for tlssysloghandler-2.0.0.tar.gz:

Publisher: publish-pypi.yml on bsd-ac/tlssysloghandler

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tlssysloghandler-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for tlssysloghandler-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b4d3beffeb2cfc421f066f556b697a1ea74d42fda2d328f73fbebbdcb9b82c8c
MD5 1fd11db26b388e07cf88807bac8a79c9
BLAKE2b-256 997f1d6692f594199d3111d4935487c218f2a46a9d779dfd5a3f7195c6cca0ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for tlssysloghandler-2.0.0-py3-none-any.whl:

Publisher: publish-pypi.yml on bsd-ac/tlssysloghandler

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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