 由于工作需求,需要设置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教程 以上就是如何设置apache每天保存日志的详细内容,更多请关注模板之家(www.mb5.com.cn)其它相关文章! |