1. 程式人生 > >Apache下access.log和error.log檔案太大的處理方法

Apache下access.log和error.log檔案太大的處理方法

第一步:停止Apache服務的所有程序,刪除 Apache2/logs/目錄下的 error.log、access.log檔案 

第二步:開啟 Apache 的 httpd.conf配置檔案並找到下面兩條配置 

ErrorLog logs/error.log 
CustomLog logs/access.log common 

直接註釋掉,換成下面的配置檔案。 


# 限制錯誤日誌檔案為 1M 
ErrorLog "|bin/rotatelogs.exe -l logs/error-%Y-%m-%d.log 1M” 

# 每天生成一個錯誤日誌檔案 
#ErrorLog "|bin/rotatelogs.exe -l logs/error-%Y-%m-%d.log 86400" 


# 限制訪問日誌檔案為 1M 
CustomLog "|bin/rotatelogs.exe -l logs/access-%Y-%m-%d.log 1M” common 

# 每天生成一個訪問日誌檔案 
#CustomLog "|bin/rotatelogs.exe -l logs/access-%Y-%m-%d.log 86400" common