code
I am using logging module to create log file.It checks the platform and provide method to create logfile as per the 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 the program")
logging.info("doing something")
logging.warning("u are gonna die")