Created
March 9, 2017 08:53
-
-
Save sroccaserra/8f71604742e4586947c48a9a214b250d to your computer and use it in GitHub Desktop.
Python 3 "logging to file" quick ref
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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