Skip to content

Instantly share code, notes, and snippets.

@sroccaserra
Created March 9, 2017 08:53
Show Gist options
  • Select an option

  • Save sroccaserra/8f71604742e4586947c48a9a214b250d to your computer and use it in GitHub Desktop.

Select an option

Save sroccaserra/8f71604742e4586947c48a9a214b250d to your computer and use it in GitHub Desktop.
Python 3 "logging to file" quick ref
import logging
seb_logger = logging.getLogger('Seb')
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
file_handler = logging.FileHandler('/vagrant/project/Seb.log')
file_handler.setLevel(logging.DEBUG)
file_handler.setFormatter(formatter)
seb_logger.addHandler(file_handler)
seb_logger.setLevel(logging.DEBUG)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment