前言:
發現WEB伺服器上有一個檔案一直在不斷增長而且速度還很快,一看是記錄檔,已經達到一個G了。但又想留下最新的一些日誌,不想一下都刪除了,但記錄檔太大,根本就打不開。其實這時最好用日誌輪詢,之前這個WEB伺服器沒有做這個配置,本應該配置WEB伺服器時就應該做的。現在配置下也不晚。
1.首先得要軟體,下載:http://cronolog.org/download/index.html
Version 1.6.2 released 2002-01-24 (gzip'ed tar file)
Version 1.6.1 released 1999-12-20 (gzip'ed tar file)
Win 32 version (ZIP file)
Version 1.6 released 1999-12-16 (gzip'ed tar file)
Version 1.5b9 released on 4 June 1998 (gzip'ed tar file)
Version 1.4 released 20 December 1996 (gzip'ed tar file)
如果有Windows的要下Win_32_version(ZIP file) Linux習慣用哪種包就用哪種.
2. 在Linux 下安裝cronolog
tar zxvf cronolog-1.6.2.tar.gz
cd cronolog-1.6.2
./configure (注意:預設是安裝在/usr/local下 cronolog的命令在/usr/local/sbin下,這個要清楚)
make ; make install
3.在Windows下安裝cronolog
在Windows下很簡單,直接把cronolog.exe解壓Copy到apache目錄下的bin目錄中.
注意:配置都是一樣的格式,不過要注意Linux和Windows下斜杠的方向.
Linux下
例:cronolog命令在/usr/local/sbin 下 記錄檔在 /usr/local/apache2/logs/下
在FormatLog附近加入兩句:
CustomLog "|/usr/local/sbin/cronolog logs/access_%Y%m%d.log" combined
ErrorLog "|/usr/local/sbin/cronolog logs/error_%Y%m%d.log"
Windows下
例:cronolog命令在apache的bin中 記錄檔在D:/logs
CustomLog "|bin/cronolog D:/logs/access_%Y%m%d.log" combined
ErrorLog "|bin/cronolog D:/logs/error_%Y%m%d.log"
(注意:斜杠方向都在Linux下是一樣的,不跟Windows的習慣一樣)
如果有虛擬機器主機,虛擬機器主機也要配置,例如:
<VirtualHost *:80>ServerName www.domain.comCustomLog "|bin/cronolog.exe D:/logs/access_%Y%m%d.log" combinedErrorLog "|bin/cronolog.exe D:/logs/error_%Y%m%d.log"</VirtualHost> |
4.重啟服務就可以看到產生了一個新的記錄檔。
相關文章】