Created
March 14, 2020 19:59
-
-
Save jesusch/6283670bbd294a0a16525c01a0253bd3 to your computer and use it in GitHub Desktop.
sample logging application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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