PHP8.1.21版本已发布
vue8.1.21版本已发布
jquery8.1.21版本已发布

如何设置apache每天保存日志

王林
王林 转载
2021-03-12 10:22:47 3048浏览

由于工作需求,需要设置apache日志按每天的方式保存,现在将具体方法分享出来,以供大家参考。

一、查找rotatelogs

rotatelogs是apache自带的日志按日期生成的模块,具体位置已自己网站rotatelogs位置为准

[root@localhost ~]# find / -name rotatelogs
/usr/sbin/rotatelogs

二、修改/etc/httpd/conf/httpd.conf配置文件

主要修改两个

#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

[root@localhost ~]# systemctl restart httpd.service

四、重新访问查看效果

[root@localhost ~]# cat /var/log/httpd/
access_log    access_log20200504.log  error_log    error_log20200504.log

相关推荐:apache教程

声明:本文转载于:csdn,如有侵犯,请联系admin@php.cn删除