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
{{ message }}
Repository navigation
Error Handling of TCPLogstashHandler When Writing to Logstash #93
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.
changed the title [-]Error Handling of TCPLogstashHandler writing to Logstash[/-][+]Error Handling of TCPLogstashHandler When Writing to Logstash[/+]on 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.
Activity
[-]Error Handling of writing to Logstash[/-][+]Error Handling of TCPLogstashHandler writing to Logstash[/+]XuejiaoZhang commentedon Dec 27, 2020
@wizardion Would you please give us some hints on this? Thanks in advance!
[-]Error Handling of TCPLogstashHandler writing to Logstash[/-][+]Error Handling of TCPLogstashHandler When Writing to Logstash[/+]jehos commentedon Feb 9, 2021
++1
@vklochan
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.
kevinn-1 commentedon Sep 28, 2022
This one is really important - we need to check whether or not the event was successfully received by Logstash.