logging module

Sharan Basappa sharan.basappa at gmail.com
Sun Jul 1 09:05:48 EDT 2018


Folks,

I am trying to use logging module and somehow I cannot make it work.

A simple code that I am trying is below. The commented code line 5,6 are other options I have tried but don't work

#importing module
import logging
 
#Create and configure logger
#logging.basicConfig(filename="D:/Projects/Initiatives/machine learning/programs/newfile.log",
#logging.basicConfig(filename="newfile.log",
logging.basicConfig(format='%(asctime)s %(message)s')
 
#Creating an object
logger=logging.getLogger()
 
#Setting the threshold of logger to DEBUG
logger.setLevel(logging.DEBUG)
 
#Test messages
logger.debug("Harmless debug Message")
logger.info("Just an information")
logger.warning("Its a Warning")
logger.error("Did you try to divide by zero")
logger.critical("Internet is down")

PS: I am running this under Enthought Canopy

The following is the output
%run "D:/Projects/Initiatives/machine learning/programs/debug_4.py"


More information about the Python-list mailing list