tomcat日誌按天分割(cronolog)
阿新 • • 發佈:2018-12-11
1.安裝cronolog
安裝方式一:
shell> sudo yum install cronolog
或
shell> sudo apt-get install cronolog
驗證cronolog:
shell> which cronolog
安裝方式二:
shell> wget http://cronolog.org/download/cronolog-1.6.2.tar.gz 或者在百度雲盤下載: https://pan.baidu.com/s/1nEaWSFf1YhztQGiz2OYL7A 下載完成: shell> tar zxf cronolog-1.6.2.tar.gz shell> cd cronolog-1.6.2 shell> ./configre shell> make shell> make install 驗證cronolog: shell> which cronolog
2.修改tomcat的catalina.sh檔案
catalina.sh檔案在tomcat的bin目錄下
shell> vim catalina.sh
大概在371行,直接輸入371G(跳到371行,G要大寫)
註釋掉:
#touch "$CATALINA_OUT"
修改:
org.apache.catalina.startup.Bootstrap "[email protected]" start \
>> "$CATALINA_OUT" 2>&1 "&"
改為:
org.apache.catalina.startup.Bootstrap " [email protected]" start 2>&1 \
| /usr/local/sbin/cronolog "$CATALINA_BASE"/logs/catalina.%Y-%m-%d.out >>/dev/null &
正確配置:
3.重新啟動tomcat生效
檢視tomcat下的logs檔案是否有 catalina.2018-12-10.out類似的檔案。