在 windows 環境下 設定 Apache log rotate

若要修改 apache log rotate 設定,讓它可以自動依指定容量自動切割。

系統環境:
Window Server
Apache 2.2.25

#ErrorLog "logs/error.log"
ErrorLog "|bin/rotatelogs.exe -l D:/Apache2.2/logs/error.%Y.%m.%d.log 86400"
#CustomLog "logs/access.log" common
CustomLog "|bin/rotatelogs.exe -l D:/Apache2.2/logs/access.%Y.%m.%d.log 86400" common
#TransferLog "D:/Apache2.2/logs/ssl_access.log"
TransferLog "|bin/rotatelogs.exe -l D:/Apache2.2/logs/ssl_access.%Y.%m.%d.log 86400"
#CustomLog "D:/Apache2.2/logs/ssl_request.log" \
#          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
CustomLog "|bin/rotatelogs.exe -l D:/Apache2.2/logs/ssl_request.%Y.%m.%d.log 86400" \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

每天產出一個記錄檔 86400
指定容量產出一個記錄檔 500M
上面 log 後面的數字最後加入了 “M”, 即不是以時間輪替, 而且以 100MB 為體積上限輪替。

其他設定參數:
%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
%s – 1970/01/01 00 開始時間

留言

這個網誌中的熱門文章

c語言-關於#define用法

CMD常用網管指令

使用windows CMD 時間自動校正