Skip to content

Instantly share code, notes, and snippets.

@jesusch
Created March 14, 2020 19:59
Show Gist options
  • Save jesusch/6283670bbd294a0a16525c01a0253bd3 to your computer and use it in GitHub Desktop.
Save jesusch/6283670bbd294a0a16525c01a0253bd3 to your computer and use it in GitHub Desktop.
sample logging application
import logging
import sys
from logstash_async.handler import AsynchronousLogstashHandler
import time
host = 'localhost'
test_logger = logging.getLogger('python-logstash-logger')
test_logger.setLevel(logging.DEBUG)
test_logger.addHandler(logging.StreamHandler())
test_logger.addHandler(AsynchronousLogstashHandler(
host, port=1337, database_path='db.sqlite3', transport='logstash_async.transport.TcpTransport'))
if __name__ == '__main__':
i=0
while True:
test_logger.info('python-logstash-asnyc: %i', i)
time.sleep(1)
i = i+1
if i > 20: break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment