
由于工作需求,需要设置apache日志按每天的方式保存,现在将具体方法分享出来,以供大家参考。
一、查找rotatelogs
rotatelogs是apache自带的日志按日期生成的模块,具体位置已自己网站rotatelogs位置为准
1 2 | [root@localhost ~]# find / -name rotatelogs
/usr/sbin/rotatelogs
|
登录后复制
二、修改/etc/httpd/conf/httpd.conf配置文件
主要修改两个
1 2 3 4 5 6 7 | #ErrorLog logs/ error_log #注释此行,添加下面这行
ErrorLog "|/usr/sbin/rotatelogs /var/log/httpd/error_log%Y%m%d.log 86400 480"
#CustomLog logs/access_log common #注释此行,添加下面这行
CustomLog "|/usr/sbin/rotatelogs /var/log/httpd/access_log%Y%m%d.log 86400 480" common
|
登录后复制
三、重启Apache
1 | [root@localhost ~]# systemctl restart httpd.service
|
登录后复制
四、重新访问查看效果
1 2 | [root@localhost ~]# cat / var /log/httpd/
access_log access_log20200504.log error_log error_log20200504.log
|
登录后复制
相关推荐:apache教程
以上是如何设置apache每天保存日志的详细内容。更多信息请关注PHP中文网其他相关文章!