taz taz - 9 months ago 63
Python Question

Log disabling in python

I am new to this logging module.

logging.disable = True

As per my understanding this should disable debug logs. But when it is executed it prints debug logs also.

I have only debug logs to print. I dont have critical or info logs. So how i can disable this debug logs.

Answer Source

logging.disable is method, not a configurable attribute.

You can disable logging with :


To disable all, call:


This will disable all logs of level DEBUG and below.

To enable all logging, do logging.disable(logging.NOTSET) as it is the lowest level.