Chu*_*lar 5 logging nginx ubuntu-16.04
我想保留lsat的nginx日志30天.默认配置为15天,如图所示.
我想保留最近30天.
以下是nginx的looging设置:
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
Run Code Online (Sandbox Code Playgroud)
但它没有说明应该采取什么"怎么样".
我根本不是nginx专家,因此我不知道如何/在哪里可以更改该配置.
也许有人需要这样做,并希望帮助我.
小智 10
要更改此行为,您必须更改nginx的logrotate文件.该文件可能位于/etc/logrotate.d中.为了实现你想要做什么,把指令weekly
和rotate 30
相应nginx的里面的文件.之后,使用以下命令确保更改生效:
logrotate /etc/logrotate.d/nginx-config-file
您可以为nginx设置logrotate,这样您就可以根据需要将日志保存30天或更长时间!
/etc/logrotate.d/nginx
/var/log/nginx/access_log {
rotate 7
size 5k
dateext
dateformat -%Y-%m-%d
missingok
compress
sharedscripts
postrotate
test -r /var/run/nginx.pid && kill -USR1 `cat /var/run/nginx.pid`
endscript
}
Run Code Online (Sandbox Code Playgroud)
相应地更改#rotate的值!30,40等...
归档时间: |
|
查看次数: |
4229 次 |
最近记录: |