我想创建每日日志,但有一个小问题。日志不是每天都要创建的,而是包含以前的日志文件。下面是我当前的设置,如何更改它,以便它每天只创建一个日志文件?
我编辑以下文件:/etc/logrotate.d/httpd
我使用一个名为Zadmin的控制面板,因此我将它的日志路径作为第二个dir包含进来。
我使用的是CentOS 6.5 64位。
/var/log/httpd/*log /var/sentora/logs/domains/zadmin/*.log {
missingok
rotate 4000000
daily
notifempty
sharedscripts
postrotate
/sbin/service httpd reload > /dev/null 2>/dev/null || true
endscript
}发布于 2015-08-21 19:06:32
按照Brian的回答,我是cronolog的忠实粉丝,cronolog就像你想要的那样:
CustomLog "|/usr/sbin/cronolog /var/log/httpd/%Y/%m/%Y-%m-%d-access.log" combined
ErrorLog "|/usr/sbin/cronolog /var/log/httpd/%Y/%m/%Y-%m-%d-error.log"yum install cronolog会让你在Cent6上找到克隆洛的。
发布于 2015-08-21 19:03:00
Apache允许您将日志文件输送到另一个程序,该程序可以处理旋转,而不必重新加载/重新启动Apache。Apache甚至提供了一个程序来实现这一点。
ErrorLog "|bin/rotatelogs -l -f /var/log/apache2/errlogfile.%Y.%m.%d.log 86400" common
CustomLog "|bin/rotatelogs -l -f /var/log/apache2/logfile.%Y.%m.%d.log 86400" common发布于 2015-08-21 20:58:18
尝试手动运行logrotate以查找错误:logrotate -d /etc/logrotate.d/httpd。手册上说:"-d打开调试模式并暗示-v。在调试模式下,不会对日志或日志旋转状态文件进行任何更改。“
这就是我们正在成功使用的东西:
/var/log/httpd/*log {
daily
dateext
dateformate -%d-%m-%Y
missingok
nocompress
rotate 30
postrotate
/sbin/service httpd reload > /dev/null 2>/dev/null || true
endscript
}https://serverfault.com/questions/714636
复制相似问题