'Python Logger setLevel bug [duplicate]
I'm unable to set my logger to the correct level in python. According to this geeksforgeeks post, the following script should print all logging statements to the console, but it only prints the warning.
import logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
# Should pring everything
logger.debug("debug")
logger.info("info")
logger.warning("warning") # only prints this
but the output is only
warning
I am thoroughly confused, especially because my script was working as expected yesterday. Nothing in other similar posts has worked yet. Can anyone explain this odd behaviour?
Executed with Python version 3.9.5
Solution 1:[1]
You need to run logging.basicConfig() in order for logging to work correctly.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | matszwecja |
