← All notes

Python logging defaults to WARNING and uses named loggers

Answer: Access logging functionality by creating a logger via logger = logging.getLogger(__name__). The logging module's default level is WARNING, so events below that severity are not tracked unless logging is configured.

Default output

A simple script can call logging.warning() to print to the console. In that same default setup, an INFO message does not appear. A basicConfig(filename='example.log', encoding='utf-8', level=logging.DEBUG) call sends messages to a log file.

Levels

PEP 282 lists logging levels in increasing order: DEBUG, INFO, WARN, ERROR and CRITICAL. CRITICAL is used in preference to FATAL because the logging module does not enforce an exit outcome.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python docs, Logging HOWTO, PSF-2.0 (https://raw.githubusercontent.com/python/cpython/main/LICENSE); Python Enhancement Proposals, PEP 282 – A Logging System, Public domain (https://peps.python.org/pep-0282/#copyright). Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python docs, Logging HOWTO, PSF-2.0 (https://raw.githubusercontent.com/python/cpython/main/LICENSE); Python Enhancement Proposals, PEP 282 – A Logging System, Public domain (https://peps.python.org/pep-0282/#copyright).

Cite this

Permanent ID: iil:note:3e22bpza

iinventedlight. 2026. "Python logging defaults to WARNING and uses named loggers." iinventedlight Library, iil:note:3e22bpza, version of 2026-11-16. https://iinventedlight.com/library/notes/python-logging-basics/. License: CC-BY-4.0.

@misc{iil_note_3e22bpza,
  author = {{iinventedlight}},
  title = {{Python logging defaults to WARNING and uses named loggers}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-16},
  url = {https://iinventedlight.com/library/notes/python-logging-basics/},
  note = {Permanent ID iil:note:3e22bpza. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-logging-basics.md.