由于工作需求,需要設置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教程
? 版權聲明
文章版權歸作者所有,未經允許請勿轉載。
THE END
喜歡就支持一下吧
相關推薦