Thursday, September 10, 2015

Logging Module in Python

import logging
 
logging.basicConfig(filename="sample.log", level=logging.INFO)
log = logging.getLogger("ex")
 
try:
    raise RuntimeError
except Exception, err:
    log.exception("Error!")
 
 
You can find a good blog on Logging here:
 
http://www.blog.pythonlibrary.org/2012/08/02/python-101-an-intro-to-logging/