Python › Logging
What are Python's five standard logging severity levels, from lowest to highest?
BeginnerAnswer
DEBUG (detailed diagnostic info), INFO (confirmation things work as expected), WARNING (something unexpected but not fatal), ERROR (a serious problem, functionality failed), and CRITICAL (a very serious error, program may be unable to continue). Each level has a numeric value, and a logger only emits messages at or above its configured threshold.
import logging
logging.basicConfig(level=logging.WARNING)
logging.debug('not shown')
logging.info('not shown')
logging.warning('shown') # WARNING:root:shown
logging.error('shown')Real-world example A deployment sets the root logger to WARNING in production to reduce noise, but switches to DEBUG temporarily when investigating a reported bug.