Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
429 views
in Technique[技术] by (71.8m points)

Unable to write to log file if python flask app running under apache2 mod_wsgi

When I run the app.py use command line no issue, the log file will be generated and logged.

but when the py file run by apache wsgi

no log comes out

file_log_path = '/var/log/apache2/'
file_log = 'python_app_log.txt'
file_log_full = file_log_path + file_log

logging.basicConfig(filename = file_log_full, level=logging.INFO,
                    format="%(asctime)s|%(levelname)s|%(funcName)s| %(message)s")

logging.info('Finished init path')

#----- Main-Fucntions ------------------------------------
#-- Set up time ---
logging.info('Main-Fucntions Init...')
tz_utc = tz.tzoffset('UTC Time', 0 * 60)
tz_sql = tz.tzoffset('SQL Server Time', Get_MySQL_TimeZone() * 60)

logging.info(tz_utc)
logging.info('MySQL Server Time zone is ' + tz_sql._name)



#----- Main Process Code must in above--------------------------------------
if __name__ == "__main__":
    app.run(host='0.0.0.0')
    #app.run(host='0.0.0.0',debug=True)
    #app.run(host= '0.0.0.0', port = 30443 ,debug = True)
    logging.info('APP RUN Event')

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...