Tomcat的日志切分和定时删除

 

在我负责的一个小系统中,Linux环境下,由于默认日志都是写入在 cattalina.out中,

我查看日志catalina.out 竟然已经到了 40G了,我想做一下 文件内容检索来追踪问题都无法进行。

于是我决定删除以前的无用日志,以每日作为单位将其进行切分,并写一个定时脚本,定时删除1个月以前的日志数据。

 

Google了一下,大部分都是使用 Cronolog 工具进行切分日志,这里我也是第一次接触,记录一下操作过程方便日后再次使用。

 

话不多说,先看 cronolog 的官网介绍和下载

这里我试着用 yum install cronolog 发现不行,阿里云镜像找不到,就下载包的方式进行安装了。

github上有其项目,网址 https://github.com/fordmason/cronolog

简易介绍:

CRONOLOG version 1.6.1 "cronolog" is a simple program that reads log messages from its input and writes them to a set of output files, the names of which are constructed using a template and the current date and time. The template uses the same format specifiers as the Unix date command (which are the same as the standard C strftime library function). "cronolog" is intended to be used in conjunction with a Web server, such as Apache, to split the access log into daily or monthly logs.

 

大体意思:

“ cronolog”是一个简单程序,可从其输入中读取日志消息并将它们写入一组输出文件,其名称为使用模板名和当前日期和时间进行构造。

模板使用与Unix date命令相同的格式说明符(与标准C strftime库函数相同)。

“ cronolog”旨在与Web服务器结合

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值