No Log file is generated -- python using logging module -


code

i using logging module create log file.it checks platform , provide method create logfile per platform

import  os,platform,logging  if platform.platform('windows'):     logging_file=os.path.join(os.getenv('homedrive'),os.getenv('homepath'),'test.log') else:     logging_file = os.path.join(os.getenv('home'),'test.log')  print"logging to",logging_file  logging.basicconfig(level=logging.debug,format='%(asctime)s : %(levelname)s :%(message)s',filename=logging_file, filemode='w')   logging.debug("start of program") logging.info("doing something") logging.warning("u gonna die") 

the code provided not indented , should use logging.debug instead of logging.debug since later integer constant used represent log level. here updated code

import  os,platform,logging  if platform.platform('windows'):     logging_file=os.path.join(os.getenv('homedrive'),os.getenv('homepath'),'test.log') else:     logging_file = os.path.join(os.getenv('home'),'test.log')  print"logging to",logging_file  logging.basicconfig(level=logging.debug,                     format='%(asctime)s : %(levelname)s :%(message)s',                     filename=logging_file,                     filemode='w')   logging.debug("start of asdfasdfprogram") logging.info("doing something") logging.warning("u gonna die") 

Comments

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -