[SPARK-3562]Periodic cleanup event logs

nit: `if (`