标签:
官网下载:http://cronolog.org/usage.html
./configure
make;make install
或者
yum install cronolog -y
默认安装位置:
# which cronolog
/usr/local/sbin/cronolog
编辑tomcat目录bin下的catalina.sh文件 # 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 if [ $have_tty -eq 1 ]; then echo "Using Security Manager" fi shift "$_RUNJAVA" "$LOGGING_CONFIG" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" -Djava.security.manager -Djava.security.policy=="$CATALINA_BASE"/conf/catalina.policy -Dcatalina.base="$CATALINA_BASE" -Dcatalina.home="$CATALINA_HOME" -Djava.io.tmpdir="$CATALINA_TMPDIR" org.apache.catalina.startup.Bootstrap "$@" start >> "$CATALINA_OUT" 2>&1 & else "$_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 /usr/local/tomcat/logs/catalina.%Y%m%d.out >> /dev/null & # >> "$CATALINA_OUT" 2>&1 & fi
保存退出
重启Tomcat服务
[root@VM tomcat]# bin/shutdown.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/jdk1.6.0_29
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar
[root@VM tomcat]# bin/startup.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/jdk1.6.0_29
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar
查看日志目录是否生成catalina.yymmdd.out的日志文件
-rw-r--r-- 1 root root 10537 Jul 30 10:50 catalina.20140730.out
配置cronolog完成了,观察每天是否有一个新的catalina.yymmdd.out的日志文件生成,定期删除日期较旧的日志文件。
标签:
原文地址:http://www.cnblogs.com/nb-blog/p/5587655.html