Skip to content

Instantly share code, notes, and snippets.

@tadone
Created October 16, 2017 14:03
Show Gist options
  • Save tadone/cadb27a93602d97959cefc7d62739055 to your computer and use it in GitHub Desktop.
Save tadone/cadb27a93602d97959cefc7d62739055 to your computer and use it in GitHub Desktop.
[Logging] Basic logging
# Import module
import logging
# Logging to console
logging.warning('Watch out!') # will print a message to the console
logging.info('I told you so') # will not print anything
>>>WARNING:root:Watch out!
# Logging to a file
logging.basicConfig(filename='example.log',level=logging.DEBUG)
logging.debug('This message should go to the log file')
logging.info('So should this')
logging.warning('And this, too')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment