一、首先安装cronolog-1.6.2

1、下载

    wget http://cronolog.org/download/cronolog-1.6.2.tar.gz

2、安装

    # tar zxvf cronolog-1.6.2.tar.gz

    # cd cronolog-1.6.2

    # ./configure

    # make

    # make install

3、查看cronolog安装后所在目录(验证安装是否成功)

# which cronolog(一般情况下显示为:/usr/local/sbin/cronolog)


4、查找

if [ -z "$CATALINA_OUT" ] ; then

  CATALINA_OUT="$CATALINA_BASE"/logs/catalina..out

fi

修改为:

if [ -z "$CATALINA_OUT" ] ; then

  CATALINA_OUT="$CATALINA_BASE"/logs/catalina.%Y-%m-%d.out

fi


5、查找   touch "$CATALINA_OUT"

注释掉   #touch "$CATALINA_OUT"


6、查找两处 "$CATALINA_OUT" 2>&1 "&"

    org.apache.catalina.startup.Bootstrap "$@" start \

    >> "$CATALINA_OUT" 2>&1 "&"

修改为:

    org.apache.catalina.startup.Bootstrap "$@" start \

    | /usr/local/sbin/cronolog "$CATALINA_OUT" >> /dev/null &

示例:

#  touch "$CATALINA_OUT"

  if [ "$1" = "-security" ] ; then

    if [ $have_tty -eq 1 ]; then

      echo "Using Security Manager"

    fi

    shift

    eval "\"$_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 \

       |/usr/local/sbin/cronolog "$CATALINA_BASE"/logs/catalina.%Y-%m-%d.out >> /dev/null 2>&1 &

  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 \

      |/usr/local/sbin/cronolog "$CATALINA_BASE"/logs/catalina.%Y-%m-%d.out >> /dev/null 2>&1 &

  fi