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

tomcat日志管理

时间:2016-08-10 01:11:33      阅读:644      评论:0      收藏:0      [点我收藏+]

标签:catalina 切割

一、tomcat关闭不必要的日志

编辑tomcat下conf/logging.properties

1catalina.org.apache.juli.FileHandler.level = FINE

1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs

1catalina.org.apache.juli.FileHandler.prefix = catalina.


2localhost.org.apache.juli.FileHandler.level = FINE

2localhost.org.apache.juli.FileHandler.directory = ${catalina.base}/logs

2localhost.org.apache.juli.FileHandler.prefix = localhost.


3manager.org.apache.juli.FileHandler.level = FINE

3manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs

3manager.org.apache.juli.FileHandler.prefix = manager.


4host-manager.org.apache.juli.FileHandler.level = FINE

4host-manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs

4host-manager.org.apache.juli.FileHandler.prefix = host-manager.

把上面的内容都添加注释


二、tomcat catalina.out日志按天切割

yum install -y cronolog

修改bin/catalina.sh脚本

将184行附近的

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


将if [ "$1" = "-security" ]附近的

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/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/sbin/cronolog "$CATALINA_OUT" >> /dev/null &


  fi


  if [ ! -z "$CATALINA_PID" ]; then

    echo $! > "$CATALINA_PID"

  fi


本文出自 “pc的个人博客” 博客,请务必保留此出处http://pc1990.blog.51cto.com/10541224/1836201

tomcat日志管理

标签:catalina 切割

原文地址:http://pc1990.blog.51cto.com/10541224/1836201

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