python - 如果 python 烧瓶应用程序在 apache2 mod_wsgi 下运行,则无法写入日志文件
问题描述
当我运行 app.py 使用命令行没有问题时,将生成并记录日志文件。
但是当 py 文件由 apache wsgi 运行时
没有日志出来
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')
解决方案
推荐阅读
- r - R ggridges:基于第三个变量的颜色 geom_ridges_density_gradient
- jenkins - jenkins 构建配置 - 打包 EAR 问题
- c# - 当名称是保留关键字时,如何从动态对象中获取属性?
- c# - 如何在 ASP net core 中添加扩展过滤器?
- angular - 复选框值不在表单数组中,角度
- javascript - 使用 Jest.fn() 查看是否调用了 s3.upload 函数......我做错了什么?
- java - 如何将 yaml 文件中的变量读入 application.properties?
- javascript - MongoDB $和查询
- image - 如何在 Kivy 的滚动视图中将标签放置在屏幕中央?
- linux - 我可以确保每个 CentOS 7 都有 /etc/os-release 文件吗?