使用旋转与log4j的弹性魔豆S3记录弹性、魔豆、log4j

由网友(微笑向暖、安之若素つ)分享简介:我想每个日志文件传输到S3。有一个自动脚本,拿起 tail_catina.log 并覆盖任何东西在那里。I'm trying to transfer each log file to s3. There is an automatic script that picks up tail_catina.log and...

我想每个日志文件传输到S3。有一个自动脚本,拿起 tail_catina.log 并覆盖任何东西在那里。

I'm trying to transfer each log file to s3. There is an automatic script that picks up tail_catina.log and overwrites anything there.

我希望每个日志文件: tail_catalina.log1 tail_catalina.log2 tail_catalina .log3 等保存到我的S3。

I want each log file: tail_catalina.log1, tail_catalina.log2, tail_catalina.log3 etc. saved to my s3.

我想要的一切!

推荐答案

我用的基本组合的 logrotate的 s3cmd 和的cron 实现这个很简单。

I use a basic combination of logrotate, s3cmd, and cron to achieve this quite simply.

我已经在我的博客做了详细的书面记录和解释。它应该对任何运行在Linux环境中的Apache服务器。我希望人们能有所帮助,因为我花了几个小时,以获得细节敲定了。

I've done a detailed writeup and explanation on my blog. It should work for anyone running an Apache server on a linux environment. I hope folks find it helpful as it took me a few hours to get the details hammered out.

基本的脚本如下,请参阅博客张贴的逐行明细:

The basic script is below, see the blog posting for a line by line breakdown:

# rotate the logs!
# common settings
compress
compresscmd /bin/gzip
compressoptions -9
compressext .gz

dateext
dateformat -%Y-%m-%d-%s

rotate 3
nomail
missingok
daily
size 5k
create 640 username username

/var/logs/www.runpartner.com/*.log {
sharedscripts
postrotate
sudo /usr/sbin/apache2ctl graceful

/usr/bin/s3cmd sync /var/logs/www.runpartner.com/*.gz s3://bucket-logs/www.runpartner.com/
endscript
}
阅读全文

相关推荐

最新文章