zoukankan      html  css  js  c++  java
  • Tomcat6,7,8的日志切割

    使用的日志切割工具cronolog(yum就可以了)

    确定好路径后,开始配置

    Tomcat6

    Tomcat6/bin/catalina.sh

    292-317行(修改两处)

    修改之后为下面的内容

    # touch "$CATALINA_BASE"/logs/catalina.out

    if [ "$1" = "-security" ] ; then
    echo "Using Security Manager"
    shift
    "$_RUNJAVA" "$LOGGING_CONFIG" $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
    >> "$CATALINA_BASE" 2>&1 &

    if [ ! -z "$CATALINA_PID" ]; then
    echo $! > $CATALINA_PID
    fi
    else
    "$_RUNJAVA" "$LOGGING_CONFIG" $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/sbin/cronolog "$CATALINA_BASE"/logs/catalina.%Y-%m-%d.out >> /dev/null &

    Tomcat7

    400-422行左右(修改两处)

    我粘出来的是的修改之后

    # touch "$CATALINA_OUT"
    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
    -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 $_NOHUP ""$_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/sbin/cronolog "$CATALINA_BASE"/logs/catalina.%Y-%m-%d.out >> /dev/null &

    Tomcat8

    439-466行(修改三处)

    # touch "$CATALINA_OUT"
    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
    | /usr/sbin/cronolog "$CATALINA_BASE"/logs/catalina.%Y-%m-%d.out >> /dev/null &

    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
    | /usr/sbin/cronolog "$CATALINA_BASE"/logs/catalina.%Y-%m-%d.out >> /dev/null &

  • 相关阅读:
    CC.NET+SVN+Msbuild
    react服务端/客户端,同构代码心得
    为什么国人很难出高质量开源
    FKP,一套全栈框架,基于react、webpack、koa1、babel
    嵌入式工程师的发展路线
    浅谈学习单片机的一些职业规划
    关于嵌入式新手面试的一些小技巧
    几点心得送给学习嵌入式的新手
    新手学习嵌入式需要掌握的几点知识点
    从迷茫到转机,一个嵌入式工程师的经历
  • 原文地址:https://www.cnblogs.com/zlf1/p/9207700.html
Copyright © 2011-2022 走看看