一、安裝 軟體
cronolog-1.6.2.tar.gz
tar zxvf cronolog-1.6.2.tar.gz
cd cronolog-1.6.2
./configure && make && make install
二、配置 tomcat
找到 tomcat 中 bin 目錄下的 catalina.sh 檔案
1. 查詢
if [ -z "$CATALINA_OUT" ] ; then
CATALINA_OUT=/opt/htdocs/logs/catalina.out
fi
修改為
if [ -z "$CATALINA_OUT" ] ; then
CATALINA_OUT=/opt/htdocs/logs/catalina.%Y-%m-%d.out
fi
--------------------------------------------------------------------
2. 查詢 touch "$CATALINA_OUT"
註釋掉
#touch "$CATALINA_OUT"
---------------------------------------------------------------------
3. 查詢 "$CATALINA_OUT" 2>&1 "&"
有兩處..
org.apache.catalina.startup.Bootstrap "$@" start \
>> "$CATALINA_OUT" 2>&1 "&"
都修改為 :
org.apache.catalina.startup.Bootstrap "$@" start \
| /usr/local/sbin/cronolog "$CATALINA_OUT" >> /dev/null &
3. 重啟 tomcat 服務,檢視日誌檔案