降低AWS EC2的日志轮换频率 [英] Reducing log rotation frequency for AWS EC2

查看:103
本文介绍了降低AWS EC2的日志轮换频率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在弹性beantalk上运行的Java应用程序,设置了到S3的日志旋转并正常工作.但是,我发现我的catalina.out日志文件最多只能保留15分钟,然后再滚动到新文件,这使得同一天的调试问题变得更加繁琐(从s3中获取gz并解压缩,而不仅仅是ssh-ing和读取日志文件).

I have a java app running on elastic beanstalk, with the log rotation to S3 set up and working fine. However, I find that my catalina.out log file only exists for up to 15 minutes before rolling to a new file, which makes debugging problems on the same day more tedious (get gz from s3 and unzip, instead of just ssh-ing and reading the log file).

是否有任何方法可以通过tomcat/log4j或elastic-beanstalk控制台进行配置?我相信这是AWS的事情,因为我们在Dotcloud上部署了相同的应用程序,并且每天只保留一个日志文件.

Is there any way to configure this through tomcat/log4j or the elastic-beanstalk console? I believe it's an AWS thing, because we had the same app deployed on Dotcloud and it kept a single log file per day.

推荐答案

截至今天为止,并非如此.您唯一可以做的就是在运行应用程序的EC2实例中修改文件/etc/logrotate.conf.elasticbeanstalk.

As of Today, not really. The only thing that you can do is modify the file /etc/logrotate.conf.elasticbeanstalk in the EC2 instance where your app is running.

更改日志的大小,应在一个文件中添加更多日志信息:

Change the size of the log and that should put more log info in one file:

/var/log/tomcat6/catalina.out /var/log/tomcat6/monitor_catalina.log /var/log/tomcat6/tail_catalina.log {
    size 20M <-- change to the file size that you want
    missingok
    rotate 2
    compress
    notifempty
    copytruncate
    dateext
    dateformat -%s
    lastaction
        /bin/chown tomcat:elasticbeanstalk /var/log/tomcat6/*gz; /bin/chmod 664 /var/log/tomcat6/*gz
    endscript
}

这里还有另一篇文章,提供了更多信息:

There's another post that has more info here:

使用带Elastic Beanstalk的log4j旋转S3日志记录

这篇关于降低AWS EC2的日志轮换频率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆