in reply to reading of log files

To really help, we'd need an example of your typical logfile output, and THEN an example of one that failed. With those pieces, one could write the script you are looking for. Without them, it'll all be generalities and guesses.