Answer the question
In order to leave comments, you need to log in
How to set all logging levels in logging python?
How to save in a file not only 1 logging level (in this example, the INFO level, since we configured this at the beginning), but in general everything? Here the debug level is not written to the file. How to record? Together with warning, error and critical?
import logging
logging.basicConfig(
filename='test.log',
format='%(name)s %(message)s',
level=logging.INFO # как задать все уровень логирования, а не только INFO
)
for i in range(10):
if i < 5:
logging.info(i)
else:
logging.debug(i) # не записывается
Answer the question
In order to leave comments, you need to log in
Info is higher than Debug. When you specify level=logging.INFO
, Info and above will be logged.
Change to
level=logging.DEBUG
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question