[master] Support for rolling logs

This replaces #3009 that was messed up. 

Adds support for rolling logs. When the log is rolled over diagnostics information is added to the top of the new log.

I think something went wrong in a rebase or something, the changes doesn't make sense. Any change to `ParallelBatchImporterTest` seems unnecessary.