GreyZmeem / python-logging-loki

Python logging handler for Loki
MIT License
151 stars 57 forks source link

Should only use log level higher than DEBUG with the handlers #18

Open pchng opened 3 years ago

pchng commented 3 years ago

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.

TheRealNoob commented 3 years ago

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)

abinba commented 1 year ago

Any updates on this issue?