import logging logging.basicConfig( format='%(asctime)s %(levelname) -8s [%(filename)s:%(lineno)d] %(message)s', level=logging.DEBUG, datefmt= '%Y-%m-%d %H:%M:%S', filename= 'log.txt' ) #s - turn it to a string logger = logging.getLogger('test_log') logger.info('This will not show up') logger.warning('This will') logger.error('this is error') logger.critical('Critical error') """ DEBUG INFO #those show up by default WARNING ERROR CRITICAL """