Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Basic python logging example
import logging
config = { 'logfile': 'log_example.log', 'loglevel': 'DEBUG' }
logger = logging.getLogger('log_example')
log_handler = logging.FileHandler(config['logfile'])
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
logger.debug('Debug statement; uninteresting... until it is.')'This is for informational purposes only: {}'.format('ya'))
logger.warning('This is your last warning')
logger.error('A cubic millimeter of prevention is worth a giga-frikin-joule of cure')
logger.critical("It's over now fool!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.