Flush the log before sleeping in event loop.