pythonloggingwarningspython-logging

logging.info doesn't show up on console but warn and error do


When I log an event with logging.info, it doesn't appear in the Python terminal.

import logging
logging.info('I am info')  # no output

In contrast, events logged with logging.warn do appear in the terminal.

import logging
logging.warn('I am warning')  # outputs "I am warning"

Is there a environment level change I can to make logging.info print to the console? I want to avoid making changes in each Python file.


Solution

  • The root logger always defaults to WARNING level. Try calling

    logging.getLogger().setLevel(logging.INFO)
    

    and you should be fine.