sethserver.com Subscribe
Python Logging: Why Logger Defaults to WARN and How to Change It

Python Logging: Why Logger Defaults to WARN and How to Change It

By Seth Black • Updated: December 22, 2025

Python · 1 min read

Like this kind of writing? Get one email a week with notes on startups, AI, and the occasional strong opinion about Python: subscribe to the newsletter.

When debugging and profiling Python software you'll find yourself relying on Python's built-in logging module. Something that is very simple to overlook is the fact that the root logger defaults to WARN and not DEBUG. Note the output of the simple logging statements below.

import logging
log = logging.getLogger(__name__)
log.debug('this is debug')
log.info('this is info')
log.warning('this is warning')
log.error('this is error')
log.critical('this is really bad')

$ python3 testlogging.py
this is warning
this is error
this is really bad

The root logger only prints out warnings, errors and criticalities. To increase the logging level set the logging.basicConfig to DEBUG.

import logging
logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger(__name__)
log.debug('this is debug')
log.info('this is info')
log.warning('this is warning')
log.error('this is error')
log.critical('this is really bad')

$ python3 testlogging.py
DEBUG:__main__:this is debug
INFO:__main__:this is info
WARNING:__main__:this is warn
ERROR:__main__:this is error
CRITICAL:__main__:this is really bad

You'll also notice that the basicConfig changes the log format to include the log message type and log name.

Good luck and happy logging!

-Sethers

Share this post
Newsletter

One email, once a week.

Notes on databases, systems, and the occasional strong opinion about Python. No spam, unsubscribe anytime.

Seth Black
Written by

Seth Black

Engineer and founder based in Texas. Writes about databases, AI, and running things in production. Embeds in small teams as lead engineer.

More from Python

View all →
Python

OpenAI Bought Astral - and my fav tool uv

Mar 23, 2026
Python

Python Pydantic Validation: Stop Writing Manual Checks

Mar 04, 2026
Python

Python asyncio Recipes

Mar 04, 2026