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
context = ssl.create_default_context(cafile='/path/to/ca/file')
handler3 = TLSSysLogHandler(address=('secure-logging.example.com', 6514),
                            socktype=socket.SOCK_STREAM,
                            secure=context)
logger.addHandler(handler3)

# or allow TLS without verification
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-1.0.3.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

tlssysloghandler-1.0.3-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tlssysloghandler-1.0.3.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for tlssysloghandler-1.0.3.tar.gz
Algorithm Hash digest
SHA256 302c136a373a814d1cf8eb680b5772d3c98ebf2bdfe17f5b007c26b25dbb56a2
MD5 263f3b992ee55d698f9e9f76e6bf97a4
BLAKE2b-256 628c119d65539e4fba0df0a324fd097ae693e85216227e22a6bdf3de8dd71f11

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tlssysloghandler-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 79f846839df8bd1ccc0a5b42dbd53b4aa4b799c5ace4215fb016be4950c147b5
MD5 39ad67f268fbbe838e970573046a9530
BLAKE2b-256 36cc80bee485539f0bccce4d9a3b97062f22da4ba4a0f07ea0cf74de4db6f8de

See more details on using hashes here.

Supported by

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