利用cronolog对Tomcat7 catalina.out 日志分割

与世无争的帅哥 提交于 2021-02-20 01:08:30

下载

Download

解压后安装

[root@ ~]# tar -xzvf cronolog-1.6.2.tar.gz
[root@ ~]# cd cronolog-1.6.2
[root@ ~]# ./configure
[root@ ~]# make && make install
[root@ ~]# which cronolog
/usr/local/sbin/cronolog

编辑catalina.sh

编辑前先备份一个

[root@ bin]# cp catalina.sh catalina.sh.bak

修改点

[root@ bin]# diff catalina.sh catalina.sh.bak 
186c186
<   CATALINA_OUT="$CATALINA_BASE"/logs/catalina.out.%Y-%m-%d
---
>   CATALINA_OUT="$CATALINA_BASE"/logs/catalina.out
371c371
<    #touch "$CATALINA_OUT"
---
>   touch "$CATALINA_OUT"
384c384,385
<       org.apache.catalina.startup.Bootstrap "$@" start 2>&1 | /usr/local/sbin/cronolog "$CATALINA_OUT" >> /dev/null &
---
>       org.apache.catalina.startup.Bootstrap "$@" start \
>       >> "$CATALINA_OUT" 2>&1 "&"
392c393,394
<       org.apache.catalina.startup.Bootstrap "$@" start 2>&1 | /usr/local/sbin/cronolog "$CATALINA_OUT" >> /dev/null &
---
>       org.apache.catalina.startup.Bootstrap "$@" start \
>       >> "$CATALINA_OUT" 2>&1 "&"

重启Tomcat即可

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!