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

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


The root logger always defaults to WARNING level. Try calling

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

and you should be fine.


Like @ztyx said that default logger level is WARNING. You have to set it to a lower level

You can do it by using logging.basicConfig and setting logger level:

logging.basicConfig(level=logging.DEBUG)


The above solutions didn't work for me, but the code here did:

# set up logging to filelogging.basicConfig(level=logging.DEBUG,                    format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',                    datefmt='%m-%d %H:%M',                    filename='/temp/myapp.log',                    filemode='w')# define a Handler which writes INFO messages or higher to the sys.stderrconsole = logging.StreamHandler()console.setLevel(logging.INFO)# add the handler to the root loggerlogging.getLogger('').addHandler(console)

(I omitted parts of the code for the sake of readability)