For a Rails 3.1 (will be 3.2 very soon), I have exceptionally verbose logs that have a lot of additional worker information spewing forth into them.
I routinely end up with multigigabyte development.log
files. I've seen some various chatter around about rotating production logs, however I've not found anything that seems applicable to development.log
rotation.
How do you rotate your development.log
at every 100.megabytes
or so? OR WHAT I WOULD PREFER is to actually truncate the head of the file so that only the most recent items remain in the log, up to 100MB of the most recent entries.
I have played with this a little and am thinking more and more than nothing quite like this exists at present and that perhaps I should implement something that will use the ruby File.truncate
somehow, however I'm not sure of the efficacy of this yet on the tail end of the file as of yet.
Each file should be rotated weekly. The log rotation job runs nightly, though, so this can be changed to daily for a specific log file if desired. The three commands that specify how often rotation should take place are daily, weekly and monthly. Keep four sets of log files.
In information technology, log rotation is an automated process used in system administration in which log files are compressed, moved (archived), renamed or deleted once they are too old or too big (there can be other metrics that can apply here).
If you want to rotate /var/log/syslog it needs to be listed in a logrotate config file somewhere, and you just run logrotate . If it rotated recently, then logrotate -f to force it to do it again. So, you need that in a file, normally either /etc/logrotate. conf or as a file snippet in /etc/logrotate.
If you want to force Logrotate to rotate the log file when it otherwise would not have, use the --force flag: logrotate /home/sammy/logrotate. conf --state /home/sammy/logrotate-state --verbose --force.
You can actually tell the Ruby Logger class to rotate the files in the constructor:
http://corelib.rubyonrails.org/classes/Logger.html#M000163
Example:
Logger.new(name, shift_age = 7, shift_size = 1048576)
In one of my enrivornment files I have the following line:
config.logger = Logger.new("#{RAILS_ROOT}/log/#{ENV['RAILS_ENV']}.log", 10, 1048576)
This keeps the last 10 logfiles which are rotated every 1 MB.
On OSX i would use newsyslog
/etc/newsyslog.conf
On a Linux OS: logrotate
logrotate
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With