[SPARK-3562]Periodic cleanup event logs

Actually, usually we use this style for this kind of code:

    logDirs.foreach { dir =>
      blah
    }