如何每天创建一个uwsgi日志文件? [英] How to create one uwsgi log file per day?

查看:607
本文介绍了如何每天创建一个uwsgi日志文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将uwsgi与--daemonize/logs/uwsgi.log参数一起使用

I use uwsgi with the parameter --daemonize /logs/uwsgi.log

这个文件正在变大,我想把它分成几个小块.每天一次是比较可取的.我已经为nginx做到了,使用日期变量可以很容易地指定日志文件名.是否可以对uwsgi做同样的事情?

This file is however becoming large and I would like to split it into smaller pieces. One per day would be preferable. I have done that for nginx where it was easy to specify the log file name using date variables. Is it possible to do the same for uwsgi?

类似的东西:

[uwsgi]
daemonize=/logs/uwsgi-$year-$month-$day.log

或者是否有另一种方法可以得到相同的结果,而无需过多地参与其他过程?

Or is there another way to get the same result, without too much involvement of other processes?

推荐答案

uWSGI本身只能通过--log-maxsize选项按大小分割".

uWSGI by itself can only "split by size", with the --log-maxsize option.

基于时间的方法正在使用经典的logrotate或apache rotationlogs( http://httpd.apache.org /docs/2.2/programs/rotatelogs.html ),您可以将其与uWSGI logpipe插件结合使用.

Time-based approaches are using classic logrotate or apache rotatelogs (http://httpd.apache.org/docs/2.2/programs/rotatelogs.html) that you can combine with uWSGI logpipe plugin.

最后,您可以在uWSGI实例的午夜触发类似于nginx的行为来触发重新加载(您甚至可以使用嵌入式cron工具):

Finally you can have an nginx like behaviour triggering a reload at midnight of the uWSGI instance (you can even use the embedded cron facility):

[uwsgi]
daemonize = /logs/uwsgi-@(exec://date +%%Y-%%m-%%d).log
log-reopen = true

这篇关于如何每天创建一个uwsgi日志文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆