在java项目中,LINUX系统,TOMCAT服务器,结果项目运行中在TOMCAT的LOGS文件下产生catalina.out文件且呈现持续化增长状态
WIN下的tomcat5的日志是按日期来记录的.移到linux下发现tomcat/logs下只有一个catalina.out件.
时间一长.发现日志文件暴增.对于管理真是不方便.
1.下载cronolog-1.6.2.tar.gz
2.安装
- # tar zxvf cronolog-1.6.2.tar.gz
- # ./configure
- # make
- # make install
# tar zxvf cronolog-1.6.2.tar.gz # ./configure # make # make install
默认是安装在/usr/local/sbin/下.
3.配置
在tomcat/bin/catalian.sh中找到
- org.apache.catalina.startup.Bootstrap "$@" start \ >> "$CATALINA_BASE"/logs/catalina.out 2&1 &
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 \ |/usr/local/sbin/cronolog "$CATALINA_BASE"/logs/catalina.%Y-%m-%d.out >> /dev/null 2>&1 &
修改好了.重启
- #./catalina.sh start
#./catalina.sh start
# ls /tomcat/logs/
就会发现logs下面多了几个如同catalina.2006.06.01.log的文件了.
------------------------------------------------------------------------------------------------------------------------------
进入tomcat的bin目录,打开catalina.out
找到-security
将
- #>> "$CATALINA_BASE"/logs/catalina.out 2>&1 &
#>> "$CATALINA_BASE"/logs/catalina.out 2>&1 &
修改成
- org.apache.catalina.startup.Bootstrap "$@" start 2>&1 | "$CATALINA_BASE"/bin/cronolog "$CATALINA_BASE"/logs/%Y%m%d_%Hcatalina.out >> /dev/null &
org.apache.catalina.startup.Bootstrap "$@" start 2>&1 | "$CATALINA_BASE"/bin/cronolog "$CATALINA_BASE"/logs/%Y%m%d_%Hcatalina.out >> /dev/null &
文件中有一行
- touch “$CATALINA_BASE”/logs/catalina.out
touch “$CATALINA_BASE”/logs/catalina.out
可以注释掉
改好后 在http://cronolog.org/ 下载一个cronolog
放到bin目录中,然后重启tomcat,将会在tomcat中/logs找到
20100604_15catalina.out的日志。