Question

Rails 3 appears to automatically truncate production logs after some unknown period. I would like to be able to save production logs for up to the past 90 days in order to be able to audit the behavior of my app. According to this answer, the old Rails Logger supported at least separating logs into different days, if not deleting the old ones automatically, but Rails now uses BufferedLogger which doesn't support these options.

Either way, it looks like I may have to resort to configuring Unix's logrotate to get the log retention policy I want. That's fine by me, but I'll also have to prevent Rails from automatically truncating the log so that I don't lose anything, and I'm not sure how to do that.

Is there an alternative logging facility for use with Rails (perhaps a gem) which can handle this all in one place? And if not, how do I prevent BufferedLogger from truncating logs so it doesn't get in logrotate's way?

Was it helpful?

Solution

AFAIK, there is no truncation at all. BufferedLogger source does not show any limiting of the log file.

And http://engineering.freeagent.com/2011/10/12/understanding-the-rails-logger/ is a good guide to some internals. But it does seem you need to do the rotation yourself.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top