#Linux Tomcat9 catalina.out日志按日期生成
- yum install cronolog
- 查看 cronolog 安装 which cronolog
- 备份tomcat/bin/catalina.sh
- 修改 catalina.sh
# 226行
if [ -z "$CATALINA_OUT" ] ; then
CATALINA_OUT="$CATALINA_BASE"/logs/catalina.out
fi
#修改为
=======>
if [ -z "$CATALINA_OUT" ] ; then
CATALINA_OUT="$CATALINA_BASE"/logs/catalinaLog.%Y-%m-%d.out
fi
#460 行,删除或者注释掉
=======> #touch "$CATALINA_OUT"
#474行和484行两处修改
org.apache.catalina.startup.Bootstrap "$@" start \
>> "$CATALINA_OUT" 2>&1 "&"
=======>
org.apache.catalina.startup.Bootstrap "$@" start 2>&1\
| /sbin/cronolog "$CATALINA_BASE"/logs/catalinaLog.%Y-%m-%d.out >> /dev/null &
#从新启动tomcat