flush log periodically