-
Notifications
You must be signed in to change notification settings - Fork 136
/
example2.py
30 lines (25 loc) · 1006 Bytes
/
example2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import logging
import logstash
# AMQP parameters
host = 'localhost'
username = 'guest'
password= 'guest'
exchange = 'logstash.py'
# get a logger and set logging level
test_logger = logging.getLogger('python-logstash-logger')
test_logger.setLevel(logging.INFO)
# add the handler
test_logger.addHandler(logstash.AMQPLogstashHandler(version=1,
host=host,
durable=True,
username=username,
password=password,
exchange=exchange))
# log
test_logger.error('python-logstash: test logstash error message.')
test_logger.info('python-logstash: test logstash info message.')
test_logger.warning('python-logstash: test logstash warning message.')
try:
1/0
except:
test_logger.exception('python-logstash: test logstash exception with stack trace')