cronolog:日志分割工具

一. 引言 

  因为tomcat的catalina.out日志无法按照日期自动创建,因此采用cronnlog分割。

二. 安装与配置

  1.安装cronolog: yum install -y cronolog httpd 

  2.配置tomcat:修改tomcat目录下bin/catalina.sh文件。修改3个地方如下:

(1)
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
(2)
touch "$CATALINA_OUT"
修改为
# touch "$CATALINA_OUT"
(3)
org.apache.catalina.startup.Bootstrap "$@" start \
>> "$CATALINA_OUT" 2>&1 "&"
修改为
org.apache.catalina.startup.Bootstrap "$@" start 2>&1 \
| /usr/sbin/cronolog "$CATALINA_OUT" >> /dev/null&

posted @ 2018-05-12 10:50  knbsyoo  阅读(203)  评论(0编辑  收藏  举报