Ruby on Rails Thursday, January 1, 2015

Hi All, 

I have implemented the log rotation feature for my application, and I am seeing unexpected behaviors in the log rotation.

​config.logger =​
 
​::​
Logger.new('log/production.log', 3, 50.kilobytes)

ASSUMPTIONS:  

I have assumed that the above code will rotate the log whenever the log file reaches 50KB, as same as the below manner

1. When I restart the application with log rotation changes, old log file needs to be moved to backup logs if it is has content more than 50KB
2. production.log reaches 50 KB first time
3. production.log content will be moved to new file called  production.log.0
4. production.log again reaches 50 KB
5. production.log.0 content will be moved completely to production.log.1
6. production.log content moved to  production.log.0 and the production.log becomes  empty.
7. The contents of the the log files production.log, production.log.0 and production.log.1 are needs to be in sequentia order like below
  •      production.log has content FROM 11AM to 12PM
  •      production.log.0  has content FROM 10AM to 11AM
  •      production.log.1  has content FROM 9AM to 10AM

Actual behavior:

1. When I start the application after log rotation settings, my current log is cleared completely and no backup is taken
2. Then I process some request in my application
3. production.log reaches 50 KB first time
4. Part of the content of  production.log is moved to production.log.0
5. Part of the content of  production.log.0 is moved to production.log.1
6. The contents of the  log files production.log,  production.log.0 and production.log.1 are not in sequential order, instead it has the content as like below

  •      production.log has content FROM 11AM to 12PM
  •      production.log.0  has content FROM 10AM to 1AM
  •      production.log.1  has content FROM 9AM to 10AM, and some contents from 11.20AM to 11.25AM
Can anybody let me know
​the way that log rotation works?

regards,
Loganathan
Mob: +91 7760780741 | +91 9944414388
Skype: loganathan.sellappa
ViewMe


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAD_i5MGgV51M%3DrDEckn6PnvLUXpwJbJT2O9RJDafunn%2BZLHWnQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment