首頁  >  文章  >  運維  >  如何設定apache每天保存日誌

如何設定apache每天保存日誌

王林
王林轉載
2021-03-12 10:22:473118瀏覽

如何設定apache每天保存日誌

由於工作需求,需要設定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每天保存日誌的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:csdn.net。如有侵權,請聯絡admin@php.cn刪除