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

Tomcat7 catalina.out 日志分割

时间:2017-07-13 18:57:04      阅读:125      评论:0      收藏:0      [点我收藏+]

标签:tomcat7 catalina.out 日志分割

安装过程如下:

下载(最新版本)

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


2、解压缩

    # tar zxvf cronolog-1.6.2.tar.gz

3、进入cronolog安装文件所在目录

    # cd cronolog-1.6.2

4、运行安装

    # ./configure
    # make
    # make install

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

    # which cronolog

一般情况下显示为:/usr/local/sbin/cronolog

要想分割tomcat7的catalina.out,需作如下工作:

进入Tomcat的bin目录,打开catalina.sh文件,一般我们修改下面行中的内容(做好用root用户),

(1)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
(2)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 \
      >> "$CATALINA_OUT" 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 \
      >> "$CATALINA_OUT" 2>&1 "&"

       

  fi

  if [ ! -z "$CATALINA_PID" ]; then
    echo $! > "$CATALINA_PID"
  fi
改为:
#  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 2>&1 \
      | /usr/local/sbin/cronolog "$CATALINA_OUT" >> /dev/null &

  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_OUT" >> /dev/null &


  fi

  if [ ! -z "$CATALINA_PID" ]; then
    echo $! > "$CATALINA_PID"
  fi  


Tomcat7 catalina.out 日志分割

标签:tomcat7 catalina.out 日志分割

原文地址:http://12927979.blog.51cto.com/12917979/1947185

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