only clean logs if logs exist

Closes #29355.