Atomic log file rotation with Flask and RotatingFileHandler

半腔热情 提交于 2020-12-04 03:58:54

问题


I use standard RotatingFileHandler within my Flask application with next parameters: maxBytes=10 * 1024 * 1024, backupCount=50. App is managed by uWSGI behind nginx. uWSGI config file part looks like this:

processes = 16
enable-threads = true
threads = 10

Right after start of an app everything (I mean logging) works well. But after first log file rotation some processes (and maybe threads too) continue writing to rotated file and some - to new one. It is obvious. But for me it is not so obvious how can I rotate log file in the way that all of my processes (and threads) start to write messages to new file.


回答1:


Note that writing to a single log file from multiple processes isn't supported, because there is no cross-platform synchronisation mechanism that can be used. See this cookbook entry for a suggested approach which might work for you.



来源:https://stackoverflow.com/questions/28021282/atomic-log-file-rotation-with-flask-and-rotatingfilehandler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!