标签:否则 uri 出现 dirname range catalina cront app 编译环境
1、使得只生成catalina.out
2、自动按日切割压缩打包日志(tar.gz)
3、删除15天前的旧文件
4、使用cronolog定时执行该脚本
#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.
修改conf/server.xml文件 注释掉下面的一段话
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
#!/bin/bash
DIR=$(dirname "$PWD")
echo $DIR/logs
d=`date +%Y%m%d%H`
cd $DIR/logs
cp catalina.out catalina.out.${d}
echo "" > catalina.out
tar -czvf catalina.out.${d}.tar.gz catalina.out.${d}
rm -rf catalina.out.${d}
find $DIR/logs -type f -mtime +15 -exec rm -f {} \;
#下载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
#列出所有文件
ll
#configure,若不想自定义安装路径则直接./configure
./configure --prefix=/usr/local/cronolog
#若发现缺很多包,安装之,否则不用管
yum install gcc cc aclocal autoconf automake autoheader makeinfo
#若前面出现缺编译环境,并已经安装了编译环境,则再次configure,否则不用管,若不想自定义安装路径则直接./configure
./configure --prefix=/usr/local/cronolog
#make
make
#安装
make install
#检查/usr/local/cronolog下是否有文件,如果有结果则安装成功
cd /usr/local/cronolog
ll
#若不是自定义路径安装的使用下面命令看,如果有结果则安装成功
which cronolog
crontab -e #按i 写入下面的内容 :w 保存内容
50 23 * * * /root/dev/tomcat-8.5.53-elite/bin/catalina-cut.sh
表示每天23点50分执行目录/root/dev/tomcat-8.5.53-elite/bin下的catalina-cut.sh脚本
Tomcat 日志设置 减少不必要的日志,针对tomcat日志过大的优化
标签:否则 uri 出现 dirname range catalina cront app 编译环境
原文地址:https://www.cnblogs.com/virtulreal/p/9914542.html