Python Logging Levels Reference

Python logging level names, numeric values and when to use each level.

Reference for the Python logging module severity levels — DEBUG, INFO, WARNING, ERROR, CRITICAL — with their numeric values, NOTSET semantics and a live threshold filter showing which records each setLevel emits.

What are the numeric values of Python logging levels?

NOTSET is 0, DEBUG is 10, INFO is 20, WARNING is 30, ERROR is 40 and CRITICAL is 50. They are spaced by 10 so you can insert custom levels in between, such as 15 or 25.

Python’s five standard logging severities

The Python standard-library logging module defines five named severity levels plus the NOTSET sentinel. Each level maps to an integer, and a record is only emitted when its value clears the threshold configured with setLevel. This reference lists every level, its numeric value and when to reach for it, and a live filter shows exactly which records a chosen threshold will let through.

How it works

Every log record carries a numeric levelno. When you call log.info(...), the record is created with value 20. The record is emitted only if its value is greater than or equal to the logger’s effective level — and then again only if it clears each attached handler’s own level. Because the named levels are spaced by 10, you can register intermediate custom levels:

import logging
TRACE = 15
logging.addLevelName(TRACE, "TRACE")
logging.getLogger().setLevel(TRACE)  # now DEBUG is hidden but TRACE shows

The root logger defaults to WARNING, so DEBUG and INFO are dropped until you lower the threshold via logging.basicConfig(level=logging.DEBUG).

Tips and notes

  • Use WARNING and above for anything an operator needs to see; reserve DEBUG for local tracing and turn it off in production.
  • exc_info=True on error/exception calls attaches the active traceback.
  • Setting a logger to NOTSET makes it inherit its parent — handy for opting a noisy library logger back into the application’s global level.
  • Handler and logger levels are independent gates; a DEBUG logger with an INFO handler still drops DEBUG output at the handler.