Solved! Go to Solution.
arcpy.AddMessage("my log file name : "+str(outputFileLog)) print ("my log file name : "+str(outputFileLog))
for handler in logger.handlers: print ("my log file handler : "+handler.baseFilename)
>>> my log file name : C:\Users\ADMINI~1\AppData\Local\Temp\2\scratch\WebMap_f4ccc4d1-00c3-11e3-835e-123142ff4c42.log I'm getting here my log file handler : C:\Users\ADMINI~1\AppData\Local\Temp\2\scratch\WebMap_f4ccc4d1-00c3-11e3-835e-123142ff4c42.log >>> ================================ RESTART ================================ >>> my log file name : C:\Users\ADMINI~1\AppData\Local\Temp\2\scratch\WebMap_0e69ed9e-00c4-11e3-840d-123142ff4c42.log I'm getting here my log file handler : C:\Users\ADMINI~1\AppData\Local\Temp\2\scratch\WebMap_0e69ed9e-00c4-11e3-840d-123142ff4c42.log >>>
import arcpy, uuid, os, logging from arcpy import env env.overwriteOutput = True outputDir = arcpy.env.scratchFolder outputName = 'WebMap_{}'.format(str(uuid.uuid1())) outputLogName = outputName + r".log" outputFileLog = os.path.join(outputDir, outputLogName) arcpy.AddMessage("my log file name : "+str(outputFileLog)) print ("my log file name : "+str(outputFileLog)) def createLogger(logFile): arcpy.AddMessage("I'm getting here") print ("I'm getting here") logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) for handler in logger.handlers: arcpy.AddMessage("my log file name : "+handler.baseFilename) print ("my log file handler : "+handler.baseFilename) handler=[] handler = logging.FileHandler(logFile) handler.setLevel(logging.INFO) formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') handler.setFormatter(formatter) logger.addHandler(handler) for handler in logger.handlers: arcpy.AddMessage("my log file name : "+handler.baseFilename) print ("my log file handler : "+handler.baseFilename) return logger logger = createLogger(outputFileLog) logger.info("I'm created") del logger