Created
January 10, 2015 12:08
-
-
Save yeonsh/4b3e59d3fc2fdb21c122 to your computer and use it in GitHub Desktop.
Python logging
This file contains 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 | |
logger = logging.getLogger(__name__) | |
logger.setLevel(logging.INFO) | |
# create a file handler | |
handler = logging.FileHandler('hello.log') | |
handler.setLevel(logging.INFO) | |
# create a logging format | |
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') | |
handler.setFormatter(formatter) | |
# add the handlers to the logger | |
logger.addHandler(handler) | |
logger.info('Hello baby') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment