使用cronolog日志切分工具切分Tomcat的catalina.out日志文件
<1>下载cronolog,并进行安装
wget http://cronolog.org/download/cronolog-1.6.2.tar.gz (中国服务器可能无法下载或下载缓慢,可先下载到境外服务器上)
tar zxvf cronolog-1.6.2.tar.gz
./cronolog-1.6.2/configure
make
make install
(默认安装在/usr/local/sbin下)
<2>.配置
在tomcat/bin/catalian.sh中
org.apache.catalina.startup.Bootstrap "$@" start \ >> "$CATALINA_BASE"/logs/catalina.out 2&1 &
改成:
org.apache.catalina.startup.Bootstrap"$@" start \ |/usr/local/sbin/cronolog "$CATALINA_BASE"/logs/catalina.%Y-%m-%d.out >> /dev/null 2>&1 &
或
org.apache.catalina.startup.Bootstrap "$@" start 2>&1 \ | /usr/local/sbin/cronolog "$CATALINA_BASE"/logs/catalina.%Y-%m-%d.out >> /dev/null &
<3>重启Tomcat
Tomcat输出日志文件分割成功,输出log文件格式变为:catalina.2017-05-15.out