cronolog安裝
查看cronolog安裝後所在目錄(驗證安裝是否成功)
# which cronolog
正常情況下顯示:
/usr/local/sbin/cronolog
要想分割tomcat的catalina.out,需作如下工作:
Tomcat7以前的版本:
(1)注釋掉(#)
touch “$CATALINA_BASE”/logs/catalina.out
(2)修改tomcat bin目錄下的catalina.sh文件中的兩處
org.apache.catalina.startup.Bootstrap “$@” start \
>> “$CATALINA_BASE”/logs/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 &
將
if [ -z "$CATALINA_OUT" ] ; then
CATALINA_OUT="$CATALINA_BASE"/logs/catalina.out
fi
修改為
if [ -z "$CATALINA_OUT" ] ; then
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/local/sbin/cronolog "$CATALINA_OUT" >> /dev/null &# vi bin/catalina.sh
找到下面這行
org.apache.catalina.startup.Bootstrap "$@" start \
>> "$CATALINA_OUT" 2>&1 &
類似這樣的行有2處,第一處是tomcat時帶“-security”參數的啟動,第二處是默認tomcat啟動方式,也就是else下面的那部分,我們只修改這裡。
另外還要把touch “$CATALINA_OUT"這行注釋掉。
完整的修改如下: #touch "$CATALINA_OUT" if [ "$1" = "-security" ] ; then ........ else eval "\"$_RUNJAVA\"" "\"$LOGGING_CONFIG\"" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \ -Djava.endorsed.dirs="\"$JAVA_ENDORSED_DIRS\"" -classpath "\"$CLASSPATH\"" \ -Dcatalina.base="\"$CATALINA_BASE\"" \ -Dcatalina.home="\"$CATALINA_HOME\"" -Djava.io.tmpdir="\"$CATALINA_TMPDIR\"" \ org.apache.catalina.startup.Bootstrap "$@" start 2>&1 \ | /usr/local/sbin/cronolog "$CATALINA_BASE"/logs/catalina.%Y-%m-%d.out >>/dev/null & fi完成之後重起Tomcat就可以看到logs文件中存在catalina.out.2015-09-13樣式的日志。
http://xxxxxx/Linuxjc/1144731.html TechArticle