我已经运行了uwsgi服务器。我需要每天的日志轮换和基于文件大小的日志轮换。
uwsgi配置:
# file: /etc/init/uwsgi.conf
description "uWSGI starter"
start on (local-filesystems and runlevel [2345])
stop on runlevel [016]
respawn
# home - is the path to our virtualenv directory
# pythonpath - the path to our django application
# module - the wsgi handler python script
exec /home/testuser/virtual_environments/teatapp/bin/uwsgi \
--uid testuser \
--home /home/testuser/virtual_environments/teatapp \
--pythonpath /home/testuser/sci-github/teatapp\
--socket /tmp/uwsgi.sock \
--chmod-socket \
--module wsgi \
--logdate \
--optimize 2 \
--processes 2 \
--master \
--logto /var/log/uwsgi/uwsgi.loglogrotate配置:
# file : /etc/logrotate.conf
"/var/log/uwsgi/*.log" {
copytruncate
daily
maxsize 5k
dateext
rotate 5
compress
missingok
create 777 root root
}但是日志轮换不起作用,如果logrotaion.conf中有任何错误的配置,请给出解决方案。
发布于 2018-05-14 15:39:54
如果您在uwsgi文件中使用copytruncate选项(如Tamar所述),则不需要重新启动logrotate服务。
但问题可能是您忘记在cron中启用logrotate。请确保在/etc/cron.daily中有一个名为logrotate的条目。
发布于 2017-06-18 22:23:59
uwsgi中有基于日志文件大小的日志记录,例如(uwsgi.ini指令):
log-maxsize = 100000如果你想使用logrotated,你必须重新启动uwsgi (logrotate指令):
postrotate
stop uwsgi
start uwsgi
endscript发布于 2015-09-17 19:31:53
只需将以下代码放到您的uwsgi配置文件中:
daemonize =/var/log/uwsgi/uwsgi-@(执行://日期+%%Y-%%m-%%d).log
这将创建一个日志每天,但要小心不要守护,如果你正在使用master我们的emperror。然后,如果日志很大,您可以通过附加到cron上的脚本来控制它,以清理文件夹。
https://stackoverflow.com/questions/31446713
复制相似问题