Skip to content

Instantly share code, notes, and snippets.

@micktwomey
Last active August 29, 2015 14:24
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 micktwomey/c6e6ad9d540e3c6a95c3 to your computer and use it in GitHub Desktop.
Save micktwomey/c6e6ad9d540e3c6a95c3 to your computer and use it in GitHub Desktop.
Minimal useful python logging config
"""
I always forget a useful default format for python logging, so here's one I prepared earlier.
"""
import logging
logging.basicConfig(level=logging.DEBUG,
format=('%(asctime)s %(levelname)s %(name)s '
'%(pathname)s:%(lineno)d %(message)s'
),
datefmt="%Y-%m-%d %H:%M:%S%z")
logging.info("ham") # 2015-07-15 10:20:07+0100 INFO root <stdin>:1 ham
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment