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 """
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter