Python logging logstash handler
Project description
sag_py_logging_logstash
Python Logstash Async is an asynchronous Python logging handler to submit log events to a remote Logstash instance. It based on open source library, see the documentation http://python-logstash-async.readthedocs.io/en/latest/. In this version transporter is limited to HTTPTransport, according to Logstash intern installation requirements.
Unlike most other Python Logstash logging handlers, this package works asynchronously by collecting log events from Python's logging subsystem and then transmitting the collected events in a separate worker thread to Logstash. This way, the main application (or thread) where the log event occurred, doesn't need to wait until the submission to the remote Logstash instance succeeded.
This is especially useful for applications like websites or web services or any kind of request serving API where response times matter.
Usage
Example::
from logstash_async.handler import AsynchronousLogstashHandler
from logstash_async.formatter import LogstashFormatter
import logging
logstash_handler = AsynchronousLogstashHandler(
host='my_host',
port=123,
username='my_user',
password='my_password',
index_name = 'my_index')
logstash_formatter = LogstashFormatter( extra_prefix='',
extra={'customer': "name", 'ap_environment': "local"})
logstash_handler.setFormatter(logstash_formatter)
logging_handlers = []
logging_handlers.append(logstash_handler)
logging.basicConfig(
level="INFO",
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=logging_handlers)
logging.getLogger().info("Logging Message", extra = {'new_field':"value"})
Local Installation
pip install sag_py_logging_logstash
How to publish
- Update the version in setup.py and commit your change
- Create a tag with the same version number
- Let github do the rest
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
Built Distribution
Hashes for sag-py-logging-logstash-2.3.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c4aeb33873d3b20fe108d1224aa9c42d13f3e75d882e213fa5c77710f4f8695 |
|
MD5 | 4abab6e9847a7eab76218246f824900a |
|
BLAKE2b-256 | 974b052ac9b54976993699f93902d4be1caf9b82628717868169c720d597315e |
Hashes for sag_py_logging_logstash-2.3.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 648075704f2ce286d0c77f3532ad03ef2cd3539c6d489246ba0fe65d917b2fb7 |
|
MD5 | d14573c9450b745dc63771c6a83d263a |
|
BLAKE2b-256 | ce08c26d2175627ad2679d070bf02c0f525ec1cf70c929a74e71da255d4a9fd1 |