码迷,mamicode.com
首页 > 其他好文 > 详细

Tomcat 每天生成 catalina.out

时间:2019-10-26 17:22:49      阅读:96      评论:0      收藏:0      [点我收藏+]

标签:figure   install   nohup   get   blog   logging   tom   man   file   

1.安装cronolog
  wget https://files.cnblogs.com/files/crazyzero/cronolog-1.6.2.tar.gz

  tar -zxvf cronolog-1.6.2.tar.gz

  cd cronolog-1.6.2

  ./configure

  make && make install

  或者 yum install cronolog

2.检查是否安装成功

  which cronolog

  正常显示 /usr/local/sbin/cronolog

3.tomcat8.5版本修改catalina.out文件

  直接将第453-491的代码

shift
  if [ -z "$CATALINA_OUT_CMD" ] ; then
    touch "$CATALINA_OUT"
    catalina_out_command=">> \"$CATALINA_OUT\" 2>&1"
  else
    catalina_out_command="| $CATALINA_OUT_CMD"
  fi
  if [ ! -z "$CATALINA_PID" ]; then
    catalina_pid_file="$CATALINA_PID"
  else
    catalina_pid_file=/dev/null
  fi
  if [ "$1" = "-security" ] ; then
    if [ $have_tty -eq 1 ]; then
      echo "Using Security Manager"
    fi
    shift
    eval \{ $_NOHUP "\"$_RUNJAVA\"" "\"$LOGGING_CONFIG\"" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \
      -D$ENDORSED_PROP="\"$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 \
      2\>\&1 \&\& echo \$! \>\"$catalina_pid_file\" \; \} $catalina_out_command "&"

  else
    eval \{ $_NOHUP "\"$_RUNJAVA\"" "\"$LOGGING_CONFIG\"" $LOGGING_MANAGER $JAVA_OPTS $CATALINA_OPTS \
      -D$ENDORSED_PROP="\"$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 \&\& echo \$! \>\"$catalina_pid_file\" \; \} $catalina_out_command "&"

  fi

覆盖替换为

shift
  #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  2>&1 \
        | /usr/local/sbin/cronolog "$CATALINA_BASE"/logs/catalina.%Y-%m-%d_%H.out >> /dev/null &

  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 "$CATALINA_BASE"/logs/catalina.%Y-%m-%d_%H.out >> /dev/null &

  fi

Tomcat 每天生成 catalina.out

标签:figure   install   nohup   get   blog   logging   tom   man   file   

原文地址:https://www.cnblogs.com/xiaofengfree/p/11743665.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!