Skip to content

Instantly share code, notes, and snippets.

@theeluwin
Created October 24, 2017 10:08
Show Gist options
  • Select an option

  • Save theeluwin/18f43314058a7fa93d1d870564c9da78 to your computer and use it in GitHub Desktop.

Select an option

Save theeluwin/18f43314058a7fa93d1d870564c9da78 to your computer and use it in GitHub Desktop.
import logging
# setting
logger = logging.getLogger('mylog')
log_handler = logging.FileHandler('path/to/file/mylog.log')
log_formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
log_handler.setFormatter(log_formatter)
logger.addHandler(log_handler)
logger.setLevel(logging.DEBUG)
# usage
logger.info("some info")
logger.error("some error")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment