tomcat按天生成日志,亲测可行~
1.安装cronolog
安装方式一:
shell> sudo yum install cronolog
或
shell> sudo apt-get install cronolog
验证cronolog:
shell> which cronolog
安装方式二:
shell> wget http://cronolog.org/download/cronolog-1.6.2.tar.gz
或者在百度云盘下载:
https://pan.baidu.com/s/1nEaWSFf1YhztQGiz2OYL7A
下载完成:
shell> tar zxf cronolog-1.6.2.tar.gz
shell> cd cronolog-1.6.2
shell> ./configre
shell> make
shell> make install
验证cronolog:
shell> which cronolog
2.修改启动tomcat的catalina.sh文件
catalina.sh文件在tomcat的bin目录下
shell> vim catalina.sh
注释掉:
#touch "$CATALINA_OUT"
修改:
org.apache.catalina.startup.Bootstrap "$@" start \
>> "$CATALINA_OUT" 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下的logs文件是否有 catalina.2018-12-10.out类似的文件。