OSError:[Errno 22]读取python日志记录配置文件时参数无效 |
您所在的位置:网站首页 › efcb › OSError:[Errno 22]读取python日志记录配置文件时参数无效 |
这是我的配置文件,这个配置文件将由python脚本读取。 [loggers] keys=root [logger_root] level=DEBUG handlers=screen,file [formatters] keys=simple,complex [formatter_simple] format='%(asctime)s [%(levelname)s] %(message)s' datefmt=%Y/%m/%d %H:%M:%S [formatter_complex] format='%(asctime)s %(process)s %(processName)s [%(levelname)s] %(message)s' datefmt=%Y/%m/%d %H:%M:%S [handlers] keys=file,screen [handler_file] class=handlers.TimedRotatingFileHandler interval=midnight backupCount=5 formatter=complex level=NOTSET args=('%(logfile)s',) [handler_screen] class=StreamHandler formatter=simple level=NOTSET args=(sys.stdout,)并且下面的python脚本要读取配置文件并输出日志文件 #Make logs folder under current working directory # and make log file config def _init_log(): currentTime = datetime.now().strftime('%Y%m%d') fileName = "ISS-"+str(currentTime)+".txt" current_directory = os.getcwd() log_directory = os.path.join(current_directory, r'Logs') if not os.path.exists(log_directory): os.makedirs(log_directory) current_directory = os.path.join(current_directory,"Logs",fileName) logging.config.fileConfig('logging.config', defaults={'logfile':str(current_directory)}, disable_existing_loggers=False) logger.info("Current working directory is :"+os.getcwd()) logger.info("real home directory is "+str(Path.home()))我得到了这个错误,OSError:[Errno 22] Invalid argument : 'D:\\home\\site\\wwwroot\\App_data\\jobs\triggered\\Logs\\test.log,这是怎么回事?请教我一下。谢谢。 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |