python-logging-loki icon indicating copy to clipboard operation
python-logging-loki copied to clipboard

Should only use log level higher than DEBUG with the handlers

Open pchng opened this issue 3 years ago • 2 comments

The instructions should state that setLevel() should be called on the handlers (LokiHandler, LokiQueueHandler) with a level higher than DEBUG.

The reason is that the handlers eventually call/use code in urllib3, (to send the log messages to the Loki API) which itself generates log DEBUG messages. If the log handler processes these messages, it results in additional calls to the urllib3 code, which generates further log messages ad infinitum, potentially causing an infinite loop of log messages if the Python process is not terminated.

Ideally the handler should ignore log messages from any code it directly or indirectly calls, but for now you should always use setLevel() with something higher than logging.DEBUG on the handler.

pchng avatar Apr 20 '21 05:04 pchng

you lose a little bit of functionality, but i got around this by setting urllib3 to just above debug logging.getLogger('urllib3').setLevel(logging.INFO)

TheRealNoob avatar Jun 12 '21 16:06 TheRealNoob

Any updates on this issue?

abinba avatar Feb 02 '23 13:02 abinba