Apache Access Logs 日誌依日期存檔
錯誤訊息:
Apache的log檔超肥超大,一個檔案上GB都有可能!!
可能原因:
當Apache是安裝在Windows的系統中,日誌預設值是不會循環的,所以若您一直沒有清除或手動循環log檔,一個檔案上GB大小也是有可能的,若需要去解析它可能要花很久的時間。
解決方法:
Apache本身提供了 rotatelogs (在Windows下為 rotatelogs.exe) 這個指令來循環日誌,讓你可以手動執行指令(請參考 rotatelogs 指令教學) ,或是直接在 httpd.conf 中設定,範例如下:
每天循環(一天為86400秒)
CustomLog "|c:/apache2/bin/rotatelogs c:/apache2/logs/access_log 86400" combined
檔案到達5MB就循環
CustomLog "|c:/apache2/bin/rotatelogs c:/apache2/logs/access_log 5M" common
但這樣設定的話,它所產生的Log檔案名稱格式為 access_log.nnnn,後面的 nnnn 由系統自動產生,例如:access_log.1168300800,但這樣的話比較不容易維護或分析,您可以把它改成這樣:
每天循環(一天為86400秒)
CustomLog "|c:/apache2/bin/rotatelogs c:/apache2/logs/access_log_%Y%m%d 86400" combined
如此產生出來的檔案名稱會像這樣:access_log_20070110
若您想自訂檔案名稱的日期格式,可以參考以下的設定值:
%A - full weekday name (localized)
%a - 3-character weekday name (localized)
%B - full month name (localized)
%b - 3-character month name (localized)
%c - date and time (localized)
%d - 2-digit day of month
%H - 2-digit hour (24 hour clock)
%I - 2-digit hour (12 hour clock)
%j - 3-digit day of year
%M - 2-digit minute
%m - 2-digit month
%p - am/pm of 12 hour clock (localized)
%S - 2-digit second
%U - 2-digit week of year (Sunday first day of week)
%W - 2-digit week of year (Monday first day of week)
%w - 1-digit weekday (Sunday first day of week)
%X - time (localized)
%x - date (localized)
%Y - 4-digit year
%y - 2-digit year
%Z - time zone name
%% - literal `%'
完成以上 設定後,重新啟動 Apache 即可。
相關字彙:Apache設定、Apache 日誌、rotatelogs檔、
Betway Casino Review - Get 100% up to $600 in bonus
回覆刪除Betway is licensed 남원 출장샵 by the Malta Gaming Authority and 인천광역 출장안마 has a 부천 출장마사지 license from 수원 출장마사지 Malta 구미 출장샵 Gaming Authority, a company which was established in 1998.