[Flask] Flask + uwsgi + TimedRotatingFileHandler = hilarity

Harrison Wright wright8191 at gmail.com
Fri Jan 12 10:43:36 EST 2018


If you are using linux, I have always just used logrotate (
https://linux.die.net/man/8/logrotate) instead of having the app server
handle this.

On Fri, Jan 12, 2018 at 7:25 AM, Skip Montanaro <skip.montanaro at gmail.com>
wrote:

> I'm trying to use the TimedRotatingFileHandler in a Flask+uwsgi app. I
> pass "when='midnight'" to the class instantiation:
>
>     handler = logging.handlers.TimedRotatingFileHandler("/
> path/to/logfile.log",
> when='midnight')
>
> That starts off okay. When I come in the next morning, I find
>
> /path/to/logfile.log
> /path/to/logfile.log-2018-10-11
>
> which, at first glance seems fine. Unfortunately, both files are open
> and receiving disjoint subsets of the log messages.
>
> My uwsgi options file contains
>
> processes = 2
> logger = python:/path/to/logfile.log
>
> the latter to catch the actual uwsgi log messages. That doesn't seem
> to be the culprit though, as I only set that up yesterday, and was
> getting the same behavior before. The messages which are distributed
> across the files are my application log messages, which leads me to
> believe I'm going to need to do something different to set up logfile
> rotation.
>
> Any suggestions about how to accomplish this?
>
> Thanks,
>
> Skip Montanaro
> _______________________________________________
> Flask mailing list
> Flask at python.org
> https://mail.python.org/mailman/listinfo/flask
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20180112/8845148f/attachment.html>


More information about the Flask mailing list