Python logging module is printing lines multiple times

后端 未结 4 710
南旧
南旧 2021-01-01 17:53

I have the following code:

import logging
class A(object):
    def __init__(self):
        self._l = self._get_logger()

    def _get_logger(self):
        l         


        
4条回答
  •  迷失自我
    2021-01-01 18:35

    Since python 3.2 and newer:

    Consider using hasHandlers() to check if a logger has handlers or not.

    https://docs.python.org/3/library/logging.html#logging.Logger.hasHandlers

提交回复
热议问题