Avoid endless loop when exporting logs

fixes #4470