The solution in your rotate-by-size configuration is probably just a
line or two in shift_log_age that checks whether the file *on disk* has
already been rotated (by checking its size), and if so just reopen it
instead of doing all the renames.

Although, I should say that both this and my patch to shift_log_period
have a possible race condition in the "check then rotate" flow. Since
it's not atomic, some kind of basic IPC is needed to synchronize that
bit of code.

 - Guy.

Alex Young wrote:
> There's definitely something screwy going on.  Try this code:
>
> require 'logger'
>
> logger = Logger.new('test.log', 100, 70 * 1024)
>
> 100.times do
>    fork {
>      1000.times do
>        logger.info("This is a test line.")
>      end
>    }
> end
>
> I know, 100 is a ridiculous number.  It runs, though.  It should result
> in 100 full logfiles.  However, running this on my machine (Ubuntu 6.06,
> ruby 1.8.4) results in Logger::ShiftingErrors being thrown, and the
> logfile list when it's finished is incomplete (the last run only left 84
> logfiles, with apparently random gaps in the sequence), so there's been
> data loss - I presume from when the processes fell over having failed to
> log.
> 
> -- 
> Alex