What Could Cause The Logging Module To Log A Record Multiple Times?
I have a multi-threaded Python application that makes use of the built in logging module. To control the logging levels and make it easier to swap the StreamHandler with a FileHan
Solution 1:
My guess is that you've got multiple handlers (ie, one message is being emitted multiple times; but on re-reading your question, it looks like you already knew that). To debug that, try:
- Looking at
logging.getLogger("").handlers
(ie, the handlers on the root logger) - Checking your calls to
addHandler()
- Brandon Rhode's
logging_tree
module - Use
pdb
to trace a log message's lifecycle (ie, put a breakpoint just before a call toself._logger.info(…)
, then step into that function).
Post a Comment for "What Could Cause The Logging Module To Log A Record Multiple Times?"