Removing handlers from python's logging loggers

后端 未结 4 1898
礼貌的吻别
礼貌的吻别 2020-12-13 23:03

I am playing with Python\'s logging system. I have noticed a strange behavior while removing handlers from a Logger object in a loop. Namely, my for loop removes all but one

4条回答
  •  -上瘾入骨i
    2020-12-13 23:55

    I've just found out that you can also do that within a logging .ini file, with the following block:

    [logger_stpipe]
    handlers=
    propagate=1
    qualname=stpipe
    

    It basically deactivates all handlers for a given logger. But it's somewhat limited because you have to know the Logger's name in advance.

提交回复
热议问题