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
- id: C1 claim: The default logging level is WARNING. source: S1 evidence: "The default level is `
WARNING`, which means that only events of this"
- id: C2 claim: The HOWTO shows getLogger(__name__). source: S1 evidence: "logger = logging.getLogger(__name__)"
- id: C3 claim: PEP 282 orders levels by importance. source: S2 evidence: "The logging levels, in increasing order of importance, are:"
Sources
- [S1] Logging HOWTO. Python docs. https://docs.python.org/3/howto/logging.html . License: PSF-2.0. Accessed 2026-11-16.
- [S2] PEP 282 – A Logging System. Python Enhancement Proposals. https://peps.python.org/pep-0282/ . License: Public domain. Accessed 2026-11-16.
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
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.},
}
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.