splunk_handler icon indicating copy to clipboard operation
splunk_handler copied to clipboard

handleError when Splunk server is unresponsive

Open gmontamat opened this issue 6 years ago • 1 comments

When you log anything using this handler and the Splunk server is down or unreachable, an Exception is raised and has to be handled properly instead of just printing the traceback.

logging.raiseExceptions = False doesn't change this behavior if I need to ignore these errors.

For example, when I disconnect from the VPN with access to the Splunk server, set raiseExceptions to False and run my code I get:

[SplunkHandler] Exception in Splunk logging handler: HTTPSConnectionPool(host='<hidden>', port=8088): Max retries exceeded with url: /services/collector (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fb476f32048>: Failed to establish a new connection: [Errno -2] Name or service not known',))

I'd use the logging.Handler.handleError method if possible in the emit method.

gmontamat avatar Jul 24 '18 18:07 gmontamat

I found this thread to be very helpful https://stackoverflow.com/questions/35152435/how-to-ignore-the-exception-which-are-generated-during-the-logging-in-python

gmontamat avatar Jul 24 '18 18:07 gmontamat