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
-
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 -
production.log reaches 50 KB first time
-
production.log content will be moved to new file called
production.log.0 -
production.log again reaches 50 KB
-
production.log.0 content will be moved completely to production.log.1
-
production.log content moved to production.log.0 and the
production.log
becomes empty. -
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:
-
When I start the application after log rotation settings, my current
log
is cleared completely and no backup is taken -
Then I process some request in my application
-
production.log reaches 50 KB first time
-
Part of the content of production.log is moved to production.log.0
-
Part of the content of production.log.0 is moved to production.log.1
-
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 http://vizualize.me/loganathan