log and restore