Fix rotating logs.
Encapsulate main loop with try except.