You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I added "try... except..." to example1.py of this repo as following:
import logging
import logstash
import sys
host = 'localhost'
try:
test_logger = logging.getLogger('python-logstash-logger')
test_logger.setLevel(logging.INFO)
# test_logger.addHandler(logstash.LogstashHandler(host, 5959, version=1))
test_logger.addHandler(logstash.TCPLogstashHandler(host, 5959, version=1))
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.')
# add extra field to logstash message
extra = {
'test_string': 'python version: ' + repr(sys.version_info),
'test_boolean': True,
'test_dict': {'a': 1, 'b': 'c'},
'test_float': 1.23,
'test_integer': 123,
'test_list': [1, 2, '3'],
}
test_logger.info('python-logstash: test extra fields', extra=extra)
print('Succeed to save event.')
except Exception as e:
print('Failed to save event: ',e)
Even though no Logstash on my localhost, it will say "Succeed to save event", I am wondering how to add error handling of writing to Logstash with TCPLogstashHandler. Thanks.
The text was updated successfully, but these errors were encountered:
XuejiaoZhang
changed the title
Error Handling of writing to Logstash
Error Handling of TCPLogstashHandler writing to Logstash
Dec 27, 2020
@wizardion Would you please give us some hints on this? Thanks in advance!
XuejiaoZhang
changed the title
Error Handling of TCPLogstashHandler writing to Logstash
Error Handling of TCPLogstashHandler When Writing to Logstash
Dec 28, 2020
in my case, i wrote wrong address for logstash, but i didn't notice any sign of error. (eventually i found my mistake)
but still need some error messages if not correctly working everything.
I added "try... except..." to example1.py of this repo as following:
Even though no Logstash on my localhost, it will say "Succeed to save event", I am wondering how to add error handling of writing to Logstash with TCPLogstashHandler. Thanks.
The text was updated successfully, but these errors were encountered: