我正在开发Web应用程序,我想在php中记录每日轮换。 我找到了* error_log *方法,但它没有记录旋转。
答案 0 :(得分:2)
默认配置文件是/etc/logrotate.conf:
# see "man logrotate" for details
# rotate log files weekly
weekly
# keep 4 weeks worth of backlogs
rotate 4
# create new (empty) log files after rotating old ones
create
# uncomment this if you want your log files compressed
#compress
# RPM packages drop log rotation information into this directory
include /etc/logrotate.d
# no packages own wtmp -- we'll rotate them here
/var/log/wtmp {
monthly
create 0664 root utmp
rotate 1
}
存储在/etc/logrotate.d目录中的服务或服务器特定配置,例如这里是示例apache logrotate配置文件:
# cat /etc/logrotate.d/httpd
输出:
/var/log/httpd/*.log {
weekly
rotate 52
compress
missingok
notifempty
sharedscripts
postrotate
/bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true endscript
}
尝试它可能对你有所帮助
答案 1 :(得分:0)
尝试Apache log4php ,这与java中的log4j相同,它可以生成每日轮换日志。