问题描述
我正在运行 uwsgi 服务器.我需要每日日志轮换和基于文件大小的日志轮换.
I have running uwsgi server. i need log rotation for daily and file size based log rotation.
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.log
logrotate 配置:
logrotate configuration:
# file : /etc/logrotate.conf
"/var/log/uwsgi/*.log" {
copytruncate
daily
maxsize 5k
dateext
rotate 5
compress
missingok
create 777 root root
}
但是日志轮转不起作用,如果logrotaion.conf 中的配置有误,请给出解决方案.
But log rotation is not working please give the solution for if any wrong configuration in logrotaion.conf.
推荐答案
如果在logrotate
中使用copytruncate
选项,则不需要重启uwsgi
服务code> 文件(如 Tamar 所述).
It's not needed to restart uwsgi
service if you use copytruncate
option in logrotate
file (as stated by Tamar).
但问题可能是你忘记在cron
中启用logrotate
.请确保您在 /etc/cron.daily
中有一个名为 logrotate
的条目.
But the problem may be that you forgot to enable logrotate
in cron
. Please, make sure you have a entry in /etc/cron.daily
called logrotate
.
这篇关于UWSGI 对数旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!