首页 > 代码库 > 使用cronolog-1.6.2按日期截取Tomcat日志
使用cronolog-1.6.2按日期截取Tomcat日志
一、首先安装cronolog-1.6.2
1、下载
wget http://cronolog.org/download/cronolog-1.6.2.tar.gz
2、安装
# tar zxvf cronolog-1.6.2.tar.gz
# cd cronolog-1.6.2
# ./configure
# make
# make install
3、查看cronolog安装后所在目录(验证安装是否成功)
# which cronolog(一般情况下显示为:/usr/local/sbin/cronolog)
4、查找
if [ -z "$CATALINA_OUT" ] ; then
CATALINA_OUT="$CATALINA_BASE"/logs/catalina..out
fi
修改为:
if [ -z "$CATALINA_OUT" ] ; then
CATALINA_OUT="$CATALINA_BASE"/logs/catalina.%Y-%m-%d.out
fi
5、查找 touch "$CATALINA_OUT"
注释掉 #touch "$CATALINA_OUT"
6、查找两处 "$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 &
本文出自 “旅程” 博客,请务必保留此出处http://a40406.blog.51cto.com/5664274/1900550
使用cronolog-1.6.2按日期截取Tomcat日志