When using the python logger, my program starts fine with logging but at some point the log output starts outputting lines twice, looking like this:
DEBUG:pluginbrowser:Scanning plugs
DEBUG:pluginbrowser:Doing good stuff
....
INFO:pluginbrowser:=== doing something ===
=== doing something ===
Currently all my python files contain the line
LOGGER = logging.getLogger(__name__)
LOGGER.setLevel(logging.DEBUG)
Thus, the doubled message comes from the pluginbrowser.py file. Examining this, I found out that at the beginning of my program, the same files output some log without double-ing the lines. I tried to find out at which point exactly it happens but I am somehow stuck here.
I also read log messages appearing twice with Python Logging but I am not using configure_logging
at all.
Looks like you add an additional handler somewhere along the way. I would search for addHandler in the code. You could also debug and watch logger.root.handlers
This is how I could reproduce your effects:
In [1]: import logging
In [2]: logging.basicConfig(level=logging.DEBUG)
In [3]: logger = logging.getLogger('pluginbrowser')
In [4]: logger.info('=== doing something ===')
INFO:pluginbrowser:=== doing something ===
In [5]: logging.root.addHandler(logging.StreamHandler())
In [6]: logger.info('=== doing something ===')
INFO:pluginbrowser:=== doing something ===
=== doing something ===
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.