Skip to content

Instantly share code, notes, and snippets.

@mihow
Last active Jan 24, 2017
Embed
What would you like to do?
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