import logging import sys logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) file_handler = logging.FileHandler('test.log') file_handler.setLevel(logging.DEBUG) logger.addHandler(file_handler) console_handler = logging.StreamHandler(sys.stdout) console_handler.setLevel(logging.DEBUG) logger.addHandler(console_handler) logger.info('Info print') logger.debug('Debug print') I have simple code above. How come the debug statement doesn't print? It seems like the logLevel is always determined by line 5. The file_handler.setLevel and the console_handler.setLevel seem to do nothing. I want to eventually have debug prints going to the test.log file, and info prints going to the console.
stdoutis sometimes associated with a terminal. Your terminal is almost never a console. Referring to stdout as "console output" is a terrible idea.