Author David Wang
Recipients David Wang
Date 2019-06-12.21:48:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
If you call setLevel() on a subclass of logging.Logger, it does not reset the cache for that logger. This mean that if you make some logging calls, then call setLevel(), the logger still acts like it still has its old level. See the attached python file for a reference.

Currently, the user has to call logger._cache.clear() to manually clear the cache after calling setLevel(). To fix this in Python, we would have to change Logger.setLevel() in /logging/ to have the following code
self.level = _checkLevel(level)

Note the following:
- I made sure the subclass has a handler attached so setLevel() should work
- This bug does not occur if you use logging.getLogger(). This is because logging.getLogger() returns the root logger, and the cache clear specifically targets the root logger's cache to be cleared. It occurs when the logger is specifically subclassed from logging.getLoggerClass()
- The cache was added in Python 3.7, so this bug is specific to this version of python.
Date User Action Args
2019-06-12 21:48:28David Wangsetrecipients: + David Wang
2019-06-12 21:48:28David Wangsetmessageid: <>
2019-06-12 21:48:28David Wanglinkissue37258 messages
2019-06-12 21:48:28David Wangcreate