Skip to content

Instantly share code, notes, and snippets.

@mihow
Last active January 24, 2017 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mihow/b941536dae6e4bbc47196d08684de7dc to your computer and use it in GitHub Desktop.
Save mihow/b941536dae6e4bbc47196d08684de7dc to your computer and use it in GitHub Desktop.
Basic logging configuration in Python
import logging
logging.basicConfig(format='%(levelname)s:%(message)s')
log = logging.getLogger(__name__)
log.setLevel(logging.INFO)
def main():
log.info("Great info")
log.debug("You won't see this")
try:
log.blarg
except AttributeError:
log.exception("The exception below looks scary, but everything worked!")
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment