Ensure that logging remains active until the task finishes.