У меня проблемы с поиском ошибки в моем коде, когда я пытаюсь войти в систему с помощью библиотеки журналов.Даже если для минимального уровня журнала задано значение DEBUG, регистратор создает файл журнала, который начинается с ПРЕДУПРЕЖДЕНИЯ.
import logging
my_logger = logging.getLogger("our logger")
# Remove all handlers associated with my_logger object.
# This is only done so that we can run this block mult. times.
for handler in my_logger.handlers[:]:
my_logger.removeHandler(handler)
# let's create a handler and set the logging level
my_handler_for_file = logging.FileHandler("custom logging.log", mode='w')
my_handler_for_file.setLevel(logging.DEBUG)
# try to set it to logging.CRITICAL and it will only log CRITICAL,
# so it does work but neither for DEBUG nor INFO!
# add the handlers to our custom logger
my_logger.addHandler(my_handler_for_file)
# let's create some logs
my_logger.debug('This is a debug message')
my_logger.info('This is an info message')
my_logger.warning('This is a warning message')
my_logger.error('This is an error message')
my_logger.critical('This is a critical message')
Это вывод в файле журнала:
This is a warning message
This is an error message
This is a critical message
И это то, что я ожидаю, это будет:
This is a debug message
This is an info message
This is a warning message
This is an error message
This is a critical message
У кого-нибудь есть идеи, что здесь не так?